From 4844851600e6508e2da3f8fc72260ae6ab431a0f Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 27 Nov 2023 06:47:01 +1000 Subject: [PATCH 1/2] Fix external repository check --- .../cd-deploy-nodes-gcp.patch-external.yml | 8 +++--- .github/workflows/cd-deploy-nodes-gcp.yml | 4 +-- ...i-integration-tests-gcp.patch-external.yml | 27 +++++++++---------- .../workflows/ci-integration-tests-gcp.yml | 6 ++--- .github/workflows/ci-lint.yml | 5 ++-- .../ci-unit-tests-docker.patch-external.yml | 17 ++++++------ .github/workflows/ci-unit-tests-docker.yml | 2 +- .../docs-deploy-firebase.patch-external.yml | 7 +++-- .github/workflows/docs-deploy-firebase.yml | 4 +-- 9 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml b/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml index 42f1aa701e4..869d09cc55b 100644 --- a/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml +++ b/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml @@ -16,10 +16,10 @@ jobs: build: name: Build CD Docker / Build images # Only run on PRs from external repositories, skipping ZF branches and tags. - if: ${{ !contains(github.head_ref || github.ref, 'refs/heads/') && !contains(github.head_ref || github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-configuration-file: name: Test CD default Docker config file / Test default-conf in Docker @@ -28,11 +28,11 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-zebra-conf-path: name: Test CD custom Docker config file / Test custom-conf in Docker needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/cd-deploy-nodes-gcp.yml b/.github/workflows/cd-deploy-nodes-gcp.yml index d6c2f83be67..4fe6f1a67bc 100644 --- a/.github/workflows/cd-deploy-nodes-gcp.yml +++ b/.github/workflows/cd-deploy-nodes-gcp.yml @@ -117,8 +117,8 @@ jobs: build: name: Build CD Docker # Skip PRs from external repositories, let them pass, and then Mergify will check them. - # Since this workflow also runs on release tags, we need to check for them as well. - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') || contains(github.head_ref || github.ref, 'refs/tags/') }} + # This workflow also runs on release tags, the event name check will run it on releases. + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/ci-integration-tests-gcp.patch-external.yml b/.github/workflows/ci-integration-tests-gcp.patch-external.yml index 52c1ce13de0..2d0cb883de4 100644 --- a/.github/workflows/ci-integration-tests-gcp.patch-external.yml +++ b/.github/workflows/ci-integration-tests-gcp.patch-external.yml @@ -16,11 +16,10 @@ jobs: get-available-disks: name: Check if cached state disks exist for Mainnet / Check if cached state disks exist # Only run on PRs from external repositories. - # (github.ref is always a local branch, so this check will skip non-PRs as well.) - if: ${{ !contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' build: name: Build CI Docker / Build images @@ -29,74 +28,74 @@ jobs: needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-stateful-sync: name: Zebra checkpoint update / Run sync-past-checkpoint test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-update-sync: name: Zebra tip update / Run update-to-tip test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' checkpoints-mainnet: name: Generate checkpoints mainnet / Run checkpoints-mainnet test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' lightwalletd-rpc-test: name: Zebra tip JSON-RPC / Run fully-synced-rpc test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' lightwalletd-transactions-test: name: lightwalletd tip send / Run lwd-send-transactions test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' get-block-template-test: name: get block template / Run get-block-template test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' submit-block-test: name: submit block / Run submit-block test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' lightwalletd-full-sync: name: lightwalletd tip / Run lwd-full-sync test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' lightwalletd-update-sync: name: lightwalletd tip update / Run lwd-update-sync test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' lightwalletd-grpc-test: name: lightwalletd GRPC tests / Run lwd-grpc-wallet test needs: get-available-disks runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/ci-integration-tests-gcp.yml b/.github/workflows/ci-integration-tests-gcp.yml index 083f1e7c465..49aa8b2728b 100644 --- a/.github/workflows/ci-integration-tests-gcp.yml +++ b/.github/workflows/ci-integration-tests-gcp.yml @@ -113,7 +113,7 @@ jobs: get-available-disks: name: Check if cached state disks exist for ${{ inputs.network || vars.ZCASH_NETWORK }} # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: ./.github/workflows/sub-find-cached-disks.yml with: network: ${{ inputs.network || vars.ZCASH_NETWORK }} @@ -124,7 +124,7 @@ jobs: # Some outputs are ignored, because we don't run those jobs on testnet. get-available-disks-testnet: name: Check if cached state disks exist for testnet - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: ./.github/workflows/sub-find-cached-disks.yml with: network: 'Testnet' @@ -136,7 +136,7 @@ jobs: # testnet when running the image. build: name: Build CI Docker - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 19eac034727..aacfdfcc1b7 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -150,9 +150,8 @@ jobs: fail_on_error: false # This gives an error when run on PRs from external repositories, so we skip it. - name: validate-dependabot - # If this is a PR, check that the PR source is from a local branch. - # (github.ref is always a local branch, so this check always passes for non-PRs.) - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + # If this is a PR, check that the PR source is a local branch. Always runs on non-PRs. + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: marocchino/validate-dependabot@v2.1.0 codespell: diff --git a/.github/workflows/ci-unit-tests-docker.patch-external.yml b/.github/workflows/ci-unit-tests-docker.patch-external.yml index 519a8e143f9..8cf8b769cae 100644 --- a/.github/workflows/ci-unit-tests-docker.patch-external.yml +++ b/.github/workflows/ci-unit-tests-docker.patch-external.yml @@ -15,11 +15,10 @@ jobs: build: name: Build CI Docker / Build images # Only run on PRs from external repositories. - # (github.ref is always a local branch, so this check will skip non-PRs as well.) - if: ${{ !contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-all: name: Test all @@ -28,39 +27,39 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-fake-activation-heights: name: Test with fake activation heights needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-empty-sync: name: Test checkpoint sync from empty state needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-lightwalletd-integration: name: Test integration with lightwalletd needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-configuration-file: name: Test CI default Docker config file / Test default-conf in Docker needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' test-zebra-conf-path: name: Test CI custom Docker config file / Test custom-conf in Docker needs: build runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/ci-unit-tests-docker.yml b/.github/workflows/ci-unit-tests-docker.yml index 7104c482419..ee3fa9385a7 100644 --- a/.github/workflows/ci-unit-tests-docker.yml +++ b/.github/workflows/ci-unit-tests-docker.yml @@ -92,7 +92,7 @@ jobs: build: name: Build CI Docker # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/docs-deploy-firebase.patch-external.yml b/.github/workflows/docs-deploy-firebase.patch-external.yml index 3126a3f3a45..f37a9dc414a 100644 --- a/.github/workflows/docs-deploy-firebase.patch-external.yml +++ b/.github/workflows/docs-deploy-firebase.patch-external.yml @@ -15,11 +15,10 @@ jobs: build-docs-book: name: Build and Deploy Zebra Book Docs # Only run on PRs from external repositories. - # (github.ref is always a local branch, so this check will skip non-PRs as well.) - if: ${{ !contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' build-docs-internal: name: Build and Deploy Zebra Internal Docs @@ -28,4 +27,4 @@ jobs: needs: build-docs-book runs-on: ubuntu-latest steps: - - run: 'echo "No build required"' + - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/docs-deploy-firebase.yml b/.github/workflows/docs-deploy-firebase.yml index 5820a2d7c58..60cd8bf7a45 100644 --- a/.github/workflows/docs-deploy-firebase.yml +++ b/.github/workflows/docs-deploy-firebase.yml @@ -71,7 +71,7 @@ jobs: build-docs-book: name: Build and Deploy Zebra Book Docs # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} timeout-minutes: 5 runs-on: ubuntu-latest permissions: @@ -125,7 +125,7 @@ jobs: build-docs-internal: name: Build and Deploy Zebra Internal Docs - if: ${{ contains(github.head_ref || github.ref, 'refs/heads/') }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} timeout-minutes: 45 runs-on: ubuntu-latest permissions: From 9e2944f4c011168c1cebab76d234b182796e5d4f Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 27 Nov 2023 06:53:50 +1000 Subject: [PATCH 2/2] Fix json path --- .github/workflows/cd-deploy-nodes-gcp.patch-external.yml | 2 +- .github/workflows/cd-deploy-nodes-gcp.yml | 2 +- .../workflows/ci-integration-tests-gcp.patch-external.yml | 2 +- .github/workflows/ci-integration-tests-gcp.yml | 6 +++--- .github/workflows/ci-lint.yml | 2 +- .github/workflows/ci-unit-tests-docker.patch-external.yml | 2 +- .github/workflows/ci-unit-tests-docker.yml | 2 +- .github/workflows/docs-deploy-firebase.patch-external.yml | 2 +- .github/workflows/docs-deploy-firebase.yml | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml b/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml index 869d09cc55b..5c1e05a56e2 100644 --- a/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml +++ b/.github/workflows/cd-deploy-nodes-gcp.patch-external.yml @@ -16,7 +16,7 @@ jobs: build: name: Build CD Docker / Build images # Only run on PRs from external repositories, skipping ZF branches and tags. - if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/cd-deploy-nodes-gcp.yml b/.github/workflows/cd-deploy-nodes-gcp.yml index 4fe6f1a67bc..0db1af6b2bc 100644 --- a/.github/workflows/cd-deploy-nodes-gcp.yml +++ b/.github/workflows/cd-deploy-nodes-gcp.yml @@ -118,7 +118,7 @@ jobs: name: Build CD Docker # Skip PRs from external repositories, let them pass, and then Mergify will check them. # This workflow also runs on release tags, the event name check will run it on releases. - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/ci-integration-tests-gcp.patch-external.yml b/.github/workflows/ci-integration-tests-gcp.patch-external.yml index 2d0cb883de4..8d9d68ed5dd 100644 --- a/.github/workflows/ci-integration-tests-gcp.patch-external.yml +++ b/.github/workflows/ci-integration-tests-gcp.patch-external.yml @@ -16,7 +16,7 @@ jobs: get-available-disks: name: Check if cached state disks exist for Mainnet / Check if cached state disks exist # Only run on PRs from external repositories. - if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/ci-integration-tests-gcp.yml b/.github/workflows/ci-integration-tests-gcp.yml index 49aa8b2728b..902575c56a5 100644 --- a/.github/workflows/ci-integration-tests-gcp.yml +++ b/.github/workflows/ci-integration-tests-gcp.yml @@ -113,7 +113,7 @@ jobs: get-available-disks: name: Check if cached state disks exist for ${{ inputs.network || vars.ZCASH_NETWORK }} # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/sub-find-cached-disks.yml with: network: ${{ inputs.network || vars.ZCASH_NETWORK }} @@ -124,7 +124,7 @@ jobs: # Some outputs are ignored, because we don't run those jobs on testnet. get-available-disks-testnet: name: Check if cached state disks exist for testnet - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/sub-find-cached-disks.yml with: network: 'Testnet' @@ -136,7 +136,7 @@ jobs: # testnet when running the image. build: name: Build CI Docker - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index aacfdfcc1b7..3640a64db0e 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -151,7 +151,7 @@ jobs: # This gives an error when run on PRs from external repositories, so we skip it. - name: validate-dependabot # If this is a PR, check that the PR source is a local branch. Always runs on non-PRs. - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: marocchino/validate-dependabot@v2.1.0 codespell: diff --git a/.github/workflows/ci-unit-tests-docker.patch-external.yml b/.github/workflows/ci-unit-tests-docker.patch-external.yml index 8cf8b769cae..2db50e52f7a 100644 --- a/.github/workflows/ci-unit-tests-docker.patch-external.yml +++ b/.github/workflows/ci-unit-tests-docker.patch-external.yml @@ -15,7 +15,7 @@ jobs: build: name: Build CI Docker / Build images # Only run on PRs from external repositories. - if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/ci-unit-tests-docker.yml b/.github/workflows/ci-unit-tests-docker.yml index ee3fa9385a7..46b67c79fc4 100644 --- a/.github/workflows/ci-unit-tests-docker.yml +++ b/.github/workflows/ci-unit-tests-docker.yml @@ -92,7 +92,7 @@ jobs: build: name: Build CI Docker # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} uses: ./.github/workflows/sub-build-docker-image.yml with: dockerfile_path: ./docker/Dockerfile diff --git a/.github/workflows/docs-deploy-firebase.patch-external.yml b/.github/workflows/docs-deploy-firebase.patch-external.yml index f37a9dc414a..8478e4c2ded 100644 --- a/.github/workflows/docs-deploy-firebase.patch-external.yml +++ b/.github/workflows/docs-deploy-firebase.patch-external.yml @@ -15,7 +15,7 @@ jobs: build-docs-book: name: Build and Deploy Zebra Book Docs # Only run on PRs from external repositories. - if: ${{ startsWith(github.event_name, 'pull') && github.event.head.repo.fork }} + if: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - run: 'echo "Skipping job on fork"' diff --git a/.github/workflows/docs-deploy-firebase.yml b/.github/workflows/docs-deploy-firebase.yml index 60cd8bf7a45..ec274162a6b 100644 --- a/.github/workflows/docs-deploy-firebase.yml +++ b/.github/workflows/docs-deploy-firebase.yml @@ -71,7 +71,7 @@ jobs: build-docs-book: name: Build and Deploy Zebra Book Docs # Skip PRs from external repositories, let them pass, and then Mergify will check them - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} timeout-minutes: 5 runs-on: ubuntu-latest permissions: @@ -125,7 +125,7 @@ jobs: build-docs-internal: name: Build and Deploy Zebra Internal Docs - if: ${{ !startsWith(github.event_name, 'pull') || !github.event.head.repo.fork }} + if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }} timeout-minutes: 45 runs-on: ubuntu-latest permissions: