Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Prevent "twisted trunk" and "latest deps" workflows from running on forks #15726

Merged
merged 5 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/latest_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ concurrency:
cancel-in-progress: true

jobs:
check_repo:
runs-on: ubuntu-latest
outputs:
should_run_workflow: ${{ steps.check_condition.outputs.should_run_workflow }}
steps:
- id: check_condition
run: echo "::set-output name=should_run_workflow::${{ github.repository == 'matrix-org/synapse' }}"
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved

mypy:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -47,6 +57,8 @@ jobs:
run: sed '/warn_unused_ignores = True/d' -i mypy.ini
- run: poetry run mypy
trial:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -105,6 +117,8 @@ jobs:


sytest:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest
container:
image: matrixdotorg/sytest-synapse:testing
Expand Down Expand Up @@ -156,7 +170,8 @@ jobs:


complement:
if: "${{ !failure() && !cancelled() }}"
needs: check_repo
if: "!failure() && !cancelled() && needs.check_repo.outputs.should_run_workflow == 'true'"
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -192,7 +207,7 @@ jobs:
# Open an issue if the build fails, so we know about it.
# Only do this if we're not experimenting with this action in a PR.
open-issue:
if: "failure() && github.event_name != 'push' && github.event_name != 'pull_request'"
if: "failure() && github.event_name != 'push' && github.event_name != 'pull_request' && needs.check_repo.outputs.should_run_workflow == 'true'"
needs:
# TODO: should mypy be included here? It feels more brittle than the others.
- mypy
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/twisted_trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ concurrency:
cancel-in-progress: true

jobs:
check_repo:
if: github.repository == 'matrix-org/synapse'
runs-on: ubuntu-latest
outputs:
should_run_workflow: ${{ steps.check_condition.outputs.should_run_workflow }}
steps:
- id: check_condition
run: echo "::set-output name=should_run_workflow::${{ github.repository == 'matrix-org/synapse' }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have also accomplished this without yet another job (by just putting if: github.repository == 'matrix-org/synapse' in each job), but duplicating matrix-org/synapse isn't ideal in case it needs to be changed.

This job runs for a small amount of time, and GitHub Actions usage is measured in minutes, so it uses little resources.


mypy:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest

steps:
Expand All @@ -41,6 +52,8 @@ jobs:
- run: poetry run mypy

trial:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -75,6 +88,8 @@ jobs:
|| true

sytest:
needs: check_repo
if: needs.check_repo.outputs.should_run_workflow == 'true'
runs-on: ubuntu-latest
container:
image: matrixdotorg/sytest-synapse:buster
Expand Down Expand Up @@ -119,7 +134,8 @@ jobs:
/logs/**/*.log*

complement:
if: "${{ !failure() && !cancelled() }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${{ ... }} was not necessary in the first place, so it has been removed.

needs: check_repo
if: "!failure() && !cancelled() && needs.check_repo.outputs.should_run_workflow == 'true'"
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -166,7 +182,7 @@ jobs:

# open an issue if the build fails, so we know about it.
open-issue:
if: failure()
if: failure() && needs.check_repo.outputs.should_run_workflow == 'true'
needs:
- mypy
- trial
Expand Down
1 change: 1 addition & 0 deletions changelog.d/15726.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent the `latest_deps` and `twisted_trunk` daily GitHub Actions workflows from running on forks of the codebase.