Skip to content

Commit

Permalink
ci: consolidate reviewdog linter path filter
Browse files Browse the repository at this point in the history
Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com>
  • Loading branch information
Neudrino committed Mar 25, 2022
1 parent a80aac2 commit d7b9aba
Showing 1 changed file with 50 additions and 75 deletions.
125 changes: 50 additions & 75 deletions .github/workflows/reviewdog-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ concurrency:
# github-pr-review: Adds lint as GitHub comments

jobs:
pre_job_go_determinator:
files_changed:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
changed_cpp: ${{ steps.changes.outputs.cpp }}
changed_cpp_files: ${{ steps.changes.outputs.cpp_files }}
changed_go: ${{ steps.changes.outputs.go }}
changed_go_files: ${{ steps.changes.outputs.go_files }}
changed_python: ${{ steps.changes.outputs.python }}
changed_python_files: ${{ steps.changes.outputs.python_files }}
steps:
# Need to get git on push event
- uses: actions/checkout@v2
Expand All @@ -28,42 +33,16 @@ jobs:
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/reviewdog-workflow.yml", "src/go/**"]
pre_job_c_cpp_determinator:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@v2
if: github.event_name == 'push'
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/reviewdog-workflow.yml", "lte/gateway/c/**", "orc8r/gateway/c/**"]
pre_job_python_determinator:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@v2
if: github.event_name == 'push'
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/reviewdog-workflow.yml", "lte/gateway/python/**", "orc8r/gateway/python/**"]
cpp:
- ["lte/gateway/c/**", "orc8r/gateway/c/**"]
go:
- ["src/go/**"]
python:
- ["lte/gateway/python/**", "orc8r/gateway/python/**"]
cpplint:
needs: pre_job_c_cpp_determinator
if: ${{ needs.pre_job_c_cpp_determinator.outputs.should_not_skip == 'true' }}
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_cpp == 'true' }}
##
# Cpplint aims to lint to the Google Style guide. For detailed
# rationale on each linting rule, see
Expand All @@ -80,8 +59,8 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
name: Install CPP Lint and ReviewDog
- run: |
Expand All @@ -98,21 +77,21 @@ jobs:
| ./reviewdog -efm="%f:%l: %m" -name="cpplint" -reporter="github-pr-check" -level="warning"
golangci-lint:
needs: pre_job_go_determinator
if: ${{ needs.pre_job_go_determinator.outputs.should_not_skip == 'true' }}
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_cpp == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
golangci_lint_flags: '--config=../../.golangci.yml'
reporter: github-pr-review # Comments on PR with review comments.
reporter: github-pr-check
workdir: src/go/

hadolint:
Expand All @@ -122,17 +101,18 @@ jobs:
- name: Check out code
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: hadolint
uses: reviewdog/action-hadolint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check # Default is github-pr-check
filter_mode: added
reporter: github-pr-check
# Ignore DL3005-"Do not use apt-get upgrade or dist-upgrade"
hadolint_ignore: DL3005
filter_mode: added # All added or modified lines


misspell:
name: misspell
Expand All @@ -141,73 +121,68 @@ jobs:
- name: Check out code.
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: misspell
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added # Any added or changed content.
reporter: github-pr-review # Post code review comments.
filter_mode: added
reporter: github-pr-check
locale: "US"

mypy:
needs: pre_job_python_determinator
if: ${{ needs.pre_job_python_determinator.outputs.should_not_skip == 'true' }}
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_python == 'true' }}
name: mypy
runs-on: ubuntu-latest
steps:
- name: Check out code.
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Run mypy with reviewdog
uses: tsuyoshicho/action-mypy@v3.6.0
with:
github_token: ${{ secrets.github_token }}
filter_mode: added # Any added or changed content.
reporter: github-pr-review # Post code review comments.
filter_mode: added
reporter: github-pr-check

shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added # Any added or changed content.
reporter: github-pr-check # Post code review comments. Falls back to Annotations.
filter_mode: added
reporter: github-pr-check
pattern: "*.sh" # Optional.
# Other options omitted here but possible.
# - fail_on_error
# - path
# - exclude
# - shellcheck_flags

wemake-python-styleguide:
needs: pre_job_python_determinator
if: ${{ needs.pre_job_python_determinator.outputs.should_not_skip == 'true' }}
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_python == 'true' }}
name: wemake-python-styleguide
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: wemake-python-styleguide
uses: wemake-services/wemake-python-styleguide@0.15.2
with:
reporter: 'github-pr-check'
reporter: github-pr-check
path: ${{ steps.py-changes.outputs.py }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
Expand All @@ -218,14 +193,14 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-check
level: warning
filter_mode: added # Any added or changed content.
reporter: github-pr-check # Comments on PR with review comments.
yamllint_flags: "-d .github/workflows/config/yamllint_config.yml ."

0 comments on commit d7b9aba

Please sign in to comment.