forked from agentscope-ai/TuFT
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (89 loc) · 3.45 KB
/
unittest.yml
File metadata and controls
102 lines (89 loc) · 3.45 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
name: unittest
on:
issue_comment:
types: [created]
permissions:
contents: write
checks: write
pull-requests: write
jobs:
unittest:
# only run on pull request
if: ${{ github.event.issue.pull_request && (startsWith(github.event.comment.body, '/unittest')) && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') }}
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: tuft-${{ github.run_id }}
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Setup docker compose
working-directory: tuft-${{ github.run_id }}/.github/workflows/docker
run: |
docker compose up -d
sleep 15s
- name: Check ray status
working-directory: tuft-${{ github.run_id }}/.github/workflows/docker
run: |
MAX_RETRIES=90
RETRY_INTERVAL=30
for i in $(seq 1 $MAX_RETRIES); do
if docker compose exec tuft-node-1 bash -c "source /root/.tuft/venv/bin/activate && ray status"; then
break
fi
echo "Waiting for ray cluster to be ready... ($i/$MAX_RETRIES)"
sleep $RETRY_INTERVAL
if [ "$i" -eq "$MAX_RETRIES" ]; then
echo "Ray cluster failed to start after $MAX_RETRIES retries."
exit 1
fi
done
- name: Run unittest
working-directory: tuft-${{ github.run_id }}/.github/workflows/docker
# set a github env variable to indicate tests were run, so that subsequent steps can check it
run: |
echo "tests_run=true" >> $GITHUB_ENV
docker compose exec tuft-node-1 bash -c "source /root/.tuft/venv/bin/activate && pytest tests -v -s --gpu --basetemp /mnt/checkpoints --ctrf report.json"
- name: Convert report.json time to ms
working-directory: tuft-${{ github.run_id }}
if: env.tests_run == 'true' || failure()
run: |
REPORT=report.json
if [ -f "$REPORT" ]; then
jq '(.results.tests[] | .duration, .start, .stop) |= (. * 1000) | (.results.summary.start, .results.summary.stop) |= (. * 1000)' "$REPORT" > "$REPORT.tmp" && mv "$REPORT.tmp" "$REPORT"
fi
- name: Clean checkpoint dir
working-directory: tuft-${{ github.run_id }}/.github/workflows/docker
if: always()
run: |
docker compose exec tuft-node-1 rm -rf /mnt/checkpoints/*
continue-on-error: true
- name: Upload test results
if: env.tests_run == 'true' || failure()
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: tuft-${{ github.run_id }}/report.json
continue-on-error: true
- name: Publish Test Report
if: env.tests_run == 'true' || failure()
uses: ctrf-io/github-test-reporter@v1
with:
report-path: tuft-${{ github.run_id }}/report.json
summary: true
pull-request: false
issue: ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Remove docker compose
working-directory: tuft-${{ github.run_id }}/.github/workflows/docker
if: always()
run: |
docker compose down --remove-orphans
continue-on-error: true
- name: Cleanup workspace
if: always()
run: |
rm -rf tuft-${{ github.run_id }} 2>/dev/null
continue-on-error: true