|
8 | 8 |
|
9 | 9 | permissions: |
10 | 10 | contents: read |
| 11 | + pull-requests: write |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | test: |
14 | 15 | runs-on: ubuntu-latest |
15 | 16 | steps: |
16 | | - - name: Checkout main repository |
| 17 | + - name: Checkout repository |
17 | 18 | uses: actions/checkout@v4 |
18 | 19 |
|
19 | | - - name: Checkout schemas repo |
20 | | - uses: actions/checkout@v4 |
| 20 | + - name: Run tests in devcontainer |
| 21 | + id: test |
| 22 | + uses: devcontainers/ci@v0.3 |
21 | 23 | with: |
22 | | - repository: OBDb/.schemas |
23 | | - path: tests/schemas |
| 24 | + imageName: ghcr.io/obdb/devcontainer |
| 25 | + push: never |
| 26 | + env: | |
| 27 | + GITHUB_SERVER_URL=${{ github.server_url }} |
| 28 | + GITHUB_REPOSITORY=${{ github.repository }} |
| 29 | + GITHUB_SHA=${{ github.sha }} |
| 30 | + GITHUB_RUN_ID=${{ github.run_id }} |
| 31 | + runCmd: | |
| 32 | + pytest tests/ --ignore=tests/schemas -xvs -n auto > ./test-output.txt 2>&1 |
| 33 | + TEST_EXIT=$? |
| 34 | + cat ./test-output.txt |
24 | 35 |
|
25 | | - - name: Set up Python |
26 | | - uses: actions/setup-python@v4 |
27 | | - with: |
28 | | - python-version: '3.13' |
29 | | - cache: 'pip' |
| 36 | + # Format results for PR comment with all required arguments |
| 37 | + /usr/local/bin/format-test-results.sh \ |
| 38 | + test-output.txt \ |
| 39 | + $TEST_EXIT \ |
| 40 | + "$GITHUB_SERVER_URL" \ |
| 41 | + "$GITHUB_REPOSITORY" \ |
| 42 | + "$GITHUB_SHA" \ |
| 43 | + "$GITHUB_RUN_ID" \ |
| 44 | + > ./test-results.md || true |
30 | 45 |
|
31 | | - - name: Install dependencies |
32 | | - run: | |
33 | | - python -m pip install --upgrade pip |
34 | | - pip install -r tests/schemas/requirements.txt |
| 46 | + # Exit with the actual test result |
| 47 | + exit $TEST_EXIT |
35 | 48 |
|
36 | | - - name: Run tests |
37 | | - id: run_tests |
| 49 | + - name: Set test results output |
| 50 | + if: always() && github.event_name == 'pull_request' |
38 | 51 | run: | |
39 | | - pytest tests/ --ignore=tests/schemas -xvs -n auto |
40 | | - continue-on-error: true |
| 52 | + if [ -f test-results.md ]; then |
| 53 | + { |
| 54 | + echo 'TEST_RESULTS<<EOFMARKER' |
| 55 | + cat test-results.md |
| 56 | + echo 'EOFMARKER' |
| 57 | + } >> $GITHUB_ENV |
| 58 | + fi |
41 | 59 |
|
42 | | - - name: Print fix instructions |
43 | | - if: steps.run_tests.outcome == 'failure' |
44 | | - run: | |
45 | | - echo "::notice title=How to fix failed tests::To fix the failed tests, run: python3 tests/update_yaml_tests.py --verbose" |
46 | | - exit 1 |
| 60 | + - name: Comment test results on PR |
| 61 | + if: always() && github.event_name == 'pull_request' |
| 62 | + uses: thollander/actions-comment-pull-request@v2 |
| 63 | + with: |
| 64 | + message: ${{ env.TEST_RESULTS }} |
| 65 | + comment_tag: response-tests |
0 commit comments