Skip to content

Commit cfdf0cc

Browse files
Update CI/Coverity workflows to match mvn_01 (#8)
1 parent d996147 commit cfdf0cc

File tree

3 files changed

+121
-72
lines changed

3 files changed

+121
-72
lines changed

.github/workflows/ci.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
name: CI
22

3-
on: push
3+
on: [ push ]
44

55
jobs:
6-
# Confirm the coverity upload
7-
coverity_upload:
8-
uses: teragrep/rlp_02/.github/workflows/coverity_upload.yaml@main
9-
secrets:
10-
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
11-
COVERITY_EMAIL: ${{ secrets.COVERITY_EMAIL }}
12-
6+
upload:
7+
name: CI
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Cache Local Maven Repository
14+
uses: actions/cache@v4
15+
with:
16+
path: ~/.m2/repository
17+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
18+
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: 8.0.292+10
23+
distribution: 'adopt'
24+
25+
- name: Run CI
26+
run: mvn --batch-mode clean verify

.github/workflows/coverity.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Coverity
2+
3+
on: push
4+
5+
jobs:
6+
verify:
7+
name: Verify Code
8+
runs-on: ubuntu-latest
9+
if: ${{ startsWith(github.repository, 'teragrep/') }}
10+
11+
env:
12+
COVERITY: coverity_tool
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install jq
20+
run: sudo apt-get update && sudo apt-get install jq
21+
22+
- name: Get version
23+
run: printf "RELEASE_VERSION=%q\n" "$(git describe --tags)" >> $GITHUB_ENV
24+
25+
- name: Setup Maven Central
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: 8.0.292+10
29+
distribution: 'adopt'
30+
31+
- name: Cache Local Maven Repository
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.m2/repository
35+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
36+
37+
- name: Download Coverity distribution md5sum for cache key
38+
run: wget https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project_id=${{ vars.COVERITY_PROJECT_URL_ID }}&md5=1" -O coverity_tool.md5
39+
40+
- name: Cache pull Coverity distribution, extracted
41+
id: cache-pull-coverity-distribution
42+
uses: actions/cache@v4
43+
with:
44+
path: ${{ runner.temp }}/${{ env.COVERITY }}
45+
key: ${{ runner.os }}-coverity-${{ hashFiles('coverity_tool.md5') }}
46+
47+
- name: Move coverity_tool.md5 file so it won't conflict with maven
48+
run: mv coverity_tool.md5 ${RUNNER_TEMP}/coverity_tool.md5
49+
50+
- name: Download and extract Coverity distribution if cache-miss
51+
if: steps.cache-pull-coverity-distribution.outputs.cache-hit != 'true'
52+
run: |
53+
wget --quiet https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project_id=${{ vars.COVERITY_PROJECT_URL_ID }}" -O ${RUNNER_TEMP}/${{ env.COVERITY }}.tgz
54+
mkdir -p ${RUNNER_TEMP}/${{ env.COVERITY }}
55+
tar zxf ${RUNNER_TEMP}/${{ env.COVERITY }}.tgz -C ${RUNNER_TEMP}/${{ env.COVERITY }} --strip-components 1
56+
57+
- name: Compile Coverity
58+
run: |
59+
${RUNNER_TEMP}/${{ env.COVERITY }}/bin/cov-build --dir ${RUNNER_TEMP}/cov-int mvn -B -Drevision=${{ env.RELEASE_VERSION }} -Dsha1= -Dchangelist= -Dmaven.test.skip.exec=true clean verify
60+
cd ${RUNNER_TEMP} && tar czvf ${{ vars.COVERITY_PROJECT_URL_ID }}.tgz cov-int
61+
62+
- name: Wait for Coverity analysis slot
63+
run: |
64+
while true; do
65+
curl -X POST -d version=${{ env.RELEASE_VERSION }} -d description="automated upload" -d email=${{ secrets.COVERITY_EMAIL }} -d token=${{ secrets.COVERITY_TOKEN }} -d file_name="${{ vars.COVERITY_PROJECT_URL_ID }}.tgz" https://scan.coverity.com/projects/${{ vars.COVERITY_PROJECT_URL_ID }}/builds/init -o ${RUNNER_TEMP}/response;
66+
67+
if grep -q 'build submission quota' ${RUNNER_TEMP}/response; then
68+
cat ${RUNNER_TEMP}/response
69+
echo 'Giving up, submission quota met'
70+
exit 1
71+
fi;
72+
73+
if grep -q 'already in the queue' ${RUNNER_TEMP}/response; then
74+
cat ${RUNNER_TEMP}/response
75+
echo 'Waiting for 15 seconds and retrying'
76+
sleep 15
77+
else
78+
break
79+
fi
80+
done
81+
82+
- name: Prepare response url
83+
run: printf "RESPONSE_URL=%q\n" "$(jq -r '.url' ${RUNNER_TEMP}/response)" >> $GITHUB_ENV
84+
85+
- name: Upload to Coverity
86+
run: |
87+
curl -X PUT --header 'Content-Type: application/json' --upload-file ${RUNNER_TEMP}/${{ vars.COVERITY_PROJECT_URL_ID }}.tgz ${{ env.RESPONSE_URL }}
88+
89+
- name: Prepare build id
90+
run: printf "COVERITY_BUILD_ID=%q\n" "$(jq -r '.build_id' ${RUNNER_TEMP}/response)" >> $GITHUB_ENV
91+
92+
- name: Build Coverity Submit URL
93+
run: printf 'COVERITY_SUBMIT_URL=%q/%s/builds/%s/enqueue' "https://scan.coverity.com/projects" "${{ vars.COVERITY_PROJECT_URL_ID }}" "${{ env.COVERITY_BUILD_ID }}" >> $GITHUB_ENV
94+
95+
- name: Trigger Coverity analysis
96+
run: curl -X PUT -d token=${{ secrets.COVERITY_TOKEN }} ${{ env.COVERITY_SUBMIT_URL }}
97+
98+
- name: Restore coverity_tool.md5 file so caches can be generated
99+
run: mv ${RUNNER_TEMP}/coverity_tool.md5 coverity_tool.md5

.github/workflows/coverity_upload.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)