Bump MAGIC_CASTLE_VERSION to 12.6.7 #660
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' }} | |
MAGIC_CASTLE_VERSION: 12.6.7 | |
jobs: | |
frontend: | |
runs-on: ubuntu-22.04 | |
name: Test frontend | |
steps: | |
- uses: actions/checkout@v3 | |
- 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@v3 | |
- 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') | |
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: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- 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: Fetch Magic Castle Source and patch acme url | |
working-directory: ./run | |
run: | | |
curl -L -O https://github.com/ComputeCanada/magic_castle/releases/download/${MAGIC_CASTLE_VERSION}/magic_castle-openstack-${MAGIC_CASTLE_VERSION}.tar.gz | |
tar xvf magic_castle-openstack-${MAGIC_CASTLE_VERSION}.tar.gz | |
mv magic_castle-openstack-${MAGIC_CASTLE_VERSION} magic_castle | |
sed -i 's;https://acme-v02.api.letsencrypt.org/directory;https://acme-staging-v02.api.letsencrypt.org/directory;g' magic_castle/dns/acme/main.tf | |
- name: Run backend regular tests | |
if: ${{ !(env.RUN_LIVE_CLUSTER_TESTS == 'true') }} | |
working-directory: ./run | |
run: | | |
export MAGIC_CASTLE_PATH=$PWD/magic_castle | |
venv/bin/python -m pytest ../ | |
- name: Run backend extended tests (including live cluster tests) | |
if: ${{ env.RUN_LIVE_CLUSTER_TESTS == 'true' }} | |
working-directory: ./run | |
env: | |
OS_AUTH_URL: ${{ secrets.OS_AUTH_URL }} | |
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} | |
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} | |
run: | | |
export MAGIC_CASTLE_PATH=$PWD/magic_castle | |
venv/bin/python -m pytest -x -vv --build-live-cluster ../; | |
container: | |
runs-on: ubuntu-22.04 | |
name: Build container | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 }} |