Update changelog #671
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, test and deploy | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
force_build_live_cluster: | |
description: "Force live cluster test (yes/no)" | |
required: true | |
default: "no" | |
env: | |
IMAGE_NAME: "cmdntrf/mc-hub" | |
RUN_LIVE_CLUSTER_TESTS: ${{ (github.event.inputs.force_build_live_cluster == 'yes' || startsWith(github.ref, 'refs/tags/v')) && 'true' || 'false' }} | |
jobs: | |
frontend: | |
runs-on: ubuntu-22.04 | |
name: Test frontend | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install NPM dependencies | |
run: (cd frontend && npm ci) | |
- name: Run frontend unit tests | |
run: (cd frontend && npm run test:unit) | |
backend: | |
runs-on: ubuntu-22.04 | |
name: Test backend | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Create run folder | |
run: | | |
mkdir -p run | |
mkdir -p run/database | |
mkdir -p run/clusters | |
- name: Decrypt secret files | |
run: | | |
FILE_NAMES=('configuration.json' 'gcloud-key.json' 'clouds.yaml') | |
for file_name in "${FILE_NAMES[@]}" | |
do | |
gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPTION_PASSPHRASE" \ | |
--output "./run/$file_name" "./.github/secrets/$file_name.gpg" | |
done | |
env: | |
DECRYPTION_PASSPHRASE: ${{ secrets.DECRYPTION_PASSPHRASE }} | |
- name: Create virtualenv | |
working-directory: ./run | |
run: | | |
python3 -m venv venv | |
venv/bin/pip install --upgrade pip | |
venv/bin/pip install poetry | |
VIRTUAL_ENV=$PWD/venv venv/bin/poetry install | |
- name: Run backend regular tests | |
if: ${{ !(env.RUN_LIVE_CLUSTER_TESTS == 'true') }} | |
working-directory: ./run | |
run: | | |
export OS_CLIENT_CONFIG_FILE=$PWD/clouds.yaml | |
venv/bin/python -m pytest ../ | |
- name: Run backend extended tests (including live cluster tests) | |
if: ${{ env.RUN_LIVE_CLUSTER_TESTS == 'true' }} | |
working-directory: ./run | |
run: | | |
export OS_CLIENT_CONFIG_FILE=$PWD/clouds.yaml | |
venv/bin/python -m pytest -x -vv --build-live-cluster ../; | |
- name: Display log on failure | |
if: ${{ failure() }} | |
working-directory: ./run | |
run: | | |
cat clusters/*/terraform_plan.log | |
cat clusters/*/terraform_apply.log | |
container: | |
runs-on: ubuntu-22.04 | |
name: Build container | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Docker image | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: docker build --tag "$IMAGE_NAME" --target production-server . | |
- name: Deploy to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:latest" | |
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:$(git describe --tags --abbrev=0)" | |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
docker push "${IMAGE_NAME}:latest" && docker push "${IMAGE_NAME}:$(git describe --tags --abbrev=0)" | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |