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 bc997ce
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
73 changes: 73 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 @@ -120,16 +142,26 @@ jobs:
name: 'Build docker image'
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 }}

- 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 +171,44 @@ 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:
builder: ${{ steps.buildx.outputs.name }}
files: |
./docker-compose-testnet.yml
./docker-compose-integration-tests.yml
set: |
*.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
*.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},mode=max
load: true
push: false

- name: Run integration tests
run: |
docker-compose \
-f docker-compose-testnet.yml \
-f docker-compose-integration-tests.yml \
up --exit-code-from integration-tests
6 changes: 3 additions & 3 deletions docker-compose-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ services:
condition: service_healthy
environment:
NODE_ENV: test
ALICE_BASE_URL: http://alice:${ALICE_API_PORT:-3000}/
BOB__BASE_URL: http://bob:${BOB_API_PORT:-3001}/
CHARLIE__BASE_URL: http://charlie:${CHARLIE_API_PORT:-3002}/
ALICE_BASE_URL: http://alice:${ALICE_API_PORT:-3000}
BOB__BASE_URL: http://bob:${BOB_API_PORT:-3001}
CHARLIE__BASE_URL: http://charlie:${CHARLIE_API_PORT:-3002}
AFJ_REST_LOG_LEVEL: 1
command: ['npm', 'run', 'test:integration']
networks:
Expand Down

0 comments on commit bc997ce

Please sign in to comment.