Repository navigation
60 lines (55 loc) · 3.3 KB
/
Copy pathcodacy.yml
File metadata and controls
60 lines (55 loc) · 3.3 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
name: Codacy Coverage Reporter
# workflow_run is what gives this job the secret after a run of CI on a pull request. It does not check out or run anything
# of the pull request: it downloads the coverage files, and reads them with a reporter pinned to a checksum.
on: # zizmor: ignore[dangerous-triggers]
workflow_run:
workflows:
- CI
types:
- completed
workflow_dispatch:
permissions:
contents: read
# needed to download the artifact of the CI run with the default GITHUB_TOKEN
actions: read
jobs:
report-coverage-linux:
# Forks don't have the secrets. Don't match on owner/name here, that silently
# skipped every run once the repository moved to libmonero.
if: github.event.repository.fork == false && (github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion != 'cancelled')
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Download coverage report
id: download
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: coverage-reports-linux
# without a token the action ignores run-id and looks in the current run
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
# The reporter is the version named here, checked against the SHA-512 written here, which is the one that Codacy publishes
# on GitHub (codacy/codacy-coverage-reporter, release 14.1.3, file codacy-coverage-reporter-linux.SHA512SUM). The action of
# Codacy and its get.sh were not pinned: they change with no commit here, and they ran with the token of the project.
# To update, set the version, download the binary and the .SHA512SUM of the release, check one against the other and write the hash
- name: Download the Codacy reporter
if: ${{ !cancelled() && steps.download.outcome == 'success' }}
env:
REPORTER_VERSION: 14.1.3
REPORTER_SHA512: 73a6c93fc5db509fd0423d6e545759c3f61d8360ee12054e32a9277daab6add0da6c6639248f6ed6c0042366440293ebc0b6144325aef52c5d3d4b230d65eb17
run: |
curl --retry 5 --retry-delay 5 --retry-max-time 150 -fsSLo codacy-coverage-reporter "https://artifacts.codacy.com/bin/codacy-coverage-reporter/$REPORTER_VERSION/codacy-coverage-reporter-linux"
echo "$REPORTER_SHA512 codacy-coverage-reporter" | sha512sum -c -
chmod +x codacy-coverage-reporter
# only this step has the token
- name: Report python, c++ and c coverage
if: ${{ !cancelled() && steps.download.outcome == 'success' }}
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
# the commit that CI ran on, which is the head of the pull request. A manual run has no workflow_run
COMMIT_UUID: ${{ github.event.workflow_run.head_sha || github.sha }}
run: |
./codacy-coverage-reporter report --language python --coverage-reports coverage.xml --partial --commit-uuid "$COMMIT_UUID"
./codacy-coverage-reporter report --language cpp --coverage-reports coverage.info --partial --commit-uuid "$COMMIT_UUID"
./codacy-coverage-reporter report --language c --coverage-reports coverage.info --partial --commit-uuid "$COMMIT_UUID"
./codacy-coverage-reporter final --commit-uuid "$COMMIT_UUID"