diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 62e4a82..aab4666 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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