Skip to content

Commit

Permalink
ci: convert e2e to matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jul 2, 2024
1 parent d4bec8b commit 2692d41
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 93 deletions.
113 changes: 113 additions & 0 deletions .github/actions/e2e.yml
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 *
93 changes: 0 additions & 93 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *


22 changes: 22 additions & 0 deletions .github/workflows/e2e.yml
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 }}

0 comments on commit 2692d41

Please sign in to comment.