Skip to content

feat(state)!: add any-chain treestate-by-hash read requests #1286

feat(state)!: add any-chain treestate-by-hash read requests

feat(state)!: add any-chain treestate-by-hash read requests #1286

name: Trigger Integration Tests
on:
pull_request:
branches: [main]
paths:
- "**/*.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
- .cargo/config.toml
- .github/workflows/trigger-integration-tests.yml
push:
branches: [main]
paths:
- "**/*.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
- .cargo/config.toml
- .github/workflows/trigger-integration-tests.yml
workflow_dispatch:
inputs:
pr_number:
description: "PR number to run integration tests against (use for fork PRs)"
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || inputs.pr_number || github.run_id }}
cancel-in-progress: true
permissions: {}
jobs:
trigger-integration:
name: Trigger integration tests
# Fork PRs do not receive repository secrets on pull_request events.
# Skip the job on fork PRs; maintainers can still run it manually via
# workflow_dispatch with the PR number as input.
# Mergify queue candidates reuse the source PR's integration result.
if: >-
${{
(
github.event_name != 'pull_request' ||
github.event.pull_request.user.login != 'mergify[bot]' ||
github.event.pull_request.head.repo.full_name != github.repository ||
!startsWith(github.event.pull_request.head.ref, 'mergify/merge-queue/')
) &&
(
(github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) ||
(github.event_name == 'push' && github.ref_name == 'main') ||
github.event_name == 'workflow_dispatch'
)
}}
runs-on: ubuntu-latest
permissions:
# Needed to post a sticky comment on the PR when triggered manually.
pull-requests: write
steps:
- name: Resolve target PR details (manual dispatch only)
id: pr
if: github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ inputs.pr_number }}
run: |
DATA=$(gh pr view "$PR" --repo "$GITHUB_REPOSITORY" --json headRefOid,body)
SHA=$(echo "$DATA" | jq -r .headRefOid)
BODY=$(echo "$DATA" | jq -r .body)
TEST_SHA=$(echo "$BODY" | sed '/[^ ]ZIT-Revision/!d' | sed -E 's/.*ZIT-Revision: ([^\\]*)\\.*/\1/')
# PR body is contributor-controlled; only forward sha-like values.
if [[ -n "$TEST_SHA" ]] && ! [[ "$TEST_SHA" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
echo "::warning::Ignoring invalid ZIT-Revision value"
TEST_SHA=""
fi
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
echo "test_sha=$TEST_SHA" >> "$GITHUB_OUTPUT"
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.Z3_APP_ID }}
private-key: ${{ secrets.Z3_APP_PRIVATE_KEY }}
owner: zcash
repositories: integration-tests
- name: Get requested test branch, if any
if: github.event_name == 'pull_request'
id: test-branch
env:
GH_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
TEST_SHA=$(gh pr -R ZcashFoundation/zebra list --search "${HEAD_SHA}" --json body | jq '.[0].body' | sed '/[^ ]ZIT-Revision/!d' | sed -E 's/.*ZIT-Revision: ([^\\]*)\\.*/\1/')
echo "test_sha=${TEST_SHA}" >> $GITHUB_OUTPUT
- name: Trigger integration tests
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
SHA: ${{ steps.pr.outputs.sha || github.event.pull_request.head.sha || github.sha }}
TEST_SHA: ${{ steps.pr.outputs.test_sha || steps.test-branch.outputs.test_sha }}
# Stable per-source key so the integration repo can cancel a superseded
# run: the PR number for pull requests and manual dispatches, otherwise
# the branch name (e.g. `main`).
SOURCE_REF: ${{ github.event_name == 'workflow_dispatch' && format('pr-{0}', inputs.pr_number) || (github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref_name) }}
run: >
gh api repos/zcash/integration-tests/dispatches
--field event_type="zebra-interop-request"
--field client_payload[sha]="${SHA}"
--field client_payload[test_sha]="${TEST_SHA}"
--field client_payload[source_ref]="${SOURCE_REF}"
- name: Post sticky comment on PR (manual dispatch only)
if: github.event_name == 'workflow_dispatch'
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 #v3.0.4
with:
number: ${{ inputs.pr_number }}
header: integration-tests-dispatch
message: |
🚀 Integration tests dispatched manually against this PR's HEAD (`${{ steps.pr.outputs.sha }}`).
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}