-
Notifications
You must be signed in to change notification settings - Fork 36
104 lines (92 loc) · 4.11 KB
/
Copy pathlabs_test.yml
File metadata and controls
104 lines (92 loc) · 4.11 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
# This workflow can be tested with `act`: sources/bin/tests/test_labs_test.sh
name: Test changed Lab pages
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
test-changed-labs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0 # ensure full history for merge-base diff
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.13'
- name: Get list of changed files
id: changed-files
run: |
# In a real GitHub PR workflow, checkout action checks out the merge commit by default
# We need to switch to the actual PR head to get the correct diff
echo "Current commit: $(git rev-parse HEAD)"
echo "PR head SHA: ${{ github.event.pull_request.head.sha }}"
# Switch to PR head for accurate diff calculation
git checkout ${{ github.event.pull_request.head.sha }} 2>/dev/null || echo "Using current checkout (local testing)"
# For local testing, check if upstream remote already exists, otherwise try to add it
if ! git remote get-url upstream >/dev/null 2>&1; then
# Check if we can add the upstream remote (for real GitHub workflows)
URL="https://github.com/${{ github.event.pull_request.base.repo.full_name }}/archive/refs/heads/${{ github.event.pull_request.base.ref }}.tar.gz"
HTTP_STATUS_LINE=$(curl -s --head "$URL" | head -n 1)
if echo "$HTTP_STATUS_LINE" | grep -q "200 OK"; then
git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}.git
git fetch --no-tags --depth=1 upstream ${{ github.event.pull_request.base.ref }}
BASE_REF="upstream/${{ github.event.pull_request.base.ref }}"
else
# For local testing, use local main branch as base
echo "Using local ${{ github.event.pull_request.base.ref }} branch for comparison (local testing mode)"
BASE_REF="${{ github.event.pull_request.base.ref }}"
fi
else
git fetch --no-tags --depth=1 upstream ${{ github.event.pull_request.base.ref }}
BASE_REF="upstream/${{ github.event.pull_request.base.ref }}"
fi
# diff between the base and PR head
git diff --name-only $BASE_REF...HEAD | grep '/lab/' > paths.txt || true
echo ""
echo "Changed files:"
cat paths.txt
mkdir -p output
mv paths.txt output/
- name: Test changed Lab pages
id: test-labs
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
run: |
if [ -s output/paths.txt ]; then
echo "Changed files found"
if [ -f "sources/bin/labs_test.py" ]; then
python3 sources/bin/labs_test.py output/paths.txt
else
echo "labs_test.py not found - skipping lab tests (this is expected for testing)"
exit 0
fi
else
echo "No changes to Galaxy Labs found"
fi
continue-on-error: true
- name: Write pull request variables to env.sh
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
BASE_REPO: ${{ github.repository }}
run: |
echo "export PR_NUMBER=${PR_NUMBER}" >> output/env.sh
echo "export BASE_REPO=${BASE_REPO}" >> output/env.sh
- name: Upload test result comments artifact
uses: actions/upload-artifact@v7
with:
name: labs_test_comments
path: output
- name: Check outcome of the previous step
id: check-outcome
run: |
if [ "${{ steps.test-labs.outcome }}" == "failure" ]; then
echo "Test failed"
exit 1
else
echo "Test passed"
fi