Update no-important-files-changed.yml (#3644)

fix for html access for [no important files changed]
This commit is contained in:
BethanyG
2024-02-28 00:39:09 -08:00
committed by GitHub
parent 8bf0fb2d1b
commit e6be68abbb

View File

@@ -1,9 +1,16 @@
name: No important files changed name: No important files changed
on: on:
pull_request: pull_request_target:
types: [opened] types: [opened]
branches: [main] branches: [main]
paths:
- "exercises/concept/**"
- "exercises/practice/**"
- "!exercises/*/*/.meta/config.json"
- "!exercises/*/*/.meta/tests.toml"
- "!exercises/*/*/.docs/instructions.md"
- "!exercises/*/*/.docs/introduction.md"
permissions: permissions:
pull-requests: write pull-requests: write
@@ -14,50 +21,40 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }}
ref: ${{ github.head_ref }}
- name: Check if important files changed - name: Check if important files changed
id: check id: check
run: | run: |
set -exo pipefail set -exo pipefail
# fetch a ref to the main branch so we can diff against it
git remote set-branches origin main git remote set-branches origin main
git fetch --depth 1 origin main git fetch --depth 1 origin main
for changed_file in $(git diff --diff-filter=M --name-only origin/main); do git diff --diff-filter=M --name-only origin/main
if ! echo "$changed_file" | grep --quiet --extended-regexp 'exercises/(practice|concept)' ; then
continue
fi
slug="$(echo "$changed_file" | sed --regexp-extended 's#exercises/[^/]+/([^/]+)/.*#\1#' )"
path_before_slug="$(echo "$changed_file" | sed --regexp-extended "s#(.*)/$slug/.*#\\1#" )"
path_after_slug="$( echo "$changed_file" | sed --regexp-extended "s#.*/$slug/(.*)#\\1#" )"
if ! [ -f "$path_before_slug/$slug/.meta/config.json" ]; then for changed_file in $(git diff --diff-filter=M --name-only origin/main); do
slug="$(echo "${changed_file}" | sed --regexp-extended 's#exercises/[^/]+/([^/]+)/.*#\1#' )"
path_before_slug="$(echo "${changed_file}" | sed --regexp-extended "s#(.*)/${slug}/.*#\\1#" )"
path_after_slug="$( echo "${changed_file}" | sed --regexp-extended "s#.*/${slug}/(.*)#\\1#" )"
config_json_file="${path_before_slug}/${slug}/.meta/config.json"
if ! [ -f "${config_json_file}" ]; then
# cannot determine if important files changed without .meta/config.json # cannot determine if important files changed without .meta/config.json
continue continue
fi fi
# returns 0 if the filter matches, 1 otherwise changed=$(jq --arg path "${path_after_slug}" '[.files.test, .files.invalidator, .files.editor] | flatten | index($path) != null' "${config_json_file}")
# | contains($path_after_slug) echo "important_files_changed=${changed}" >> "$GITHUB_OUTPUT"
if jq --exit-status \
--arg path_after_slug "$path_after_slug" \
'[.files.test, .files.invalidator, .files.editor] | flatten | index($path_after_slug)' \
"$path_before_slug/$slug/.meta/config.json" \
> /dev/null;
then
echo "important_files_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
done done
echo "important_files_changed=false" >> "$GITHUB_OUTPUT"
- name: Suggest to add [no important files changed] - name: Suggest to add [no important files changed]
if: steps.check.outputs.important_files_changed == 'true' if: steps.check.outputs.important_files_changed == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with: with:
github-token: ${{ github.token }}
script: | script: |
const body = "This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.\n\nIf this PR does **not** affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), **please add the following to the merge-commit message** which will stops student's tests from re-running. Please copy-paste to avoid typos.\n```\n[no important files changed]\n```\n\n For more information, refer to the [documentation](https://exercism.org/docs/building/tracks#h-avoiding-triggering-unnecessary-test-runs). If you are unsure whether to add the message or not, please ping `@exercism/maintainers-admin` in a comment. Thank you!" const body = "This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.\n\nIf this PR does **not** affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), **please add the following to the merge-commit message** which will stops student's tests from re-running. Please copy-paste to avoid typos.\n```\n[no important files changed]\n```\n\n For more information, refer to the [documentation](https://exercism.org/docs/building/tracks#h-avoiding-triggering-unnecessary-test-runs). If you are unsure whether to add the message or not, please ping `@exercism/maintainers-admin` in a comment. Thank you!"
github.rest.issues.createComment({ github.rest.issues.createComment({