Update coverity to new version (#452) #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Coverity | |
on: push | |
jobs: | |
verify: | |
name: Verify Code | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.repository, 'teragrep/') }} | |
env: | |
COVERITY: coverity_tool | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install jq | |
run: sudo apt-get update && sudo apt-get install jq | |
- name: Get version | |
run: printf "RELEASE_VERSION=%q\n" "$(git describe --tags)" >> $GITHUB_ENV | |
- name: Setup Maven Central | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 8.0.292+10 | |
distribution: 'adopt' | |
- name: Cache Local Maven Repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
- name: Install test dependencies | |
run: cd / && sudo apt-get update && sudo apt-get install wget rpm2cpio && sudo wget -q https://download.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/geolite2-city-20180605-1.el8.noarch.rpm && sudo wget -q https://download.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/geolite2-country-20180605-1.el8.noarch.rpm && rpm2cpio geolite2-city-20180605-1.el8.noarch.rpm | sudo cpio -i --make-directories && rpm2cpio geolite2-country-20180605-1.el8.noarch.rpm | sudo cpio -i --make-directories | |
- name: Download Coverity distribution md5sum for cache key | |
run: wget https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project=${{ vars.COVERITY_PROJECT_URL_NAME }}&md5=1" -O coverity_tool.md5 | |
- name: Cache pull Coverity distribution, extracted | |
id: cache-pull-coverity-distribution | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.COVERITY }} | |
key: ${{ runner.os }}-coverity-${{ hashFiles('coverity_tool.md5') }} | |
- name: Download and extract Coverity distribution if cache-miss | |
if: steps.cache-pull-coverity-distribution.outputs.cache-hit != 'true' | |
run: | | |
wget --quiet https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project=${{ vars.COVERITY_PROJECT_URL_NAME }}" -O ${{ env.COVERITY }}.tgz | |
mkdir -p ${{ env.COVERITY }} | |
tar zxf ${{ env.COVERITY }}.tgz -C ${{ env.COVERITY }} --strip-components 1 | |
- name: Wait for Coverity analysis slot | |
run: | | |
while true; do | |
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_NAME }}.tgz" https://scan.coverity.com/projects/${{ vars.COVERITY_PROJECT_URL_ID }}/builds/init -o response; | |
if grep -q 'build submission quota' response; then | |
cat response | |
echo 'Giving up, submission quota met' | |
exit 1 | |
fi; | |
if grep -q 'already in the queue' response; then | |
cat response | |
echo 'Waiting for 15 seconds and retrying' | |
sleep 15 | |
else | |
break | |
fi | |
done | |
- name: Compile Coverity | |
run: | | |
${{ env.COVERITY }}/bin/cov-build --dir cov-int mvn -B -Drevision=${{ env.RELEASE_VERSION }} -Dsha1= -Dchangelist= clean verify | |
tar czvf ${{ vars.COVERITY_PROJECT_URL_NAME }}.tgz cov-int | |
- name: Prepare response url | |
run: printf "RESPONSE_URL=%q\n" "$(jq -r '.url' response)" >> $GITHUB_ENV | |
- name: Upload to Coverity | |
run: | | |
curl -X PUT --header 'Content-Type: application/json' --upload-file ${{ vars.COVERITY_PROJECT_URL_NAME }}.tgz ${{ env.RESPONSE_URL }} | |
- name: Prepare build id | |
run: printf "COVERITY_BUILD_ID=%q\n" "$(jq -r '.build_id' response)" >> $GITHUB_ENV | |
- name: Build Coverity Submit URL | |
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 | |
- name: Trigger Coverity analysis | |
run: curl -X PUT -d token=${{ secrets.COVERITY_TOKEN }} ${{ env.COVERITY_SUBMIT_URL }} |