@@ -2,14 +2,17 @@ name: Test coverage
22on :
33 schedule :
44 - cron : " 0 22 * * *"
5+ workflow_dispatch : # Allows manual triggering
56
67jobs :
78 test :
89 name : test
910 runs-on : ubuntu-latest
11+ permissions :
12+ contents : read
1013
1114 steps :
12- - uses : actions/checkout@v4
15+ - uses : actions/checkout@v5
1316
1417 - uses : actions/setup-node@v4
1518 with :
@@ -39,93 +42,110 @@ jobs:
3942 - name : Zip coverage report
4043 run : |
4144 zip -r coverage/cobertura-coverage.zip coverage/cobertura-coverage.xml coverage/coverage.xml
42-
45+
4346 - name : Upload coverage report
4447 if : always()
4548 uses : actions/upload-artifact@v4
4649 with :
4750 name : snapcraftio-coverage
4851 path : coverage
4952 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"
10053
54+ publish-coverage-report :
55+ name : publish-coverage-report
56+ runs-on : ubuntu-latest
57+ needs : test
58+ permissions :
59+ contents : write
60+ continue-on-error : true
61+ steps :
62+ - uses : actions/checkout@v5
63+ with :
64+ ref : gh-pages
65+ token : ${{ secrets.GITHUB_TOKEN }}
66+ - name : Cleanup coverage directory
67+ run : |
68+ rm -rf coverage
69+ mkdir coverage
70+ - name : Download coverage report artifact
71+ uses : actions/download-artifact@v5
72+ with :
73+ name : snapcraftio-coverage
74+ path : coverage
75+ # user git configs are needed for git commands to work
76+ # actual authentication is done using secrets.GITHUB_TOKEN with write permission
77+ - name : Set Git User
78+ run : |
79+ git config --global user.email "github-action@example.com"
80+ git config --global user.name "GitHub Action"
81+ - name : Push coverage Report
82+ timeout-minutes : 3
83+ run : |
84+ git add .
85+ git commit -m "workflow: update coverage report"
86+
87+ # In case of another action job pushing to gh-pages while we are rebasing for the current job
88+ while true; do
89+ git pull --rebase
90+ if [ $? -ne 0 ]; then
91+ echo "Failed to rebase. Please review manually."
92+ exit 1
93+ fi
94+
95+ git push
96+ if [ $? -eq 0 ]; then
97+ echo "Successfully pushed HTML report to repo."
98+ exit 0
99+ fi
100+ done
101+ - name : Output Report URL as Worfklow Annotation
102+ run : |
103+ FULL_HTML_REPORT_URL=https://canonical.github.io/snapcraft.io/coverage
104+ echo "::notice title=Published Playwright Test Report::$FULL_HTML_REPORT_URL"
101105
102106 tics-report :
103- runs-on : ubuntu-latest
107+ runs-on : [self-hosted, reactive, amd64, tiobe, noble]
108+ permissions :
109+ contents : read
104110 needs : publish-coverage-report
105111 steps :
106- - uses : actions/checkout@v4
112+ - uses : actions/checkout@v5
107113
108114 - name : Download coverage report artifact
109- uses : actions/download-artifact@v4
115+ uses : actions/download-artifact@v5
110116 with :
111117 name : snapcraftio-coverage
112118 path : coverage
113119
120+ - name : Set up Python 3.10
121+ uses : actions/setup-python@v5
122+ with :
123+ python-version : " 3.10"
124+ cache : " pip"
125+
126+ - name : Set up Node.js
127+ uses : actions/setup-node@v4
128+ with :
129+ node-version : " 22"
130+ cache : " yarn"
131+
114132 - name : Install Python requirements
115133 run : |
116- sudo pip3 install -r requirements.txt
117-
118- - name : Install Python dependencies
119- run : sudo pip3 install pylint
134+ python -m pip install --upgrade pip
135+ pip3 install -r requirements.txt
136+ pip3 install pylint
120137
121138 - name : Install JS dependencies
122- run : yarn install --immutable
123-
124- - name : Produce TICS report
125- shell : bash
126139 run : |
127- set -x
128- export TICSAUTHTOKEN=${{ secrets.TICSAUTHTOKEN }}
129- curl --silent --show-error "https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/" > install_tics.sh
130- . ./install_tics.sh
131- TICSQServer -project snapcraft.io -tmpdir /tmp/tics -branchdir . -nosanity
140+ yarn install --immutable
141+
142+ - name : Run TICS analysis with github-action
143+ uses : tiobe/tics-github-action@v3
144+ with :
145+ mode : qserver
146+ project : snapcraft.io
147+ branchdir : .
148+ viewerUrl : https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default
149+ ticsAuthToken : ${{ secrets.TICSAUTHTOKEN }}
150+ installTics : true
151+
0 commit comments