Commit accf0905 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

build: block promotion on Test (#6898)

parent ef5065de
...@@ -14,6 +14,21 @@ jobs: ...@@ -14,6 +14,21 @@ jobs:
environment: environment:
name: push/staging name: push/staging
steps: steps:
- name: Check test status
uses: actions/github-script@v6.4.1
with:
script: |
const statuses = await github.rest.repos.listCommitStatusesForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.head_commit.sha
})
const status = statuses.data.find(status => status.context === 'Test / promotion')?.state || 'missing'
core.info('Status: ' + status)
if (status !== 'success') {
core.setFailed('"Test / promotion" must be successful before pushing')
}
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with: with:
token: ${{ secrets.RELEASE_SERVICE_ACCESS_TOKEN }} token: ${{ secrets.RELEASE_SERVICE_ACCESS_TOKEN }}
......
...@@ -169,6 +169,7 @@ jobs: ...@@ -169,6 +169,7 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
pre: pre:
if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v6.4.1 - uses: actions/github-script@v6.4.1
...@@ -177,7 +178,7 @@ jobs: ...@@ -177,7 +178,7 @@ jobs:
github.rest.repos.createCommitStatus({ github.rest.repos.createCommitStatus({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
sha: context.payload.pull_request.head.sha || context.payload.head_commit.sha, sha: context.payload.head_commit.sha,
state: 'pending', state: 'pending',
context: 'Test / promotion', context: 'Test / promotion',
description: 'Running tests...', description: 'Running tests...',
...@@ -185,7 +186,7 @@ jobs: ...@@ -185,7 +186,7 @@ jobs:
}) })
post: post:
if: always() if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}
needs: [pre, lint, typecheck, deps-tests, unit-tests, cypress-test-matrix] needs: [pre, lint, typecheck, deps-tests, unit-tests, cypress-test-matrix]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
...@@ -195,7 +196,7 @@ jobs: ...@@ -195,7 +196,7 @@ jobs:
github.rest.repos.createCommitStatus({ github.rest.repos.createCommitStatus({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
sha: context.payload.pull_request.head.sha || context.payload.head_commit.sha, sha: context.payload.head_commit.sha,
state: ${{ env.STATUS }} ? 'success' : 'failure', state: ${{ env.STATUS }} ? 'success' : 'failure',
context: 'Test / promotion', context: 'Test / promotion',
description: ${{ env.STATUS }} ? 'All tests passed' : 'One or more tests failed and are blocking promotion', description: ${{ env.STATUS }} ? 'All tests passed' : 'One or more tests failed and are blocking promotion',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment