Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

add unit & integration tests to CI & split off build step #126

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 103 additions & 4 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ on:
push:
branches:
- main
- INTRN-243-setup-ci-pipeline

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
staging-deploy:
build:
runs-on: ubuntu-latest

steps:
Expand All @@ -35,10 +36,108 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: registry.digitalocean.com/akatsuki/interns-backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
# cache-from: type=gha
# cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/interns-backend.tar

- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: interns-backend
path: /tmp/interns-backend.tar

unit-tests:
runs-on: ubuntu-latest
needs: build

steps:
- name: Check out latest commit
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download built image artifact
uses: actions/download-artifact@v3
with:
name: interns-backend
path: /tmp/

- name: Load image
run: |
docker load --input /tmp/interns-backend.tar
# docker image ls -a

- name: Run containers
run: docker-compose up -d interns-backend

- name: Run tests
run: docker-compose exec -T users-service /scripts/run-tests.sh

- name: Stop containers
if: always()
run: docker-compose down

integration-tests:
runs-on: ubuntu-latest
needs: build

steps:
- name: Check out latest commit
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download built image artifact
uses: actions/download-artifact@v3
with:
name: interns-backend
path: /tmp/

- name: Load image
run: |
docker load --input /tmp/interns-backend.tar
# docker image ls -a

- name: Run containers
run: docker-compose up -d interns-backend postgres redis

- name: Run tests
run: docker-compose exec -T users-service /scripts/run-tests.sh

- name: Stop containers
if: always()
run: docker-compose down

staging-deploy:
runs-on: ubuntu-latest
needs: [build, unit-tests, integration-tests]

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download built image artifact
uses: actions/download-artifact@v3
with:
name: interns-backend
path: /tmp/

- name: Load image
run: |
docker load --input /tmp/interns-backend.tar
# docker image ls -a

- name: Save kubeconfig from digitalocean
run: doctl k8s cluster kubeconfig save --expiry-seconds 600 akatsuki-staging
Expand Down