Skip to content

Commit

Permalink
🤖 Sync org-wide files to upstream repo
Browse files Browse the repository at this point in the history
  • Loading branch information
exercism-bot committed Feb 2, 2024
1 parent 983c835 commit 00c7c6a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/no-important-files-changed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: No important files changed

on:
pull_request:
types: [opened]
branches: [main]

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 # v4.1.1

- name: Check if important files changed
id: check
run: |
set -exo pipefail
# fetch a ref to the main branch so we can diff against it
git remote set-branches origin main
git fetch --depth 1 origin main
for changed_file in $(git diff --diff-filter=M --name-only origin/main); do
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
# cannot determine if important files changed without .meta/config.json
continue
fi
# returns 0 if the filter matches, 1 otherwise
# | contains($path_after_slug)
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
echo "important_files_changed=false" >> "$GITHUB_OUTPUT"
- name: Suggest to add [no important files changed]
if: steps.check.outputs.important_files_changed == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
github-token: ${{ github.token }}
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
})
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ This policy was initially adopted from the Front-end London Slack community and
A version history can be seen on [GitHub](https://github.com/exercism/website-copy/edit/main/pages/code_of_conduct.md).

_This policy is a "living" document, and subject to refinement and expansion in the future.
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Slack, Twitter, email) and any other Exercism entity or event._
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Discord, Forum, Twitter, email) and any other Exercism entity or event._
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Exercism
Copyright (c) 2021 Exercism

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.

0 comments on commit 00c7c6a

Please sign in to comment.