|
4 | 4 | - cron: "0 22 * * 6" |
5 | 5 |
|
6 | 6 | jobs: |
7 | | - test: |
8 | | - name: test |
9 | | - runs-on: ubuntu-latest |
10 | | - |
11 | | - steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - |
14 | | - - uses: actions/setup-node@v4 |
15 | | - with: |
16 | | - node-version: 20 |
17 | | - |
18 | | - - name: Install JS dependencies |
19 | | - run: yarn install --immutable |
20 | | - |
21 | | - - name: Run JS tests with coverage |
22 | | - run: | |
23 | | - yarn test-js --coverage |
24 | | - mv coverage/js/cobertura-coverage.xml coverage/cobertura-coverage.xml |
25 | | -
|
26 | | - - name: Install Python requirements |
27 | | - run: | |
28 | | - sudo pip3 install -r requirements.txt |
29 | | -
|
30 | | - - name: Install Python dependencies |
31 | | - run: sudo pip3 install coverage |
32 | | - |
33 | | - - name: Run Python tests with coverage |
34 | | - run: | |
35 | | - SECRET_KEY=simplesecretkey coverage run --source=. -m unittest discover tests |
36 | | - coverage xml -o coverage/coverage.xml |
37 | | - coverage html -d coverage/python |
38 | | -
|
39 | | - - name: Zip coverage report |
40 | | - run: | |
41 | | - zip -r coverage/cobertura-coverage.zip coverage/cobertura-coverage.xml coverage/coverage.xml |
42 | | - |
43 | | - - name: Upload coverage report |
44 | | - if: always() |
45 | | - uses: actions/upload-artifact@v4 |
46 | | - with: |
47 | | - name: snapcraftio-coverage |
48 | | - path: coverage |
49 | | - retention-days: 1 |
50 | | - |
51 | | - publish-coverage-report: |
52 | | - name: publish-coverage-report |
53 | | - runs-on: ubuntu-latest |
54 | | - needs: test |
55 | | - continue-on-error: true |
56 | | - steps: |
57 | | - - uses: actions/checkout@v4 |
58 | | - with: |
59 | | - ref: gh-pages |
60 | | - token: ${{ secrets.GITHUB_TOKEN }} |
61 | | - - name: Cleanup coverage directory |
62 | | - run: | |
63 | | - rm -rf coverage |
64 | | - mkdir coverage |
65 | | - - name: Download coverage report artifact |
66 | | - uses: actions/download-artifact@v4 |
67 | | - with: |
68 | | - name: snapcraftio-coverage |
69 | | - path: coverage |
70 | | - # user git configs are needed for git commands to work |
71 | | - # actual authentication is done using secrets.GITHUB_TOKEN with write permission |
72 | | - - name: Set Git User |
73 | | - run: | |
74 | | - git config --global user.email "github-action@example.com" |
75 | | - git config --global user.name "GitHub Action" |
76 | | - - name: Push coverage Report |
77 | | - timeout-minutes: 3 |
78 | | - run: | |
79 | | - git add . |
80 | | - git commit -m "workflow: update coverage report" |
81 | | - |
82 | | - # In case of another action job pushing to gh-pages while we are rebasing for the current job |
83 | | - while true; do |
84 | | - git pull --rebase |
85 | | - if [ $? -ne 0 ]; then |
86 | | - echo "Failed to rebase. Please review manually." |
87 | | - exit 1 |
88 | | - fi |
89 | | - |
90 | | - git push |
91 | | - if [ $? -eq 0 ]; then |
92 | | - echo "Successfully pushed HTML report to repo." |
93 | | - exit 0 |
94 | | - fi |
95 | | - done |
96 | | - - name: Output Report URL as Worfklow Annotation |
97 | | - run: | |
98 | | - FULL_HTML_REPORT_URL=https://canonical.github.io/snapcraft.io/coverage |
99 | | - echo "::notice title=Published Playwright Test Report::$FULL_HTML_REPORT_URL" |
100 | | -
|
101 | | -
|
102 | 7 | tics-report: |
103 | 8 | runs-on: ubuntu-latest |
104 | 9 | needs: publish-coverage-report |
|
0 commit comments