Skip to content

Commit

Permalink
fix trigger condition for build jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
sionescu committed Jun 5, 2023
1 parent 8e93e65 commit eb8d430
Showing 1 changed file with 43 additions and 65 deletions.
108 changes: 43 additions & 65 deletions .github/workflows/docker-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ env:
# We use `pr-<pr_number>` as cache-id for PRs and simply <branch_name> otherwise.
TARGET_CACHE_ID: ${{ github.event.number && format('pr-{0}', github.event.number) || github.ref_name }}

# On PRs, only build and push to GCP
# On push, build and push to all remote registries
TARGET_REGISTRY: ${{ github.event_name == 'pull_request_target' && 'gcp' || 'remote' }}

permissions:
contents: read
id-token: write #required for GCP Workload Identity federation which we use to login into Google Artifact Registry
Expand Down Expand Up @@ -103,11 +99,9 @@ jobs:
run: |
echo "GIT_SHA: ${GIT_SHA}"
echo "TARGET_CACHE_ID: ${TARGET_CACHE_ID}"
echo "TARGET_REGISTRY: ${TARGET_REGISTRY}"
outputs:
gitSha: ${{ env.GIT_SHA }}
targetCacheId: ${{ env.TARGET_CACHE_ID }}
targetRegistry: ${{ env.TARGET_REGISTRY }}

rust-images:
needs: [permission-check, determine-docker-build-metadata]
Expand All @@ -118,7 +112,6 @@ jobs:
TARGET_CACHE_ID: ${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
PROFILE: release
BUILD_ADDL_TESTING_IMAGES: true
TARGET_REGISTRY: ${{ needs.determine-docker-build-metadata.outputs.targetRegistry }}

rust-images-indexer:
needs: [permission-check, determine-docker-build-metadata]
Expand All @@ -134,7 +127,6 @@ jobs:
PROFILE: release
FEATURES: indexer
BUILD_ADDL_TESTING_IMAGES: true
TARGET_REGISTRY: ${{ needs.determine-docker-build-metadata.outputs.targetRegistry }}

rust-images-failpoints:
needs: [permission-check, determine-docker-build-metadata]
Expand All @@ -150,7 +142,6 @@ jobs:
PROFILE: release
FEATURES: failpoints
BUILD_ADDL_TESTING_IMAGES: true
TARGET_REGISTRY: ${{ needs.determine-docker-build-metadata.outputs.targetRegistry }}

rust-images-performance:
needs: [permission-check, determine-docker-build-metadata]
Expand All @@ -165,7 +156,6 @@ jobs:
TARGET_CACHE_ID: ${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
PROFILE: performance
BUILD_ADDL_TESTING_IMAGES: true
TARGET_REGISTRY: ${{ needs.determine-docker-build-metadata.outputs.targetRegistry }}

rust-images-consensus-only-perf-test:
needs: [permission-check, determine-docker-build-metadata]
Expand All @@ -180,45 +170,9 @@ jobs:
PROFILE: release
FEATURES: consensus-only-perf-test
BUILD_ADDL_TESTING_IMAGES: true
TARGET_REGISTRY: ${{ needs.determine-docker-build-metadata.outputs.targetRegistry }}

rust-images-all:
needs:
[
determine-docker-build-metadata,
rust-images,
rust-images-indexer,
rust-images-failpoints,
rust-images-performance,
rust-images-consensus-only-perf-test,
]
if: always() # this ensures that the job will run even if the previous jobs were skipped
runs-on: ubuntu-latest
steps:
- name: fail if rust-images job failed
if: ${{ needs.rust-images.result == 'failure' }}
run: exit 1
- name: fail if rust-images-indexer job failed
if: ${{ needs.rust-images-indexer.result == 'failure' }}
run: exit 1
- name: fail if rust-images-failpoints job failed
if: ${{ needs.rust-images-failpoints.result == 'failure' }}
run: exit 1
- name: fail if rust-images-performance job failed
if: ${{ needs.rust-images-performance.result == 'failure' }}
run: exit 1
- name: fail if rust-images-consensus-only-perf-test job failed
if: ${{ needs.rust-images-consensus-only-perf-test.result == 'failure' }}
run: exit 1
outputs:
rustImagesResult: ${{ needs.rust-images.result }}
rustImagesIndexerResult: ${{ needs.rust-images-indexer.result }}
rustImagesFailpointsResult: ${{ needs.rust-images-failpoints.result }}
rustImagesPerformanceResult: ${{ needs.rust-images-performance.result }}
rustImagesConsensusOnlyPerfTestResult: ${{ needs.rust-images-consensus-only-perf-test.result }}

sdk-release:
needs: [rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
needs: [permission-check, rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
if: |
(github.event_name == 'push' && github.ref_name != 'main') ||
github.event_name == 'workflow_dispatch' ||
Expand All @@ -231,7 +185,7 @@ jobs:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}

cli-e2e-tests:
needs: [rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
needs: [permission-check, rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
if: |
!contains(github.event.pull_request.labels.*.name, 'CICD:skip-sdk-integration-test') && (
github.event_name == 'push' ||
Expand All @@ -246,7 +200,7 @@ jobs:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}

indexer-grpc-e2e-tests:
needs: [rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
needs: [permission-check, rust-images, determine-docker-build-metadata] # runs with the default release docker build variant "rust-images"
if: |
(github.event_name == 'push' && github.ref_name != 'main') ||
github.event_name == 'workflow_dispatch' ||
Expand All @@ -259,10 +213,16 @@ jobs:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}

forge-e2e-test:
needs: [rust-images-all, determine-docker-build-metadata]
if:
| # always() ensures that the job will run even if some of the previous docker variant build jobs were skipped https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
always() && needs.rust-images-all.result == 'success' && (
needs:
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-indexer
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
Expand All @@ -284,10 +244,16 @@ jobs:

# Run e2e compat test against testnet branch
forge-compat-test:
needs: [rust-images-all, determine-docker-build-metadata]
if:
| # always() ensures that the job will run even if some of the previous docker variant build jobs were skipped https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
always() && needs.rust-images-all.result == 'success' && (
needs:
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-indexer
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
Expand All @@ -306,10 +272,16 @@ jobs:

# Run forge framework upgradability test
forge-framework-upgrade-test:
needs: [rust-images-all, determine-docker-build-metadata]
if:
| # always() ensures that the job will run even if some of the previous docker variant build jobs were skipped https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
always() && needs.rust-images-all.result == 'success' && (
needs:
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-indexer
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
Expand All @@ -327,10 +299,16 @@ jobs:
FORGE_NAMESPACE: forge-framework-upgrade-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}

forge-consensus-only-perf-test:
needs: [rust-images-all, determine-docker-build-metadata]
if:
| # always() ensures that the job will run even if some of the previous docker variant build jobs were skipped https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
always() && needs.rust-images-all.result == 'success' &&
needs:
- permission-check
- determine-docker-build-metadata
- rust-images
- rust-images-indexer
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' &&
contains(github.event.pull_request.labels.*.name, 'CICD:run-consensus-only-perf-test')
uses: aptos-labs/aptos-core/.github/workflows/workflow-run-forge.yaml@main
secrets: inherit
Expand Down

0 comments on commit eb8d430

Please sign in to comment.