-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Reusable E2E Testing Workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
runs_on: | ||
description: 'The type of runner to run on (e.g., ubuntu-22.04)' | ||
type: string | ||
default: 'ubuntu-22.04' | ||
make_target: | ||
description: 'Makefile target to execute in the Start Test step' | ||
required: true | ||
type: string | ||
timeout_minutes: | ||
description: 'The maximum number of minutes the job can run' | ||
type: number | ||
default: 25 | ||
run: | ||
description: 'Whether to run the job or not' | ||
required: true | ||
type: boolean | ||
|
||
jobs: | ||
e2e-test: | ||
runs-on: ${{ inputs.runs_on }} | ||
if: ${{ run }} | ||
timeout-minutes: ${{ inputs.timeout_minutes }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# configure docker to use the containerd snapshotter | ||
# so that we can use the buildkit cache | ||
- uses: depot/use-containerd-snapshotter-action@v1 | ||
|
||
- name: Login to Docker Hub registry | ||
uses: docker/login-action@v2 | ||
if: (github.event_name == 'push' && github.repository == 'zeta-chain/node') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'zeta-chain/node') | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_READ_ONLY }} | ||
|
||
- name: Login to github docker registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Restore go cache | ||
uses: actions/cache@v4 | ||
id: restore-go-cache | ||
with: | ||
path: | | ||
go-cache | ||
key: cache-${{ hashFiles('go.sum') }} | ||
lookup-only: ${{ github.event_name != 'push' }} | ||
|
||
- name: Inject go cache into docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-map: | | ||
{ | ||
"go-cache": "/root/.cache/go-build" | ||
} | ||
skip-extraction: ${{ steps.restore-go-cache.outputs.cache-hit || github.event_name != 'push' }} | ||
|
||
# build zetanode with cache options | ||
- name: Build zetanode for cache | ||
uses: docker/build-push-action@v6 | ||
env: | ||
CACHE_FROM_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache" | ||
CACHE_TO_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max" | ||
with: | ||
context: . | ||
file: ./Dockerfile-localnet | ||
push: false | ||
tags: zetanode:latest | ||
cache-from: ${{ env.CACHE_FROM_CONFIG }} | ||
cache-to: ${{ github.event_name == 'push' && env.CACHE_TO_CONFIG || '' }} | ||
target: latest-runtime | ||
|
||
- name: Start Test | ||
run: make ${{ inputs.make_target }} | ||
|
||
# use docker logs -f rather than docker attach to make sure we get the initial logs | ||
- name: Watch Test | ||
run: | | ||
container_id=$(docker ps --filter "ancestor=orchestrator:latest" --format "{{.ID}}") | ||
docker logs -f "${container_id}" & | ||
exit $(docker wait "${container_id}") | ||
- name: Full Log Dump On Failure | ||
if: failure() | ||
run: | | ||
make stop-localnet | ||
- name: Notify Slack on Failure | ||
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/develop' | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
status: ${{ job.status }} | ||
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CI_ALERTS }} | ||
|
||
- name: Stop Private Network | ||
if: always() | ||
run: | | ||
make stop-localnet | ||
- name: Clean Up Workspace | ||
if: always() | ||
shell: bash | ||
run: sudo rm -rf * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,96 +100,3 @@ jobs: | |
if: always() | ||
shell: bash | ||
run: rm -rf * | ||
|
||
e2e-test: | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 25 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# configure docker to use the containerd snapshotter | ||
# so that we can use the buildkit cache | ||
- uses: depot/use-containerd-snapshotter-action@v1 | ||
|
||
- name: Login to Docker Hub registry | ||
uses: docker/login-action@v2 | ||
if: (github.event_name == 'push' && github.repository == 'zeta-chain/node') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'zeta-chain/node') | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_READ_ONLY }} | ||
|
||
- name: Login to github docker registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Restore go cache | ||
uses: actions/cache@v4 | ||
id: restore-go-cache | ||
with: | ||
path: | | ||
go-cache | ||
key: cache-${{ hashFiles('go.sum') }} | ||
lookup-only: ${{ github.event_name != 'push' }} | ||
|
||
- name: Inject go cache into docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-map: | | ||
{ | ||
"go-cache": "/root/.cache/go-build" | ||
} | ||
skip-extraction: ${{ steps.restore-go-cache.outputs.cache-hit || github.event_name != 'push' }} | ||
|
||
# build zetanode with cache options | ||
- name: Build zetanode for cache | ||
uses: docker/build-push-action@v6 | ||
env: | ||
CACHE_FROM_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache" | ||
CACHE_TO_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max" | ||
with: | ||
context: . | ||
file: ./Dockerfile-localnet | ||
push: false | ||
tags: zetanode:latest | ||
cache-from: ${{ env.CACHE_FROM_CONFIG }} | ||
cache-to: ${{ github.event_name == 'push' && env.CACHE_TO_CONFIG || '' }} | ||
target: latest-runtime | ||
|
||
- name: Start Test | ||
run: make start-e2e-test | ||
|
||
# use docker logs -f rather than docker attach to make sure we get the initial logs | ||
- name: Watch Test | ||
run: | | ||
container_id=$(docker ps --filter "ancestor=orchestrator:latest" --format "{{.ID}}") | ||
docker logs -f "${container_id}" & | ||
exit $(docker wait "${container_id}") | ||
- name: Full Log Dump On Failure | ||
if: failure() | ||
run: | | ||
make stop-localnet | ||
- name: Notify Slack on Failure | ||
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/develop' | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
status: ${{ job.status }} | ||
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CI_ALERTS }} | ||
|
||
- name: Stop Private Network | ||
if: always() | ||
run: | | ||
make stop-localnet | ||
- name: Clean Up Workspace | ||
if: always() | ||
shell: bash | ||
run: sudo rm -rf * | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: e2e | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
e2e: | ||
strategy: | ||
matrix: | ||
include: | ||
- make_target: "start-e2e-test" | ||
run: true | ||
- make_target: "start-upgrade-test-light" | ||
run: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'MINIMAL_CI') }} | ||
uses: ./.github/actions/e2e.yml | ||
with: | ||
make_target: ${{ matrix.make_target }} |