Skip to content

Commit

Permalink
[GHA] Run smoke and performance tests when appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind committed Aug 10, 2023
1 parent 3644e98 commit af67b21
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 18 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/cli-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ on:
required: true
type: string
description: Use this to override the git SHA1, branch name (e.g. devnet) or tag
SKIP_JOB:
required: false
default: false
type: boolean
description: Set to true to skip this job. Useful for PRs that don't require this workflow.

# TODO: should we migrate this to a composite action, so that we can skip it
# at the call site, and don't need to wrap each step in an if statement?
jobs:
# Run the Aptos CLI examples. We run the CLI on this commit / PR against a
# local testnet using the devnet, testnet, and mainnet branches. This way
Expand All @@ -24,10 +31,12 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v3
if: ${{ !inputs.SKIP_JOB }}
with:
ref: ${{ inputs.GIT_SHA }}

- uses: aptos-labs/aptos-core/.github/actions/docker-setup@main
if: ${{ !inputs.SKIP_JOB }}
with:
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
Expand All @@ -37,11 +46,13 @@ jobs:
GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}

- uses: ./.github/actions/python-setup
if: ${{ !inputs.SKIP_JOB }}
with:
pyproject_directory: crates/aptos/e2e

# Run CLI tests against local testnet built from devnet branch.
- uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # pin@v2
if: ${{ !inputs.SKIP_JOB }}
name: devnet-tests
with:
max_attempts: 5
Expand All @@ -50,6 +61,7 @@ jobs:

# Run CLI tests against local testnet built from testnet branch.
- uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # pin@v2
if: ${{ !inputs.SKIP_JOB }}
name: testnet-tests
with:
max_attempts: 5
Expand All @@ -58,13 +70,18 @@ jobs:

# Run CLI tests against local testnet built from mainnet branch.
- uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # pin@v2
if: ${{ !inputs.SKIP_JOB }}
name: mainnet-tests
with:
max_attempts: 5
timeout_minutes: 20
command: cd ./crates/aptos/e2e && poetry run python main.py -d --base-network mainnet --image-repo-with-project ${{ secrets.GCP_DOCKER_ARTIFACT_REPO }} --test-cli-tag ${{ inputs.GIT_SHA }} --working-directory ${{ runner.temp }}/aptos-e2e-tests-mainnet

- name: Print local testnet logs on failure
if: ${{ failure() }}
if: ${{ !inputs.SKIP_JOB && failure() }}
working-directory: docker/compose/validator-testnet
run: docker logs aptos-tools-devnet && docker logs aptos-tools-testnet && docker logs aptos-tools-mainnet

# Print out whether the job was skipped.
- run: echo "Skipping CLI E2E tests!"
if: ${{ inputs.SKIP_JOB }}
25 changes: 21 additions & 4 deletions .github/workflows/docker-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ jobs:
targetCacheId: ${{ env.TARGET_CACHE_ID }}
targetRegistry: ${{ env.TARGET_REGISTRY }}

# This job determines which files were changed
file_change_determinator:
runs-on: ubuntu-latest
outputs:
only_docs_changed: ${{ steps.determine_file_changes.outputs.only_docs_changed }}
steps:
- uses: actions/checkout@v3
- name: Run the file change determinator
id: determine_file_changes
uses: ./.github/actions/file-change-determinator

# This is a PR required job.
rust-images:
needs: [permission-check, determine-docker-build-metadata]
Expand Down Expand Up @@ -185,7 +196,7 @@ jobs:

