From 9c8214b7385a44e037c172a76d65af5b0a3aff6a Mon Sep 17 00:00:00 2001 From: Justin Hiemstra <75916364+jhiemstrawisc@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:34:36 -0500 Subject: [PATCH] Add linter test (#4) * Add linter test * Update linter.yml to not reference scitokens This was linter code I originally wrote for scitokens, and I didn't catch the reference to scitokens when I was adding it to lotman --- .github/workflows/linter.yml | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..97c4cb7 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,63 @@ +name: Lint + +# Linter Action documentation at https://github.com/marketplace/actions/lint-action + +# One thing to note is that this action is currently configured automatically fix and re-push the linted code to the repo on a pull request. +# Because the github token used for authenticating this commit comes from the upstream repo (ie pelicanplatform/lotman), those linter changes will not be pushed +# to the fork that is providing the pull request. A manual git fetch will have to be run by the fork after the PR is merged to update the fork to the linted code. +# The linter does not have authorization to lint any code in the repo's .github/workflows/ directory. + +# If the linter fails, the PR can still be completed, but none of the linter changes will be made. + +on: + # push: # Can specify more circumstances under which to run the linter. + # branches: # Not specifying input to "branches:" causes the action to run on push for all branches. + push: + branches: + - main + # Trigger the workflow on pull request, + # but only for master + pull_request_target: + branches: + - main + +permissions: + checks: write + contents: read + pull-requests: write + +jobs: + run-linters: + name: Run linters + runs-on: ubuntu-latest + + steps: + - name: Check out repository (push) + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v3 + + - name: Check out repository (pull_request_target) + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Install ClangFormat + run: sudo apt-get install -y clang-format + + - name: Run linters + uses: wearerequired/lint-action@v2 + with: + github_token: ${{ secrets.github_token }} # For providing the commit authorization for the auto_fix feature + clang_format: true + clang_format_auto_fix: true + auto_fix: true + commit: false + continue_on_error: false + git_email: github.event.commits[0].author.name # Uses the author's git email instead of the default git email associated with the action ("lint-action@samuelmeuli.com") + clang_format_args: -style=file # Any additional arguments for clang_format + + - name: suggester / lint + uses: reviewdog/action-suggester@v1 + with: + tool_name: lint