Skip to content

Commit

Permalink
Change covnscan actions to better handle labels
Browse files Browse the repository at this point in the history
Mark the covscan action done when the covscan-ok label is set.

Mark the covscan ok if no source changes are detected

Remove the covscan-ok label if rebases or source files were changed

Signed-off-by: Simo Sorce <[email protected]>
  • Loading branch information
simo5 committed Jun 4, 2024
1 parent facd3eb commit 28502df
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
pull_request_target:
branches: ["main"]
types:
- synchronize
- labeled
schedule:
- cron: '41 3 * * 0'
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
token: ${{ secrets.COVERITY_SCAN_TOKEN }}

on-labeled-pr:
if: ${{ contains(github.event.*.labels.*.name, 'covscan') }}
if: ${{ contains(github.event.action, 'labeled') && contains(github.event.*.labels.*.name, 'covscan') }}
name: Coverity Scan on PR
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -76,16 +77,64 @@ jobs:
token: ${{ secrets.COVERITY_SCAN_TOKEN }}
- name: Remove Label
if: always()
run: gh pr edit "$NUMBER" --remove-label "covscan"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
run: gh pr edit "$NUMBER" --remove-label "covscan"

on-no-covscan-labeled-pr:
if: ${{ contains(github.event.*.labels.*.name, 'no-covscan') }}
if: ${{ contains(github.event.action, 'labeled') && contains(github.event.*.labels.*.name, 'covscan-ok') }}
name: Coverity Scan on PR
runs-on: ubuntu-latest
steps:
- name: Coverity Scan Marked Successful
run: echo "Dummy action to report all ok and mark covscan as handled"

on-synchronize-no-source-changes:
if: ${{ contains(github.event.action, 'synchronize') && ! contains(github.event.*.labels.*.name, 'covscan-ok') }}
name: Coverity Scan on PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check changed files
id: changed-sources
uses: tj-actions/changed-files@v44
with:
files: |
src/**
- name: Coverity Scan not needed
if: steps.changed-sources.outputs.any_changed == 'false'
run: |
echo "No Source files changed, no covscan needed"
- name: Coverity Scan is needed
if: steps.changed-sources.outputs.any_changed == 'true'
run: |
echo "Source files changed, covscan is needed"
on-synchronize-covscan-ok:
if: ${{ contains(github.event.action, 'synchronize') && contains(github.event.*.labels.*.name, 'covscan-ok') }}
name: Coverity Scan on PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check changed files
id: changed-sources
uses: tj-actions/changed-files@v44
with:
base_sha: ${{ github.event.before }}
files: |
src/**
continue-on-error: true
- name: Coverity Scan not needed
if: ${{ steps.changed-sources.outcome == 'success' && steps.changed-sources.outputs.any_changed == 'false' }}
run: echo "Dummy action to report all ok and mark covscan as handled"
- name: Coverity Scan is needed
if: ${{ steps.changed-sources.outcome == 'failure' || steps.changed-sources.outputs.any_changed == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
run: |
gh pr edit "$NUMBER" --remove-label "covscan"
false

0 comments on commit 28502df

Please sign in to comment.