# This is a PR required job.
node-api-compatibility-tests:
needs: [permission-check, 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, file_change_determinator] # runs with the default release docker build variant "rust-images"
if: |
(
github.event_name == 'push' ||
Expand All @@ -198,10 +209,11 @@ jobs:
secrets: inherit
with:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

# This is a PR required job.
cli-e2e-tests:
needs: [permission-check, 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, file_change_determinator] # runs with the default release docker build variant "rust-images"
if: |
(
github.event_name == 'push' ||
Expand All @@ -214,14 +226,13 @@ jobs:
secrets: inherit
with:
GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

indexer-grpc-e2e-tests:
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' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
github.event.pull_request.auto_merge != null ||
contains(github.event.pull_request.body, '#e2e')
uses: aptos-labs/aptos-core/.github/workflows/docker-indexer-grpc-test.yaml@main
secrets: inherit
Expand All @@ -238,6 +249,7 @@ jobs:
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
- file_change_determinator
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
Expand All @@ -258,6 +270,7 @@ jobs:
# test lifecycle is separate from that of GHA. This protects us from the case where many Forge tests are triggered
# by this GHA. If there is a Forge namespace collision, Forge will pre-empt the existing test running in the namespace.
FORGE_NAMESPACE: forge-e2e-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

# Run e2e compat test against testnet branch. This is a PR required job.
forge-compat-test:
Expand All @@ -269,6 +282,7 @@ jobs:
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
- file_change_determinator
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
Expand All @@ -286,6 +300,7 @@ jobs:
FORGE_RUNNER_DURATION_SECS: 300
COMMENT_HEADER: forge-compat
FORGE_NAMESPACE: forge-compat-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

# Run forge framework upgradability test. This is a PR required job.
forge-framework-upgrade-test:
Expand All @@ -297,6 +312,7 @@ jobs:
- rust-images-failpoints
- rust-images-performance
- rust-images-consensus-only-perf-test
- file_change_determinator
if: |
!failure() && !cancelled() && needs.permission-check.result == 'success' && (
(github.event_name == 'push' && github.ref_name != 'main') ||
Expand All @@ -314,6 +330,7 @@ jobs:
FORGE_RUNNER_DURATION_SECS: 300
COMMENT_HEADER: forge-framework-upgrade
FORGE_NAMESPACE: forge-framework-upgrade-${{ needs.determine-docker-build-metadata.outputs.targetCacheId }}
SKIP_JOB: ${{ needs.file_change_determinator.outputs.only_docs_changed == 'true' }}

forge-consensus-only-perf-test:
needs:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/execution-performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ name: "execution-performance"
on:
workflow_dispatch:
pull_request:
types: [labeled, opened, synchronize, reopened, auto_merge_enabled]
schedule:
- cron: "0 12 * * *" # This runs every day at 12pm UTC.

jobs:
execution-performance:
if: | # Only run on each PR once an appropriate event occurs
(
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
github.event.pull_request.auto_merge != null) ||
contains(github.event.pull_request.body, '#e2e'
)
uses: aptos-labs/aptos-core/.github/workflows/workflow-run-execution-performance.yaml@main
secrets: inherit
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/indexer-grpc-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ concurrency:

jobs:
permission-check:
if: contains(github.event.pull_request.labels.*.name, 'CICD:non-required-tests'))
runs-on: ubuntu-latest
steps:
- name: Check repository permission for user which triggered workflow
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ jobs:
# Run all rust smoke tests. This is a PR required job.
rust-smoke-tests:
needs: file_change_determinator
if: | # Only run on each PR once an appropriate event occurs
(
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
contains(github.event.pull_request.labels.*.name, 'CICD:run-e2e-tests') ||
github.event.pull_request.auto_merge != null) ||
contains(github.event.pull_request.body, '#e2e'
)
runs-on: high-perf-docker
steps:
- uses: actions/checkout@v3
Expand Down
41 changes: 32 additions & 9 deletions .github/workflows/node-api-compatibility-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ on:
required: true
type: string
description: Use this to override the git SHA1, branch name (e.g. devnet) or tag to release the SDK from
SKIP_JOB:
required: false
default: false
type: boolean
description: Set to true to skip this job. Useful for PRs that don't require this workflow.

env:
# This is the docker image tag that will be used for the SDK release.
# It is also used to pull the docker images for the CI.
IMAGE_TAG: ${{ inputs.GIT_SHA || 'devnet' }} # default to "devnet" tag when not running on workflow_call
GIT_SHA: ${{ inputs.GIT_SHA || github.event.pull_request.head.sha || github.sha }} # default to PR branch sha when not running on workflow_call

# TODO: should we migrate this to a composite action, so that we can skip it
# at the call site, and don't need to wrap each step in an if statement?
jobs:
# Confirm that the generated client within the TS SDK has been re-generated
# if there are any changes that would affect it within the PR / commit. If
Expand All @@ -42,10 +49,12 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3
if: ${{ !inputs.SKIP_JOB }}
with:
ref: ${{ env.GIT_SHA }}

- uses: aptos-labs/aptos-core/.github/actions/docker-setup@main
if: ${{ !inputs.SKIP_JOB }}
with:
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
Expand All @@ -55,49 +64,63 @@ jobs:
GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}

- uses: actions/setup-node@969bd2663942d722d85b6a8626225850c2f7be4b # pin@v3
if: ${{ !inputs.SKIP_JOB }}
with:
node-version-file: .node-version
registry-url: "https://registry.npmjs.org"

# Self hosted runners don't have pnpm preinstalled.
# https://github.com/actions/setup-node/issues/182
- uses: pnpm/action-setup@537643d491d20c2712d11533497cb47b2d0eb9d5 # pin https://github.com/pnpm/action-setup/releases/tag/v2.2.3
if: ${{ !inputs.SKIP_JOB }}

# When using high-perf-docker, the CI is actually run with two containers
# in a k8s pod, one for docker commands run in the CI steps (docker), and
# one for everything else (runner). These containers share some volume
# mounts, ${{ runner.temp }} is one of them. Writing the specs here ensures
# the docker run step writes to a same place that the runner can read from.
- run: mkdir -p ${{ runner.temp }}/specs
if: ${{ !inputs.SKIP_JOB }}

# Build the API specs.
- uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # pin@v2
if: ${{ !inputs.SKIP_JOB }}
name: generate-yaml-spec
with:
max_attempts: 3
timeout_minutes: 20
command: docker run --rm --mount=type=bind,source=${{ runner.temp }}/specs,target=/specs ${{ secrets.GCP_DOCKER_ARTIFACT_REPO }}/tools:${IMAGE_TAG} aptos-openapi-spec-generator -f yaml -o /specs/spec.yaml

- uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # pin@v2
if: ${{ !inputs.SKIP_JOB }}
name: generate-json-spec
with:
max_attempts: 3
timeout_minutes: 20
command: docker run --rm --mount=type=bind,source=${{ runner.temp }}/specs,target=/specs ${{ secrets.GCP_DOCKER_ARTIFACT_REPO }}/tools:${IMAGE_TAG} aptos-openapi-spec-generator -f json -o /specs/spec.json

# Confirm that the specs we built here are the same as those checked in.
- run: echo "If this step fails, run the following commands locally to fix it:"
- run: echo "cargo run -p aptos-openapi-spec-generator -- -f yaml -o api/doc/spec.yaml"
- run: echo "cargo run -p aptos-openapi-spec-generator -- -f json -o api/doc/spec.json"
- run: git diff --no-index --ignore-space-at-eol --ignore-blank-lines ${{ runner.temp }}/specs/spec.yaml api/doc/spec.yaml
- run: git diff --no-index --ignore-space-at-eol --ignore-blank-lines ${{ runner.temp }}/specs/spec.json api/doc/spec.json
- run: |
echo "If this step fails, run the following commands locally to fix it:"
echo "cargo run -p aptos-openapi-spec-generator -- -f yaml -o api/doc/spec.yaml"
echo "cargo run -p aptos-openapi-spec-generator -- -f json -o api/doc/spec.json"
git diff --no-index --ignore-space-at-eol --ignore-blank-lines ${{ runner.temp }}/specs/spec.yaml api/doc/spec.yaml
git diff --no-index --ignore-space-at-eol --ignore-blank-lines ${{ runner.temp }}/specs/spec.json api/doc/spec.json
if: ${{ !inputs.SKIP_JOB }}
# Run package install. If install fails, it probably means the lockfile
# was not included in the commit.
- run: cd ./ecosystem/typescript/sdk && pnpm install --frozen-lockfile
if: ${{ !inputs.SKIP_JOB }}

# Ensure any changes to the generated client were checked in.
- run: cd ./ecosystem/typescript/sdk && pnpm generate-client -o /tmp/generated_client
- run: echo "If this step fails, run the following command locally to fix it:"
- run: echo "cd ecosystem/typescript/sdk && pnpm generate-client"
- run: git diff --no-index --ignore-space-at-eol --ignore-blank-lines ./ecosystem/typescript/sdk/src/generated/ /tmp/generated_client/
- run: |
cd ./ecosystem/typescript/sdk && pnpm generate-client -o /tmp/generated_client
echo "If this step fails, run the following command locally to fix it:"
echo "cd ecosystem/typescript/sdk && pnpm generate-client"
git diff --no-index --ignore-space-at-eol --ignore-blank-lines ./ecosystem/typescript/sdk/src/generated/ /tmp/generated_client/
if: ${{ !inputs.SKIP_JOB }}
# Print out whether the job was skipped.
- run: echo "Skipping node API compatibility tests!"
if: ${{ inputs.SKIP_JOB }}
Loading

0 comments on commit af67b21

Please sign in to comment.