Skip to content

Commit

Permalink
ci: make sure latest commit is checked out in derivative check
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Mar 18, 2023
1 parent 246a503 commit 736c450
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/check_derivatives_change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Check if the PR changes any of the derivative databases
id: changed-files
Expand All @@ -27,13 +29,6 @@ jobs:
!plane-alert-pia.csv
!plane-alert-twitter-blocked.csv
!plane-alert-ukraine.csv
separator: ","

- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
- uses: actions/setup-python@v4
if: steps.changed-files.outputs.any_changed == 'true'
Expand All @@ -49,7 +44,7 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
id: invalid_derivatives
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
run: python ./scripts/check_invalid_derivatives.py

- name: Store derivative check results as artifacts
Expand Down
14 changes: 12 additions & 2 deletions scripts/check_invalid_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
format="%(asctime)s %(levelname)-8s [%(name)s] %(message)s", level=logging.INFO
)

CHANGED_FILES = os.environ["CHANGED_FILES"]
PULL_REQUEST_NUMBER = os.environ["PULL_REQUEST_NUMBER"]
MAIN_DB_FILES = [
"plane-alert-db.csv",
"plane-alert-pia.csv",
Expand All @@ -24,7 +24,17 @@
if __name__ == "__main__":
logging.info("Getting the PR files...")
requests_session = requests.Session()
pr_files = CHANGED_FILES.split(",")
response = requests_session.get(
f"https://api.github.com/repos/sdr-enthusiasts/plane-alert-db/pulls/{PULL_REQUEST_NUMBER}/files"
)
response.raise_for_status()
pr_files = response.json()
pr_files = [
pr_file["filename"]
for pr_file in pr_files
if pr_file["filename"].endswith(".csv")
and pr_file["filename"] not in MAIN_DB_FILES
] # Filter main database files and non CSV files.
logging.info("PR files retrieved successfully.")

logging.info("Getting changed files...")
Expand Down

0 comments on commit 736c450

Please sign in to comment.