Skip to content

Commit 274ddce

Browse files
Merge branch 'main' into unmaintained-repo-comment
2 parents a296f56 + 20a502d commit 274ddce

6 files changed

+70
-30
lines changed

.github/workflows/check-no-important-files-changed.yml

+64-24
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,79 @@ jobs:
2020
name: No important files changed
2121
runs-on: ubuntu-22.04
2222
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
25-
with:
26-
repository: ${{ inputs.repository }}
27-
ref: ${{ inputs.ref }}
28-
2923
- name: Check if important files changed
3024
id: check
31-
run: |
32-
set -exo pipefail
25+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
26+
with:
27+
script: |
28+
const { owner, repo } = context.repo;
29+
const pull_number = context.issue.number
30+
31+
return github.rest.pulls
32+
.listFiles({ owner, repo, pull_number })
33+
.then(async ({ data: files }) => {
34+
const filenames = files
35+
.filter((file) => file.status !== "added")
36+
.map((file) => file.filename);
37+
console.log(`Files in PR: ${filenames}`);
38+
39+
// Cache the parsed exercise config file's invalidator files
40+
let exerciseInvalidatorFiles = {};
41+
42+
for (const filename of filenames) {
43+
const match =
44+
/^exercises\/(?<type>practice|concept)\/(?<slug>[^\/]+)\/(?<path>.+)$/i.exec(
45+
filename
46+
);
47+
if (match?.groups === undefined) {
48+
console.log(`${filename}: skipped (can't invalidate test results)`);
49+
return false;
50+
}
51+
52+
const { type, slug, path } = match.groups;
53+
const configFile = `exercises/${type}/${slug}/.meta/config.json`;
54+
55+
const parseInvalidatorFiles = (path) => {
56+
return github.rest.repos
57+
.getContent({ owner, repo, path })
58+
.then(({ data: { content } }) =>
59+
JSON.parse(Buffer.from(content, "base64").toString())
60+
)
61+
.then((config) => {
62+
const files = config.files;
63+
if (files === undefined) {
64+
return [];
65+
}
3366
34-
git remote set-branches origin main
35-
git fetch --depth 1 origin main
67+
return [].concat(
68+
files["invalidator"] || [],
69+
files["test"] || [],
70+
files["editor"] || []
71+
);
72+
})
73+
.catch((err) => []);
74+
};
3675
37-
git diff --diff-filter=M --name-only origin/main
76+
exerciseInvalidatorFiles[slug] ||= await parseInvalidatorFiles(
77+
configFile
78+
);
79+
const invalidatesTests = exerciseInvalidatorFiles[slug].includes(path);
3880
39-
for changed_file in $(git diff --diff-filter=M --name-only origin/main); do
40-
slug="$(echo "${changed_file}" | sed --regexp-extended 's#exercises/[^/]+/([^/]+)/.*#\1#' )"
41-
path_before_slug="$(echo "${changed_file}" | sed --regexp-extended "s#(.*)/${slug}/.*#\\1#" )"
42-
path_after_slug="$( echo "${changed_file}" | sed --regexp-extended "s#.*/${slug}/(.*)#\\1#" )"
43-
config_json_file="${path_before_slug}/${slug}/.meta/config.json"
81+
if (invalidatesTests) {
82+
console.log(`${filename}: invalidates test results`);
83+
} else {
84+
console.log(`${filename}: does not invalidate test results`);
85+
}
4486
45-
if ! [ -f "${config_json_file}" ]; then
46-
# cannot determine if important files changed without .meta/config.json
47-
continue
48-
fi
87+
return invalidatesTests;
88+
}
4989
50-
changed=$(jq --arg path "${path_after_slug}" '[.files.test, .files.invalidator, .files.editor] | flatten | index($path) != null' "${config_json_file}")
51-
echo "important_files_changed=${changed}" >> "$GITHUB_OUTPUT"
52-
done
90+
return false;
91+
})
92+
.catch((err) => false);
5393
5494
- name: Suggest to add [no important files changed]
55-
if: steps.check.outputs.important_files_changed == 'true'
95+
if: steps.check.outputs.result == 'true'
5696
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
5797
with:
5898
script: |

.github/workflows/configlet.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-22.04
2323
steps:
2424
- name: Checkout code
25-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2626

2727
- name: Fetch configlet
2828
uses: exercism/github-actions/configlet-ci@main

.github/workflows/docker-build-push-image.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
steps:
6464
- name: Checkout code
65-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
65+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
6666
with:
6767
# Never deploy from non-main branches
6868
ref: main
@@ -78,7 +78,7 @@ jobs:
7878
7979
- name: Set up Docker Buildx
8080
if: steps.dockerfile-exists.outputs.result == 'true'
81-
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
81+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349
8282

8383
- name: Login to DockerHub
8484
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567

.github/workflows/keep-alive.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3131
with:
3232
repository: exercism/${{ inputs.repository || github.event.inputs.repository }}
3333
token: ${{ secrets.pat_empty_commits }}

.github/workflows/labels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1616

1717
- name: Sync labels
1818
uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c

.github/workflows/shellcheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1616

1717
- name: Run shellcheck
1818
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38

0 commit comments

Comments
 (0)