Skip to content

Commit

Permalink
ci: run clang-tidy for all files on main branch or if config changes (#…
Browse files Browse the repository at this point in the history
…149)

* ci: run clang-tidy on every file of main branch

* ci: run clang-tidy on every file if config changes by PR

* ci: allow other keywords for skipping test/lint

[skip test]
  • Loading branch information
jnooree authored Oct 17, 2023
1 parent fc47ce2 commit 9d6e338
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/_check-want-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ name: Check commit message for skipping test

on:
workflow_call:
inputs:
keyword:
type: string
default: "test"
outputs:
want-test:
value: ${{ jobs.check-want-test.outputs.want-test }}
Expand Down Expand Up @@ -41,4 +45,4 @@ jobs:
- name: Set output
id: check-want-test
run: |
echo "want-test=${{ !contains(steps.get-commit-msg.outputs.commit-msg, '[skip test]') && !contains(steps.get-commit-msg.outputs.commit-msg, '[test skip]') }}" >> $GITHUB_OUTPUT
echo "want-test=${{ !contains(steps.get-commit-msg.outputs.commit-msg, format('[skip {0}]', inputs.keyword)) && !contains(steps.get-commit-msg.outputs.commit-msg, format('[{0} skip]', inputs.keyword)) }}" >> $GITHUB_OUTPUT
5 changes: 5 additions & 0 deletions .github/workflows/_run-clang-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ name: Run clang tools

on:
workflow_call:
inputs:
files-changed-only:
type: boolean
default: true

defaults:
run:
Expand Down Expand Up @@ -42,6 +46,7 @@ jobs:
tidy-checks: ""
database: build
ignore: ".github|build|third-party|test"
files-changed-only: ${{ inputs.files-changed-only }}
env:
GITHUB_TOKEN: ${{ github.token }}

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
needs: [check-want-test]
if: ${{ needs.check-want-test.outputs.want-test == 'true' }}
uses: ./.github/workflows/_run-clang-tools.yaml
with:
files-changed-only: false

test-and-coverage:
needs: [check-want-test]
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Project nurikit - Copyright 2023 SNU Compbio Lab.
# SPDX-License-Identifier: Apache-2.0
#

name: Lint PR

on:
pull_request:
branches:
- main
paths:
- ".github/workflows/pr-lint.yaml"
- ".github/workflows/_run-clang-tools.yaml"
- "**.clang-*"
types:
- opened
- reopened
- synchronize
- ready_for_review

defaults:
run:
shell: bash

jobs:
check-want-test:
if: ${{ !github.event.pull_request.draft }}
uses: ./.github/workflows/_check-want-test.yaml
with:
keyword: "lint"

run-clang-tools:
needs: [check-want-test]
if: ${{ needs.check-want-test.outputs.want-test == 'true' }}
uses: ./.github/workflows/_run-clang-tools.yaml
with:
files-changed-only: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
3 changes: 1 addition & 2 deletions .github/workflows/pr-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ on:
paths:
- ".github/workflows/pr-test.yaml"
- ".github/workflows/_cpp-test-and-coverage.yaml"
- ".github/workflows/_run-clang-tools.yaml"
- "cmake/**"
- "include/**"
- "scripts/check_coverage.sh"
- "src/**"
- "test/**"
- "third-party/**"
- ".clang-*"
- "CMakeLists.txt"
- "!**.clang*"
types:
- opened
- reopened
Expand Down

0 comments on commit 9d6e338

Please sign in to comment.