Skip to content

Commit

Permalink
add integration tests to github action
Browse files Browse the repository at this point in the history
  • Loading branch information
msterle committed Jan 5, 2024
1 parent 550fcec commit 582e782
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
push:
branches-ignore: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# Make sure we're not running multiple release steps at the same time as this can give issues with determining the next npm version to release.
# Ideally we only add this to the 'release' job so it doesn't limit PR runs, but github can't guarantee the job order in that case:
# "When concurrency is specified at the job level, order is not guaranteed for jobs or runs that queue within 5 minutes of each other."
Expand All @@ -24,6 +28,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get repository identifiers
id: repo_ids
run: |
Expand All @@ -39,9 +44,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Cache Node.js modules
uses: actions/cache@v3
with:
Expand All @@ -50,8 +57,10 @@ jobs:
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm install # maybe this should be changed to npm ci

- name: Lint
run: npm run lint

Expand All @@ -60,9 +69,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Cache Node.js modules
uses: actions/cache@v3
with:
Expand All @@ -71,8 +82,10 @@ jobs:
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm install # maybe this should be changed to npm ci

- name: Dependency Check
run: npm run depcheck

Expand All @@ -81,9 +94,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Cache Node.js modules
uses: actions/cache@v3
with:
Expand All @@ -92,10 +107,13 @@ jobs:
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm install # maybe this should be changed to npm ci

- name: Build the TypeScript OpenAPI with tsoa
run: npm run build

- name: Run tests
run: npm run test

Expand All @@ -104,13 +122,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- run: git fetch --depth=1 --tags origin

- name: Install yq
run: sudo snap install yq

- name: Check Build Version
id: get_version
run: ./scripts/check-version.sh
shell: bash

- name: Error if version is not increased
shell: bash
run: |
Expand All @@ -121,15 +143,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: '--debug'

- name: Build image
uses: docker/build-push-action@v4
with:
Expand All @@ -139,3 +164,43 @@ jobs:
# The arm64 img is added only in release ( arm ETA build-time is ~1h )
platforms: linux/amd64
push: false
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},mode=max

integration-tests:
name: 'Run integration tests'
runs-on: ubuntu-latest
steps:
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: '--debug'

- uses: actions/checkout@v3

- name: Build testnet and integration images
uses: docker/bake-action@v4
with:
files: |
./docker-compose-testnet.yml
./docker-compose-integration-tests.yml
load: true
set: |
*.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
*.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},mode=max
push: false

- name: Run integration tests
run: |
docker-compose \
-f docker-compose-testnet.yml \
-f docker-compose-integration-tests.yml \
up --build --exit-code-from integration-tests

0 comments on commit 582e782

Please sign in to comment.