forked from sdr-enthusiasts/plane-alert-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: fix derivative check action (sdr-enthusiasts#129)
* ci: cache python and change dervative check fail condition This commit makes sure the python environment is cached. It also ensures that the derivative check action only fails when the derivative files found in the PR are different from the files that would be generated by the derivative creation pipeline. * ci: fix check derivative action
- Loading branch information
Showing
3 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -8,14 +8,14 @@ on: | |
jobs: | ||
checkDerivativesChange: | ||
runs-on: ubuntu-latest | ||
name: Post a warning to the PR when a user changes a derivative file | ||
name: Post a warning to the PR when a user incorrectly changed derivative files | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get changed files | ||
- name: Check if PR changes the derivative databases | ||
id: changed-files | ||
uses: tj-actions/changed-files@v35 | ||
uses: tj-actions/changed-files@v35.6.3 | ||
with: | ||
files: | | ||
*.csv | ||
|
@@ -24,23 +24,43 @@ jobs: | |
!plane-alert-twitter-blocked.csv | ||
!plane-alert-ukraine.csv | ||
- name: Retrieve warning message from READ_BEFORE_MAKING_CHANGES.md | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
- if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
echo "WARNING_MSG<<EOF" >> $GITHUB_ENV | ||
echo "$(cat READ_BEFORE_MAKING_CHANGES.md | tail -n +3)" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Post derivative warning | ||
- name: Post derivative databases change warning | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
${{ env.WARNING_MSG }} | ||
comment_tag: execution | ||
|
||
- name: Display test result | ||
- uses: actions/setup-python@v4 | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
with: | ||
python-version: "3.10" | ||
cache: 'pip' | ||
- if: steps.changed-files.outputs.any_changed == 'true' | ||
run: pip install -r ./scripts/requirements.txt | ||
- name: Run derivative databases creation script | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: python ./scripts/create_db_derivatives.py | ||
- name: Check if user files are equal to generated files | ||
id: changes | ||
uses: UnicornGlobal/[email protected] | ||
|
||
- name: Fail on incorrect changes | ||
if: steps.changed-files.outputs.any_changed == 'true' && steps.changes.outputs.changed == 1 | ||
run: | | ||
echo "Derivative files changed!" | ||
echo "Derivative files changed and were different from the automatic generation pipeline." | ||
exit 1 | ||
- name: Succeed on correct changes | ||
if: steps.changed-files.outputs.any_changed == 'true' && steps.changes.outputs.changed == 0 | ||
run: | | ||
echo "Derivative files changed but were in line with the automatic generation pipeline." | ||
- name: Succeed on no changes | ||
if: steps.changed-files.outputs.any_changed == 'false' | ||
run: | | ||
echo "No derivative files were changed." |
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
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