Skip to content

Commit

Permalink
ci: add workflow to detect important file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Jul 14, 2023
1 parent c71f43d commit af9cbdf
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 79 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/configlet.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/important-files-changed.yml
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
25 changes: 0 additions & 25 deletions .github/workflows/pause-community-contributions.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/sync-labels.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/tests.yml

This file was deleted.

88 changes: 88 additions & 0 deletions test.js
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);
// }

0 comments on commit af9cbdf

Please sign in to comment.