Skip to content

Commit

Permalink
ci: fix derivative check action (sdr-enthusiasts#129)
Browse files Browse the repository at this point in the history
* 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
rickstaa committed Mar 9, 2023
1 parent d898f39 commit 87e0cf4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
38 changes: 29 additions & 9 deletions .github/workflows/check_derivatives_change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."
1 change: 1 addition & 0 deletions .github/workflows/check_main_databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- run: pip install -r ./scripts/requirements.txt

- name: Run main database checks
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/create_db_derivatives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- run: pip install -r ./scripts/requirements.txt

- name: Create category, images and extended database CSV files
Expand Down

0 comments on commit 87e0cf4

Please sign in to comment.