Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: reviewdog filter consolidation #12293

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
123 changes: 47 additions & 76 deletions .github/workflows/reviewdog-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ 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_go: ${{ steps.changes.outputs.go }}
changed_python: ${{ steps.changes.outputs.python }}
steps:
# Need to get git on push event
- uses: actions/checkout@v2
Expand All @@ -28,42 +30,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 +56,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 @@ -95,24 +71,24 @@ jobs:
cpplint --recursive \
--filter=-build/include_subdir,-build/c++11,-build/include_what_you_use \
--linelength=120 ${{ github.workspace }} 2>&1 \
| ./reviewdog -efm="%f:%l: %m" -name="cpplint" -reporter="github-pr-check" -level="warning"
| ./reviewdog -efm="%f:%l: %m" -name="cpplint" -reporter="github-pr-review" -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_go == '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-review
workdir: src/go/

hadolint:
Expand All @@ -122,17 +98,17 @@ 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-review
# 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 +117,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-review
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-review

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-review
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-review
path: ${{ steps.py-changes.outputs.py }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
Expand All @@ -218,14 +189,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-review
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 ."