-
Notifications
You must be signed in to change notification settings - Fork 112
136 lines (121 loc) · 4.44 KB
/
e2e-spaces.yml
File metadata and controls
136 lines (121 loc) · 4.44 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
name: e2e-spaces
on:
workflow_run:
workflows: ["trigger-e2e-spaces"]
types:
- completed
concurrency:
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-e2e-spaces"
cancel-in-progress: true
permissions: {}
jobs:
get-pr-info:
name: "get-pr-info"
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
permissions:
actions: read
outputs:
pr_number: ${{ steps.pr_info.outputs.pr_number }}
sha: ${{ steps.pr_info.outputs.sha }}
source_repo: ${{ steps.pr_info.outputs.source_repo }}
source_branch: ${{ steps.pr_info.outputs.source_branch }}
steps:
- name: Download PR info artifact
uses: actions/download-artifact@v4
with:
name: pr-info
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Parse PR info
id: pr_info
run: |
cat pr_info.json
echo "pr_number=$(jq -r '.pr_number' pr_info.json)" >> $GITHUB_OUTPUT
echo "sha=$(jq -r '.sha' pr_info.json)" >> $GITHUB_OUTPUT
echo "source_repo=$(jq -r '.source_repo' pr_info.json)" >> $GITHUB_OUTPUT
echo "source_branch=$(jq -r '.source_branch' pr_info.json)" >> $GITHUB_OUTPUT
e2e-test:
name: "e2e-spaces-test"
needs: get-pr-info
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- name: Set pending status
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ needs.get-pr-info.outputs.sha }}',
state: 'pending',
context: 'E2E Spaces Test',
description: 'Running e2e tests on Spaces...',
target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})
- uses: actions/checkout@v4
with:
repository: ${{ needs.get-pr-info.outputs.source_repo }}
ref: ${{ needs.get-pr-info.outputs.sha }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install dependencies
run: |
uv pip install --system -e .[dev,spaces] --prerelease=allow
uv pip install --system pytest gradio-client --prerelease=allow
- name: Delete test Space if exists
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
python -c "
import huggingface_hub
space_id = 'trackio-tests/test_${{ needs.get-pr-info.outputs.pr_number }}'
try:
huggingface_hub.delete_repo(space_id, repo_type='space')
print(f'Deleted existing Space: {space_id}')
except huggingface_hub.errors.RepositoryNotFoundError:
print(f'Space does not exist: {space_id}')
"
- name: Run e2e Spaces tests
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
TEST_SPACE_ID: trackio-tests/test_${{ needs.get-pr-info.outputs.pr_number }}
run: |
pytest tests/e2e-spaces/ -v
- name: Set success status
if: success()
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ needs.get-pr-info.outputs.sha }}',
state: 'success',
context: 'E2E Spaces Test',
description: 'E2E tests passed!',
target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})
- name: Set failure status
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ needs.get-pr-info.outputs.sha }}',
state: 'failure',
context: 'E2E Spaces Test',
description: 'E2E tests failed',
target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})