-
Notifications
You must be signed in to change notification settings - Fork 92
147 lines (134 loc) · 5.7 KB
/
Copy pathtest-fork-pr.yml
File metadata and controls
147 lines (134 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Test Fork PR
on:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request number to test'
required: true
type: number
permissions:
contents: read
checks: write
pull-requests: read
env:
PYTHON_VERSION: "3.11"
UV_VERSION: "0.7.13"
jobs:
setup:
name: Validate PR
runs-on: ubuntu-latest
outputs:
head_sha: ${{ steps.pr-info.outputs.head_sha }}
head_repo: ${{ steps.pr-info.outputs.head_repo }}
steps:
- name: Get PR information
id: pr-info
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ inputs.pr_number }}
});
if (pr.data.state !== 'open') {
core.setFailed(`PR #${{ inputs.pr_number }} is not open`);
return;
}
if (pr.data.head.repo.full_name === `${context.repo.owner}/${context.repo.repo}`) {
core.setFailed(`PR #${{ inputs.pr_number }} is not from a fork. Use the regular workflow.`);
return;
}
core.setOutput('head_sha', pr.data.head.sha);
core.setOutput('head_repo', pr.data.head.repo.full_name);
console.log(`Testing PR #${{ inputs.pr_number }}`);
console.log(` Head SHA: ${pr.data.head.sha}`);
console.log(` Head Repo: ${pr.data.head.repo.full_name}`);
service-tests:
name: Service Tests
runs-on: ubuntu-latest
needs: setup
steps:
- name: Create check run
id: check
uses: actions/github-script@v7
with:
script: |
const check = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Fork PR - Service Tests',
head_sha: '${{ needs.setup.outputs.head_sha }}',
status: 'in_progress',
started_at: new Date().toISOString()
});
core.setOutput('check_id', check.data.id);
- name: Check out fork PR code
uses: actions/checkout@v6
with:
repository: ${{ needs.setup.outputs.head_repo }}
ref: ${{ needs.setup.outputs.head_sha }}
- name: Run service tests
uses: ./.github/actions/run-service-tests
with:
python-version: ${{ env.PYTHON_VERSION }}
uv-version: ${{ env.UV_VERSION }}
env:
HF_HOME: ${{ github.workspace }}/hf_cache
HF_TOKEN: ${{ secrets.HF_TOKEN }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_DEPLOYMENT_NAME }}
OPENAI_API_VERSION: ${{ secrets.OPENAI_API_VERSION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
LANGCACHE_WITH_ATTRIBUTES_API_KEY: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_API_KEY }}
LANGCACHE_WITH_ATTRIBUTES_CACHE_ID: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_CACHE_ID }}
LANGCACHE_WITH_ATTRIBUTES_URL: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_URL }}
LANGCACHE_NO_ATTRIBUTES_API_KEY: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_API_KEY }}
LANGCACHE_NO_ATTRIBUTES_CACHE_ID: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_CACHE_ID }}
LANGCACHE_NO_ATTRIBUTES_URL: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_URL }}
- name: Update check run (success)
if: success()
uses: actions/github-script@v7
with:
script: |
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: ${{ steps.check.outputs.check_id }},
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
output: {
title: 'Service Tests Passed',
summary: `All service tests passed for PR #${{ inputs.pr_number }}.`
}
});
- name: Update check run (failure)
if: failure()
uses: actions/github-script@v7
with:
script: |
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: ${{ steps.check.outputs.check_id }},
status: 'completed',
conclusion: 'failure',
completed_at: new Date().toISOString(),
details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
output: {
title: 'Service Tests Failed',
summary: `The service tests failed for PR #${{ inputs.pr_number }}. Click "Details" to view the full test output and logs.`,
text: `**Workflow Run:** [View Details](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})\n\n**PR:** #${{ inputs.pr_number }}\n**Commit:** ${{ needs.setup.outputs.head_sha }}`
}
});