diff --git a/.github/actions/docs-only/action.yml b/.github/actions/docs-only/action.yml new file mode 100644 index 000000000..a03b921a5 --- /dev/null +++ b/.github/actions/docs-only/action.yml @@ -0,0 +1,34 @@ +name: "VA.gov CMS Documentation Only PR Check" +description: "Checks if the current PR contains only documentation changes" +inputs: {} +outputs: + docs-only: + description: "'true' if the PR contains only documentation changes, otherwise 'false'" + value: ${{ steps.docs-only.outputs.result }} + +runs: + using: "composite" + steps: + + - name: Check for documentation only changes + id: docs-only + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 + with: + script: | + const opts = github.rest.pulls.listFiles.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }) + const files = await github.paginate(opts, (response) => + response.data.map((file) => file.filename)) + + for (const file of files) { + console.log(`Checking PR file: ${file}`) + if (!file.endsWith('.md')) { + return "false" + } + } + + return "true" + result-encoding: string diff --git a/.github/actions/post-checkout/action.yml b/.github/actions/post-checkout/action.yml index 56b3d2e21..6f4d8b248 100644 --- a/.github/actions/post-checkout/action.yml +++ b/.github/actions/post-checkout/action.yml @@ -5,27 +5,6 @@ runs: using: "composite" steps: - - name: Check for documentation only changes - id: docs-only - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 - with: - script: | - const opts = github.rest.pulls.listFiles.endpoint.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }) - const files = await github.paginate(opts, (response) => - response.data.map((file) => file.filename)) - for (const file of files) { - console.log(file) - if (!file.endsWith('.md')) { - return "false" - } - } - return "true" - result-encoding: string - - name: Get Composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/contextual-advice.yml b/.github/workflows/contextual-advice.yml index 5ba24c335..e82f825bb 100644 --- a/.github/workflows/contextual-advice.yml +++ b/.github/workflows/contextual-advice.yml @@ -17,7 +17,8 @@ jobs: # branch or its commits, regardless of provenance. # # Do not execute any code located within the repository! - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 06f574234..46aa6746a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -9,12 +9,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Check Corresponding Entity Reference Fields - # See also `composer va:test:check-cer` in composer.json + # See also `composer va:test:check-cer` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: ./tests/scripts/check-cer.sh - name: Check Revision Log fields # See also `composer va:test:check-node-revision-logs` in composer.json # See also `composer va:test:check-taxonomy-revision-logs` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: | ./tests/scripts/check-node-revision-logs.sh ./tests/scripts/check-taxonomy-revision-logs.sh @@ -26,7 +31,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Composer Validate + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: composer validate # Check style of ES/JS files with ESLint and ReviewDog. @@ -36,10 +45,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Post-Checkout Actions + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: ./.github/actions/post-checkout - name: ReviewDog # See also `composer va:test:eslint` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: reviewdog/action-eslint@e1dbcf30466d267e79331b2f5bacb269093125b5 # v1.19.1 with: reporter: github-pr-review @@ -53,10 +67,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Post-Checkout Actions uses: ./.github/actions/post-checkout - name: Run PHP_CodeSniffer and ReviewDog # See also `composer va:test:php_codesniffer` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: | export REVIEWDOG_GITHUB_API_TOKEN="${GITHUB_TOKEN}" bin/phpcs \ @@ -77,10 +95,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Post-Checkout Actions + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: ./.github/actions/post-checkout - name: Run PHPLint # See also `composer va:test:lint-php` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: ./tests/scripts/lint-php.sh # Analyze the codebase for programming errors with PHPStan. @@ -90,10 +113,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Post-Checkout Actions uses: ./.github/actions/post-checkout - name: Run PHPStan and ReviewDog # See also `composer va:test:phpstan` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: | export REVIEWDOG_GITHUB_API_TOKEN="${GITHUB_TOKEN}" bin/phpstan analyze \ @@ -116,10 +143,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Post-Checkout Actions + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: ./.github/actions/post-checkout - name: Run PHPUnit (Unit Tests only) # See also `composer va:test:phpunit-unit` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} run: bin/phpunit \ --group unit \ --exclude-group disabled \ @@ -133,8 +165,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Stylelint modules # See also `composer va:test:stylelint-modules` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: reviewdog/action-stylelint@e45410880466232c34ec6ab2e0fbc15f5ce3fdd2 # v1.17.1 with: fail_on_error: true @@ -145,6 +181,7 @@ jobs: stylelint_input: 'docroot/modules/custom/**/*.css' - name: Stylelint themes # See also `composer va:test:stylelint-themes` in composer.json + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: reviewdog/action-stylelint@e45410880466232c34ec6ab2e0fbc15f5ce3fdd2 # v1.17.1 with: fail_on_error: true @@ -169,11 +206,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: CodeQL Init + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4 with: languages: ${{ matrix.language }} - name: CodeQL Analyze + if: ${{ steps.docs-only.outputs.docs-only == 'false' }} uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/set-tugboat-tests-pending.yml b/.github/workflows/set-tugboat-tests-pending.yml index 04ccd2d5b..2bcd6391e 100644 --- a/.github/workflows/set-tugboat-tests-pending.yml +++ b/.github/workflows/set-tugboat-tests-pending.yml @@ -22,6 +22,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Documentation Only PR Check + uses: ./.github/actions/docs-only + id: docs-only - name: Set status for Tugboat tasks. run: | test_names=( @@ -32,13 +35,23 @@ jobs: va/tests/status-error ) for test_name in "${test_names[@]}"; do + if [ $DOCS_ONLY == "true" ]; then gh api \ --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/${GITHUB_REPOSITORY}/statuses/${SHA}" \ - -f state='pending' \ + -f state='success' \ -f context="${test_name}"; + else + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/statuses/${SHA}" \ + -f state='pending' \ + -f context="${test_name}"; + fi done; env: SHA: ${{ github.event.pull_request.head.sha }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCS_ONLY: ${{ steps.docs-only.outputs.docs-only }}