Skip to content

Commit

Permalink
🤖 Sync org-wide files to upstream repo (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
exercism-bot authored Feb 29, 2024
1 parent 24f8172 commit 008de38
Showing 1 changed file with 9 additions and 51 deletions.
60 changes: 9 additions & 51 deletions .github/workflows/no-important-files-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,17 @@ on:
paths:
- "exercises/concept/**"
- "exercises/practice/**"
- "!exercises/*/*/.meta/config.json"
- "!exercises/*/*/.meta/tests.toml"
- "!exercises/*/*/.docs/instructions.md"
- "!exercises/*/*/.docs/introduction.md"
- "!exercises/*/*/.approaches/**"
- "!exercises/*/*/.articles/**"
- "!exercises/*/*/.docs/**"
- "!exercises/*/*/.meta/**"

permissions:
pull-requests: write

jobs:
no_important_files_changed:
name: No important files changed
runs-on: ubuntu-22.04
steps:
- name: Checkout code
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
id: check
run: |
set -exo pipefail
git remote set-branches origin main
git fetch --depth 1 origin main
git diff --diff-filter=M --name-only origin/main
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
continue
fi
changed=$(jq --arg path "${path_after_slug}" '[.files.test, .files.invalidator, .files.editor] | flatten | index($path) != null' "${config_json_file}")
echo "important_files_changed=${changed}" >> "$GITHUB_OUTPUT"
done
- name: Suggest to add [no important files changed]
if: steps.check.outputs.important_files_changed == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
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!"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
pause:
uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main
with:
repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }}
ref: ${{ github.head_ref }}

0 comments on commit 008de38

Please sign in to comment.