Skip to content

Merge pull request #1049 from ubc/dependabot/pip/redis-4.4.4 #167

Merge pull request #1049 from ubc/dependabot/pip/redis-4.4.4

Merge pull request #1049 from ubc/dependabot/pip/redis-4.4.4 #167

Workflow file for this run

name: Test and Deploy
on:
push:
branches: [ 'master' ]
tags: [ '*' ]
pull_request:
branches: [ 'master' ]
workflow_dispatch:
jobs:
unit_test_backend:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop
- name: Set up MariaDB
uses: getong/[email protected]
with:
mysql database: compair
mysql root password: ''
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install -y --no-install-recommends --no-install-suggests libxmlsec1-dev libz-dev
pip install -r requirements.txt -r requirements.dev.txt
- name: Backend Unit Tests MariaDB
run: |
DATABASE_URI="mysql+pymysql://root@localhost/compair" nosetests
- name: Backend Unit Tests SQLite
run: |
DATABASE_URI="sqlite:///:memory:" nosetests
unit_test_frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: |
npm install
node_modules/gulp/bin/gulp.js
- name: Frontend Karma Tests
run: |
node_modules/karma/bin/karma start compair/static/test/config/karma.conf.js --single-run
deploy_assets:
runs-on: ubuntu-latest
needs: [ unit_test_backend, unit_test_frontend ]
# only deploy master and tagged releases
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
version: 12
- name: Install dependencies
run: |
npm install
node_modules/gulp/bin/gulp.js
- name: Generate assets
run: |
node_modules/gulp/bin/gulp.js prod
- uses: shallwefootball/s3-upload-action@master
name: Upload S3
id: S3
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: compair-assets
source_dir: compair/static/dist
destination_dir: dist
deploy_docker_image:
runs-on: ubuntu-latest
needs: [ deploy_assets ]
# only deploy master and tagged releases
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Publish to Registry
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
repository: ubcctlt/compair-app
tag_with_ref: true
- name: Trigger deploy
run: |
curl -X POST \
--fail \
-F token=${{ secrets.DEPLOYMENT_TOKEN }} \
-F ref=master \
-F "variables[app__image__tag]=${GITHUB_REF##*/}" \
-F "variables[worker__image__tag]=${GITHUB_REF##*/}" \
https://repo.code.ubc.ca/api/v4/projects/366/trigger/pipeline
# TODO: add acceptance testing (would be easier with a slight rewrite to gulp/generate_index)