|
1 | 1 | name: No important files changed
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - pull_request: |
| 4 | + pull_request_target: |
5 | 5 | types: [opened]
|
6 | 6 | branches: [main]
|
| 7 | + paths: |
| 8 | + - "exercises/concept/**" |
| 9 | + - "exercises/practice/**" |
| 10 | + - "!exercises/*/*/.approaches/**" |
| 11 | + - "!exercises/*/*/.articles/**" |
| 12 | + - "!exercises/*/*/.docs/**" |
| 13 | + - "!exercises/*/*/.meta/**" |
7 | 14 |
|
8 | 15 | permissions:
|
9 | 16 | pull-requests: write
|
10 | 17 |
|
11 | 18 | jobs:
|
12 |
| - no_important_files_changed: |
13 |
| - name: No important files changed |
14 |
| - runs-on: ubuntu-22.04 |
15 |
| - steps: |
16 |
| - - name: Checkout code |
17 |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
18 |
| - |
19 |
| - - name: Check if important files changed |
20 |
| - id: check |
21 |
| - run: | |
22 |
| - set -exo pipefail |
23 |
| -
|
24 |
| - # fetch a ref to the main branch so we can diff against it |
25 |
| - git remote set-branches origin main |
26 |
| - git fetch --depth 1 origin main |
27 |
| -
|
28 |
| - for changed_file in $(git diff --diff-filter=M --name-only origin/main); do |
29 |
| - if ! echo "$changed_file" | grep --quiet --extended-regexp 'exercises/(practice|concept)' ; then |
30 |
| - continue |
31 |
| - fi |
32 |
| - slug="$(echo "$changed_file" | sed --regexp-extended 's#exercises/[^/]+/([^/]+)/.*#\1#' )" |
33 |
| - path_before_slug="$(echo "$changed_file" | sed --regexp-extended "s#(.*)/$slug/.*#\\1#" )" |
34 |
| - path_after_slug="$( echo "$changed_file" | sed --regexp-extended "s#.*/$slug/(.*)#\\1#" )" |
35 |
| -
|
36 |
| - if ! [ -f "$path_before_slug/$slug/.meta/config.json" ]; then |
37 |
| - # cannot determine if important files changed without .meta/config.json |
38 |
| - continue |
39 |
| - fi |
40 |
| -
|
41 |
| - # returns 0 if the filter matches, 1 otherwise |
42 |
| - # | contains($path_after_slug) |
43 |
| - if jq --exit-status \ |
44 |
| - --arg path_after_slug "$path_after_slug" \ |
45 |
| - '[.files.test, .files.invalidator, .files.editor] | flatten | index($path_after_slug)' \ |
46 |
| - "$path_before_slug/$slug/.meta/config.json" \ |
47 |
| - > /dev/null; |
48 |
| - then |
49 |
| - echo "important_files_changed=true" >> "$GITHUB_OUTPUT" |
50 |
| - exit 0 |
51 |
| - fi |
52 |
| - done |
53 |
| -
|
54 |
| - echo "important_files_changed=false" >> "$GITHUB_OUTPUT" |
55 |
| -
|
56 |
| - - name: Suggest to add [no important files changed] |
57 |
| - if: steps.check.outputs.important_files_changed == 'true' |
58 |
| - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea |
59 |
| - with: |
60 |
| - github-token: ${{ github.token }} |
61 |
| - script: | |
62 |
| - 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!" |
63 |
| - github.rest.issues.createComment({ |
64 |
| - issue_number: context.issue.number, |
65 |
| - owner: context.repo.owner, |
66 |
| - repo: context.repo.repo, |
67 |
| - body: body |
68 |
| - }) |
| 19 | + pause: |
| 20 | + uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main |
| 21 | + with: |
| 22 | + repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} |
| 23 | + ref: ${{ github.head_ref }} |
0 commit comments