Skip to content

Commit

Permalink
Run tests for Nest.js project in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Jul 28, 2023
1 parent 5234506 commit b3efa2b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 27 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and upload image

on:
on:
workflow_call:

jobs:
Expand All @@ -23,3 +23,23 @@ jobs:
with:
name: hybridilusmu
path: /tmp/hybridilusmu.tar

build-nest:
name: Build and upload image (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v4
with:
context: app-nest
tags: hybridilusmu-nest
outputs: type=docker,dest=/tmp/hybridilusmu-nest.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp/hybridilusmu-nest.tar
75 changes: 50 additions & 25 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,53 @@ jobs:
- name: Stop containers
if: always()
run: npm stop
# FIXME: Enable these once integration tests exit cleanly.
# integration-tests:
# name: Integration tests
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: hybridilusmu
# path: /tmp
# - name: Load image
# run: |
# docker load --input /tmp/hybridilusmu.tar
# docker image ls -a
# - name: Start containers
# run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu
# - name: Run integration tests
# run: npm run test:integration
# - name: Stop containers
# run: npm stop

unit-tests-nest:
name: Unit tests (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp
- name: Load image
run: |
docker load --input /tmp/hybridilusmu-nest.tar
docker image ls -a
- name: Start containers
run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu-nest
- name: Run unit tests
run: docker exec -t lusmu-nest npm test
- name: Stop containers
if: always()
run: npm stop

integration-tests-nest:
name: Integration tests (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp
- name: Load image
run: |
docker load --input /tmp/hybridilusmu-nest.tar
docker image ls -a
- name: Start containers
run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu-nest
- name: Run integration tests
run: npm run test:integration
- name: Stop containers
if: always()
run: npm stop
5 changes: 4 additions & 1 deletion compose-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
services:
lusmu:
image: hybridilusmu-ci
image: hybridilusmu

lusmu-nest:
image: hybridilusmu-nest

0 comments on commit b3efa2b

Please sign in to comment.