Skip to content

Commit

Permalink
Merge pull request #214 from zivy/addPrelimPRTest
Browse files Browse the repository at this point in the history
Add test for changes of auto-generated files in a PR.
  • Loading branch information
zivy authored Aug 27, 2024
2 parents 2e26b5d + 19a3682 commit 1ab651d
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,13 @@ on:
pull_request:
branches:
- main
paths-ignore: # ignore auto-generated files, only run when source files change
- docs/contrib.md
- docs/fluorescent_probes.md
- docs/index.md
- docs/protocols.md
- docs/publications.md
- docs/reagent_resources.md
- docs/the_who.md
- docs/videos.md
- docs/data_and_software.md
# Enable manual running of workflow, so that if the validation or
# markdown generation code changes we can force execution
workflow_dispatch:

jobs:
preliminary_test: # run all pre-commit tests (see .pre-commit-config.yaml)
preliminary_test:
# run all pre-commit tests (see .pre-commit-config.yaml)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -43,10 +34,37 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pre-commit tests
- name: Run pre-commit tests
run: |
pip install pre-commit
pre-commit run --all-files
pr_preliminary_test:
# check that no auto-generated file was modified in a PR on main so just check we're dealing with a PR
# (workflow "on" event settings are all on main branch)
needs: preliminary_test
if: github.event_name == 'pull_request'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
autogenerated_docs:
- docs/contrib.md
- docs/fluorescent_probes.md
- docs/index.md
- docs/protocols.md
- docs/publications.md
- docs/reagent_resources.md
- docs/the_who.md
- docs/videos.md
- docs/data_and_software.md
- name: modified autogenerated docs # succeed if no auto-generated files modified, otherwise fail
if: steps.filter.outputs.autogenerated_docs != 'false'
run: |
echo "The pull request includes changes to auto-generated files, this is not allowed. Please modify the relevant files in the docs_in and data directories."
exit 1
validate_data:
needs: preliminary_test
runs-on: macos-latest
Expand All @@ -70,7 +88,8 @@ jobs:
validate_videos data/videos.csv .github/data_validation_configs/videos.json .zenodo.json
validate_image_resources data/image_resources.csv .github/data_validation_configs/image_resources.json docs/supporting_material
validate_reagent_resources data/reagent_resources.csv .github/data_validation_configs/reagent_resources.json .zenodo.json data/vendor_urls.csv docs/supporting_material
data_2_md: # run the data to markdown updates only when pushing to the main branch or forced execution via workflow_dispatch
data_2_md:
# run the data to markdown updates only when pushing to the main branch or forced execution via workflow_dispatch
needs: validate_data
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'}}
runs-on: macos-latest
Expand Down

0 comments on commit 1ab651d

Please sign in to comment.