Skip to content

Commit

Permalink
Testing short circuit for docs only changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Dec 4, 2023
1 parent 56f800d commit c9dd64a
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 24 deletions.
34 changes: 34 additions & 0 deletions .github/actions/docs-only/action.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 0 additions & 21 deletions .github/actions/post-checkout/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/contextual-advice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
44 changes: 43 additions & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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.
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}}"
15 changes: 14 additions & 1 deletion .github/workflows/set-tugboat-tests-pending.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand All @@ -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 }}

0 comments on commit c9dd64a

Please sign in to comment.