-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflow to detect important file changes
- Loading branch information
1 parent
c71f43d
commit af9cbdf
Showing
6 changed files
with
100 additions
and
79 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Important files changed | ||
on: | ||
pull_request: | ||
types: [synchronize] | ||
|
||
jobs: | ||
check_important_files_changes: | ||
name: Check if any important files changed | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check files changes | ||
runs: ruby .github/bin/check-important-files-changed.rb |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const files = [ | ||
{ filename: ".github/workflows/test.yml" }, | ||
{ filename: "exercises/practice/anagram/.docs/instructions.md" }, | ||
{ filename: "exercises/practice/bob/.meta/config.json" }, | ||
{ filename: "exercises/practice/hello-world/hello-world.coffee" }, | ||
{ filename: "exercises/practice/hexadecimal/hexadecimal.spec.coffee" }, | ||
{ filename: "exercises/practice/binary/helper.coffee" }, | ||
{ filename: "exercises/practice/accumulate/.docs/instructions.md" }, | ||
{ filename: "exercises/practice/accumulate/accumulate.coffee" }, | ||
{ filename: "exercises/practice/accumulate/accumulate.spec.coffee" }, | ||
]; | ||
|
||
const exerciseFiles = files.reduce((exerciseFiles, file) => { | ||
const m = file.filename.match( | ||
/^exercises\/(concept|practice)\/(?<slug>[^\/]+)\/(?<filename>.+)$/ | ||
); | ||
|
||
if (m == null) return exerciseFiles; | ||
|
||
const files = exerciseFiles.get(m.groups.slug) || []; | ||
files.push(m.groups.filename); | ||
|
||
exerciseFiles.set(m.groups.slug, files); | ||
return exerciseFiles; | ||
}, new Map()); | ||
|
||
configs = { | ||
bob: { | ||
files: { | ||
solution: ["bob.coffee"], | ||
test: ["bob.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
}, | ||
}, | ||
anagram: { | ||
files: { | ||
solution: ["anagram.coffee"], | ||
test: ["anagram.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
}, | ||
}, | ||
"hello-world": { | ||
files: { | ||
solution: ["hello-world.coffee"], | ||
test: ["hello-world.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
}, | ||
}, | ||
hexadecimal: { | ||
files: { | ||
solution: ["hexadecimal.coffee"], | ||
test: ["hexadecimal.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
}, | ||
}, | ||
binary: { | ||
files: { | ||
solution: ["hexadecimal.coffee"], | ||
test: ["hexadecimal.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
invalidator: ["helper.coffee"], | ||
}, | ||
}, | ||
accumulate: { | ||
files: { | ||
solution: ["accumulate.coffee"], | ||
test: ["accumulate.spec.coffee"], | ||
example: [".meta/example.coffee"], | ||
}, | ||
}, | ||
}; | ||
const x = Array.from(exerciseFiles.entries(), ([exercise, files]) => { | ||
const exerciseConfig = configs[exercise]; | ||
return files.filter( | ||
(file) => | ||
exerciseConfig.files.test.includes(file) || | ||
exerciseConfig.files.editor?.includes(file) || | ||
exerciseConfig.files.invalidator?.includes(file) | ||
); | ||
}) | ||
.flat() | ||
.sort(); | ||
|
||
console.log(x); | ||
// for (const [exercise, files] of exerciseFiles) { | ||
|
||
// console.log(exercise, importantFiles); | ||
// } |