From f487388a6cb6c3a58bf235c0e5b736f167ccb5fc Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 27 Mar 2024 14:25:10 -0700 Subject: [PATCH 1/4] Docs typo (#225) - fix a docs typo about `pull-requests` permissions - add write permissions to token in self-test CI - improve self-test CI step that shows `*checks-failed` outputs --- .github/workflows/self-test.yml | 8 ++++++-- docs/action.yml | 4 ++-- docs/permissions.md | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index 621eaf51..55d1c8bb 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -18,6 +18,9 @@ on: jobs: test: + permissions: + issues: write + pull-requests: write strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] @@ -61,7 +64,8 @@ jobs: # if: steps.linter.outputs.checks-failed > 0 run: | echo "some linter checks failed" - echo "${{ steps.linter.outputs.checks-failed }}" - echo "${{ env.checks-failed }}" + echo "total checks-failed: ${{ steps.linter.outputs.checks-failed }}" + echo "clang-tidy checks-failed: ${{ steps.linter.outputs.clang-tidy-checks-failed }}" + echo "clang-format checks-failed: ${{ steps.linter.outputs.clang-format-checks-failed }}" # for actual deployment # run: exit 1 diff --git a/docs/action.yml b/docs/action.yml index cd3b6322..0f08bce1 100644 --- a/docs/action.yml +++ b/docs/action.yml @@ -36,10 +36,10 @@ inputs: tidy-review: experimental: true minimum-version: '2.9.0' - required-permission: 'pull_request: write #pull-request-reviews' + required-permission: 'pull-requests: write #pull-request-reviews' format-review: minimum-version: '2.9.0' - required-permission: 'pull_request: write #pull-request-reviews' + required-permission: 'pull-requests: write #pull-request-reviews' outputs: checks-failed: minimum-version: '1.2.0' diff --git a/docs/permissions.md b/docs/permissions.md index f0beb03b..202108c8 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -29,7 +29,7 @@ The [`thread-comments`](inputs-outputs.md#thread-comments) feature requires the ```yaml permissions: issues: write # (1)! - pull_requests: write # (2)! + pull-requests: write # (2)! ``` 1. for [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) @@ -41,5 +41,5 @@ The [`tidy-review`](inputs-outputs.md#tidy-review) and [`format-review`](inputs- ```yaml permissions: - pull_requests: write + pull-requests: write ``` From 18f236bba1525400681c87c139a79ead3a0df2ef Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 27 Mar 2024 21:30:17 -0700 Subject: [PATCH 2/4] Assess push permission (#226) * use `contents: write` permission to post comments on push events * update docs --- .github/workflows/self-test.yml | 4 +- docs/action.yml | 6 +-- docs/examples/index.md | 7 ++-- docs/examples/only-PR-comments.yml | 8 ++-- docs/permissions.md | 61 +++++++++++++++++++++++------- docs/stylesheets/extra.css | 22 +++++++++++ 6 files changed, 84 insertions(+), 24 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index 55d1c8bb..c7700888 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -2,7 +2,7 @@ name: Self test action on: push: - branches: main + branches: [main] paths: - 'action.yml' - 'requirements.txt' @@ -19,7 +19,7 @@ on: jobs: test: permissions: - issues: write + contents: write pull-requests: write strategy: matrix: diff --git a/docs/action.yml b/docs/action.yml index 0f08bce1..b5a5f232 100644 --- a/docs/action.yml +++ b/docs/action.yml @@ -14,15 +14,15 @@ inputs: minimum-version: '1.3.0' lines-changed-only: minimum-version: '1.5.0' - required-permission: 'content: read #file-changes' + required-permission: 'contents: read #file-changes' files-changed-only: minimum-version: '1.3.0' - required-permission: 'content: read #file-changes' + required-permission: 'contents: read #file-changes' ignore: minimum-version: '1.3.0' thread-comments: minimum-version: '2.6.2' - required-permission: 'issues: write #thread-comments' + required-permission: 'contents: write #thread-comments' no-lgtm: minimum-version: '2.6.2' step-summary: diff --git a/docs/examples/index.md b/docs/examples/index.md index 61e361fe..2191f192 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -31,6 +31,7 @@ Here are some example workflows to get started quickly. --8<-- "docs/examples/only-PR-comments.yml" ``` - 1. See also [`style`][style] - 2. See also [`tidy-checks`][tidy-checks] - 3. See also [`thread-comments`][thread-comments] + 1. See also our [token permissions document](../permissions.md) + 2. See also [`style`][style] + 3. See also [`tidy-checks`][tidy-checks] + 4. See also [`thread-comments`][thread-comments] diff --git a/docs/examples/only-PR-comments.yml b/docs/examples/only-PR-comments.yml index 1fc890b8..389248e4 100644 --- a/docs/examples/only-PR-comments.yml +++ b/docs/examples/only-PR-comments.yml @@ -10,6 +10,8 @@ on: jobs: cpp-linter: runs-on: ubuntu-latest + permissions: # (1)! + pull-requests: write steps: - uses: actions/checkout@v4 @@ -20,9 +22,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - style: 'file' # Use .clang-format config file. (1) - tidy-checks: '' # Use .clang-tidy config file. (2) - # only 'update' a single comment in a pull request's thread. (3) + style: 'file' # Use .clang-format config file. (2) + tidy-checks: '' # Use .clang-tidy config file. (3) + # only 'update' a single comment in a pull request's thread. (4) thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} - name: Fail fast?! diff --git a/docs/permissions.md b/docs/permissions.md index 202108c8..d10163f5 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -14,26 +14,61 @@ When using [`files-changed-only`](inputs-outputs.md#files-changed-only) or [`lines-changed-only`](inputs-outputs.md#lines-changed-only) to get the list of file changes for a CI event, the following permissions are needed: -```yaml - permissions: - contents: read # (1)! -``` +=== "`#!yaml on: push`" + + For [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) + + ```yaml + permissions: + contents: read # (1)! + ``` + + 1. This permission is also needed to download files if the repository is not + checked out before running cpp-linter. + +=== "`#!yaml on: pull_request`" + + For [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) + + ```yaml + permissions: + contents: read # (1)! + pull-requests: read # (2)! + ``` -1. This permission is also needed to download files if the repository is not checked out before - running cpp-linter (for both push and pull_request events). + 1. For pull requests, this permission is only needed to download files if + the repository is not checked out before running cpp-linter. + 2. Specifying `#!yaml write` is also sufficient as that is required for + + * posting [thread comments](#thread-comments) on pull requests + * posting [pull request reviews](#pull-request-reviews) ## Thread Comments The [`thread-comments`](inputs-outputs.md#thread-comments) feature requires the following permissions: -```yaml - permissions: - issues: write # (1)! - pull-requests: write # (2)! -``` +=== "`#!yaml on: push`" + + For [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) + + ```yaml + permissions: + metadata: read # (1)! + contents: write # (2)! + ``` + + 1. needed to fetch existing comments + 2. needed to post or update a commit comment. This also allows us to delete + an outdated comment if needed. + +=== "`#!yaml on: pull_request`" + + For [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) -1. for [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) -2. for [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) + ```yaml + permissions: + pull-requests: write + ``` ## Pull Request Reviews diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 6651c6f7..65f1ada6 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -204,3 +204,25 @@ th { display: block; max-height: none } + +/* annotation buttons' pulse animation */ +a.md-annotation__index { + border-radius: 2.2ch; +} + +@keyframes pulse { + 0% { + box-shadow: 0 0 0 0 var(--md-accent-fg-color); + transform: scale(.95) + } + + 75% { + box-shadow: 0 0 0 .625em transparent; + transform: scale(1) + } + + to { + box-shadow: 0 0 0 0 transparent; + transform: scale(.95) + } +} From 0061cabd91e8d8c253fab0f1b2d027cd9feaf63d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 21:31:33 -0700 Subject: [PATCH 3/4] Bump the pip group with 2 updates (#227) Bumps the pip group with 2 updates: [clang-tools](https://github.com/cpp-linter/clang-tools-pip) and [cpp-linter](https://github.com/cpp-linter/cpp-linter). Updates `clang-tools` from 0.12.0 to 0.12.1 - [Release notes](https://github.com/cpp-linter/clang-tools-pip/releases) - [Commits](https://github.com/cpp-linter/clang-tools-pip/compare/v0.12.0...v0.12.1) Updates `cpp-linter` from 1.7.4 to 1.8.1 - [Release notes](https://github.com/cpp-linter/cpp-linter/releases) - [Commits](https://github.com/cpp-linter/cpp-linter/compare/v1.7.4...v1.8.1) --- updated-dependencies: - dependency-name: clang-tools dependency-type: direct:production update-type: version-update:semver-patch dependency-group: pip - dependency-name: cpp-linter dependency-type: direct:production update-type: version-update:semver-minor dependency-group: pip ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 21db7481..de7ed9f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # Install clang-tools binaries (clang-format, clang-tidy) # For details please see: https://github.com/cpp-linter/clang-tools-pip -clang-tools==0.12.0 +clang-tools==0.12.1 # cpp-linter core Python executable package # For details please see: https://github.com/cpp-linter/cpp-linter -cpp-linter==1.7.4 +cpp-linter==1.8.1 From 065b5bae743b75e4225bafdc56bea4a55d432758 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Thu, 28 Mar 2024 12:51:49 +0700 Subject: [PATCH 4/4] Enable parallelism (#213) * feat: add --jobs parameter to action See cpp-linter/cpp-linter#92 for the related CLI updates. * adjustments for docs --------- Co-authored-by: Brendan <2bndy5@gmail.com> --- .github/workflows/self-test.yml | 7 +++++++ action.yml | 13 +++++++++++-- docs/action.yml | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index c7700888..e2b1f54f 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -15,6 +15,13 @@ on: - 'requirements.txt' - 'docs/examples/demo/**' - '.github/workflows/self-test.yml' + pull_request_target: + branches: main + paths: + - 'action.yml' + - 'requirements.txt' + - 'docs/examples/demo/**' + - '.github/workflows/self-test.yml' jobs: test: diff --git a/action.yml b/action.yml index cdd9c15b..03dfff39 100644 --- a/action.yml +++ b/action.yml @@ -191,6 +191,13 @@ inputs: > The [`no-lgtm`](#no-lgtm) option is applicable to Pull Request reviews. required: false default: false + jobs: + description: | + The number of jobs to run in parallel. + If less than or equal to 0, the number of jobs is set to + use the number of all available CPU cores. + required: false + default: 0 outputs: checks-failed: description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy and clang-format. @@ -260,7 +267,8 @@ runs: --file-annotations=${{ inputs.file-annotations }} \ --extra-arg="${{ inputs.extra-args }}" \ --tidy-review="${{ inputs.tidy-review }}" \ - --format-review="${{ inputs.format-review }}" + --format-review="${{ inputs.format-review }}" \ + --jobs=${{ inputs.jobs }} - name: Setup python venv (Windows) if: runner.os == 'Windows' @@ -295,6 +303,7 @@ runs: ' --file-annotations=${{ inputs.file-annotations }}' + ' --extra-arg="${{ inputs.extra-args }}"' + ' --tidy-review="${{ inputs.tidy-review }}"' + - ' --format-review="${{ inputs.format-review }}"' + ' --format-review="${{ inputs.format-review }}"' + + ' --jobs=${{ inputs.jobs }}' Invoke-Expression -Command $app diff --git a/docs/action.yml b/docs/action.yml index b5a5f232..40b65cd3 100644 --- a/docs/action.yml +++ b/docs/action.yml @@ -40,6 +40,8 @@ inputs: format-review: minimum-version: '2.9.0' required-permission: 'pull-requests: write #pull-request-reviews' + jobs: + minimum-version: '2.11.0' outputs: checks-failed: minimum-version: '1.2.0'