-
Notifications
You must be signed in to change notification settings - Fork 3
67 lines (62 loc) · 2.43 KB
/
integration_tests.yaml
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
name: Integration tests
on:
pull_request:
branches-ignore:
- 'test-branch/**'
jobs:
integration-tests:
runs-on: ubuntu-22.04
if: ${{ !failure() }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Install tox
run: python3 -m pip install tox
- name: Run integration tests
id: run-tests
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
CI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Ensure that stdout appears as normal and redirect to file and exit depends on exit code of first command
STDOUT_LOG=$(mktemp --suffix=stdout.log)
echo STDOUT_LOG=$STDOUT_LOG >> $GITHUB_ENV
tox -e test,coverage-report --result-json=test-result.json | tee $STDOUT_LOG ; test ${PIPESTATUS[0]} -eq 0
- name: Export test report
if: always()
uses: actions/github-script@v6
with:
script: |
const no_color = (text) => {
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
}
const sha = '${{ github.event.pull_request.head.sha }}';
const fs = require('fs');
const result = JSON.parse(fs.readFileSync('./test-result.json')).testenvs;
let int_result = result.test.test;
let int_success = int_result[0].retcode == 0;
let int_output = int_result[0].output;
let coverage_result = result["coverage-report"].test;
let coverage_output = coverage_result[0].output;
let reports = [];
if (!int_success) {
reports.push(
`Integration tests failed for ${sha}\n
\`\`\`\n${no_color(int_output).trim()}\n\`\`\``
);
}
reports.push(
`Test coverage for ${sha}\n
\`\`\`\n${no_color(coverage_output).trim()}\n\`\`\``
);
let json = JSON.stringify(reports);
fs.writeFileSync('report_int.json', json);
- name: Upload coverage report
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: report
path: report_int.json
- name: Report
if: always()
id: report
run: echo "outcome=${{ steps.run-tests.conclusion }}" >> $GITHUB_OUTPUT