Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
senekor committed Nov 24, 2023
1 parent b357983 commit 7dade05
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/no-important-files-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,38 @@ on:
permissions:
pull-requests: write

# TODO maybe use step output instead ?
# https://stackoverflow.com/questions/60589373/how-to-force-job-to-exit-in-github-actions-step
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context

jobs:
check_if_important_files_changed:
name: Check if important files changed
runs-on: ubuntu-22.04
outputs:
what: ${{ steps.check_if_important_files_changed.outputs.important_files_changed }}
steps:
- name: Check if important files changed
run: |
const body = "This PR touches files which probably affect the outcome of the tests of an exercise. If this is not the case, please add the following to the merge commit message. Copy-paste to avoid typos. This will prevent tests from rerunning unnecessarily. For more information, refer to the [documentation](https://exercism.org/docs/building/tracks#h-avoiding-triggering-unnecessary-test-runs).\n```\n[no important files changed]\n```"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
echo "important_files_changed=$important_files_changed" >> "$GITHUB_OUTPUT"
no_important_files_changed:
name: No important files changed
needs: check_if_important_files_changed
if: needs.check_if_important_files_changed.outputs.important_files_changed == 'true'
runs-on: ubuntu-22.04
steps:
- name: Suggest to add [no important files changed]
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
const body = "This PR touches the test files of an exercise. If the changes are only cosmetic, please add the following to the merge commit message. Copy-paste to avoid typos. This will prevent tests from rerunning unnecessarily. For more information, refer to the [documentation](https://exercism.org/docs/building/tracks#h-avoiding-triggering-unnecessary-test-runs).\n```\n[no important files changed]\n```"
const body = "This PR touches files which probably affect the outcome of the tests of an exercise. If this is not the case, please add the following to the merge commit message. Copy-paste to avoid typos. This will prevent tests from rerunning unnecessarily. For more information, refer to the [documentation](https://exercism.org/docs/building/tracks#h-avoiding-triggering-unnecessary-test-runs).\n```\n[no important files changed]\n```"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand Down
12 changes: 12 additions & 0 deletions bin/check_if_important_files_changed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eo pipefail

cd "$(git rev-parse --show-toplevel)"

git diff --name-only origin/main

# TODO
# - detect changed exercises based on the diff
# - check .meta/config.json for each of those exercises
# to determine if important files changed
# - output "true" if so, anything else (e.g. "false") otherwise

0 comments on commit 7dade05

Please sign in to comment.