summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build-and-test.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/build-and-test.yml')
-rw-r--r--.github/workflows/build-and-test.yml191
1 files changed, 191 insertions, 0 deletions
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
new file mode 100644
index 00000000..4f8f4526
--- /dev/null
+++ b/.github/workflows/build-and-test.yml
@@ -0,0 +1,191 @@
+name: Test builds
+
+on: push
+
+jobs:
+ test-frontend:
+ name: Test build frontend
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ node: [12.x, 14.x, 15.x]
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Uses Node.JS ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node }}
+ - name: Cache Node.js modules
+ uses: actions/cache@v2
+ with:
+ # npm cache files are stored in `~/.npm` on Linux/macOS
+ path: ~/.npm
+ key: ${{ runner.OS }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.OS }}-node-${{ matrix.node-version }}
+ ${{ runner.OS }}-node-
+ ${{ runner.OS }}-
+
+ - name: Install dependencies
+ run: |
+ yarn install --frozen-lockfile
+ sudo apt update
+ sudo apt install -y firefox
+ working-directory: front
+
+ - name: Lint code
+ run: npm run lint
+ working-directory: front
+
+ # might need firefox...
+ - name: Test front
+ run: npm run unit
+ working-directory: front
+
+ - name: Test build front
+ run: npm run build
+ working-directory: front
+
+ sync-frontend:
+ name: Sync frontend release
+ runs-on: ubuntu-latest
+
+ needs: test-frontend
+ if: github.ref == 'refs/heads/master' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Uses Node.JS 14.x
+ uses: actions/setup-node@v1
+ with:
+ node-version: 14.x
+ - name: Cache Node.js modules
+ uses: actions/cache@v2
+ with:
+ # npm cache files are stored in `~/.npm` on Linux/macOS
+ path: ~/.npm
+ key: ${{ runner.OS }}-node-14.x-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.OS }}-node-14.x
+ ${{ runner.OS }}-node-
+ ${{ runner.OS }}-
+
+ - name: Install dependencies
+ run: |
+ yarn install --frozen-lockfile
+ working-directory: front
+
+ - name: Build front
+ run: npm run build
+ working-directory: front
+
+ - name: Archive build (tag)
+ run: |
+ export NAME="front-dist-${{ github.event.release.tag_name }}"
+ zip -r "${NAME}.zip" dist/
+ working-directory: front
+ if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
+
+ - name: Archive build (master)
+ run: |
+ export NAME="front-dist-master"
+ zip -r "${NAME}.zip" dist/
+ working-directory: front
+ if: github.ref == 'refs/heads/master'
+
+ - name: Deploy front
+ uses: burnett01/rsync-deployments@4.1
+ with:
+ switches: -avc
+ path: front-dist-*.zip
+ remote_path: /
+ remote_host: ${{ secrets.ASSETS_DEPLOY_HOST }}
+ remote_user: ${{ secrets.ASSETS_DEPLOY_USER }}
+ remote_key: ${{ secrets.ASSETS_DEPLOY_KEY }}
+
+ backend:
+ name: Test build backend
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ python: [3.6, 3.7, 3.8, 3.9]
+
+ services:
+ postgres:
+ image: postgres:12
+ env:
+ POSTGRES_DB: reel2bits_test
+ POSTGRES_USER: postgres
+ POSTGRES_HOST_AUTH_METHOD: trust
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 5432:5432
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Uses Python ${{ matrix.python }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python }}
+ - name: Cache pip
+ uses: actions/cache@v2
+ with:
+ # This path is specific to Ubuntu
+ path: ~/.cache/pip
+ # Look to see if there is a cache hit for the corresponding requirements file
+ key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-${{ matrix.python }}
+ ${{ runner.os }}-pip-
+ ${{ runner.os }}-
+
+ - name: Install system dependencies
+ run: |
+ sudo add-apt-repository -y ppa:chris-needham/ppa
+ sudo apt update
+ sudo apt install -y sox libtag1v5 libmagic1 libffi7 ffmpeg postgresql-client-12 rsync
+ sudo apt install -y cmake build-essential git wget make libboost-all-dev rustc cargo
+ sudo apt install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev libmediainfo-dev audiowaveform
+
+ - name: Install python dependencies
+ run: |
+ pip install --requirement api/requirements.txt
+ pip install black
+ pip install flake8
+ touch front/dist/index.html
+
+ - name: Lint code
+ run: |
+ black --check .
+ flake8 . --count --show-source --statistics
+ working-directory: api
+
+ - name: Test backend
+ run: python setup.py test
+ working-directory: api
+ env:
+ AUTHLIB_INSECURE_TRANSPORT: 1
+ APP_SETTINGS: "config.testing.Config"
+
+ - name: Test full migrations
+ run: |
+ psql -U postgres -h localhost -w -c 'CREATE DATABASE reel2bits'
+ psql -U postgres -h localhost -w -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' reel2bits
+ flask db upgrade
+ flask db-datas 000-seeds
+ flask db-datas 001-generate-tracks-uuids
+ flask db-datas 002-set-local-users
+ flask db-datas 003-set-user-quota
+ flask db-datas 004-update-file-sizes
+ flask db-datas 005-update-user-quotas
+ working-directory: api