diff options
author | Valérianne <dashie@sigpipe.me> | 2021-03-15 13:01:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 13:01:46 +0100 |
commit | e45464e87d8ec54f74c01db4b9eb8160423cf4f5 (patch) | |
tree | 0da84e1659e8fb936d81dd90870e8b3540f23979 | |
parent | 4e52ab504484007d0c8a6963e1847dd8ce874777 (diff) | |
parent | 3ab6b36af0debd45013df5956204af41d00eb073 (diff) |
Merge pull request #383 from reel2bits/feature/github-actions
-rw-r--r-- | .circleci/config.yml | 366 | ||||
-rw-r--r-- | .github/workflows/build-and-test.yml | 191 | ||||
-rw-r--r-- | .github/workflows/build-docs.yml | 38 |
3 files changed, 229 insertions, 366 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9a276ad2..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,366 +0,0 @@ -# Python CircleCI 2.0 configuration file -# Check https://circleci.com/docs/2.0/language-python/ for more details -version: 2 - -aliases: - - &defaults - docker: - - image: circleci/python:3.6-buster-node - working_directory: ~/projects/reel2bits - - - &attach_workspace - attach_workspace: - at: ~/projects/ - - - &persist_to_workspace - persist_to_workspace: - root: ~/projects/ - paths: - - ./reel2bits/ - - ./audiowaveform/ - - - &install_system_dependencies - run: - name: Install system dependencies - command: | - sudo apt-get update - sudo apt-get install -y sox libtag1v5 libmagic1 libffi6 ffmpeg postgresql-client-11 rsync - sudo apt-get install -y cmake build-essential git wget make libboost-all-dev rustc - sudo apt-get install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev libmediainfo-dev - - - &install_audiowaveform - run: - name: Install audiowaveform - command: ./api/tests/install_audiowaveform.sh - - - &install_python_dependencies - steps: - - *attach_workspace - - *install_system_dependencies - - *install_audiowaveform - - run: python -V | tee /tmp/.python-version - - restore_cache: - keys: - - v2-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "api/requirements.txt" }} - - run: python3 -m venv venv - - run: - command: | - . venv/bin/activate - pip install --requirement api/requirements.txt - pip install black - pip install flake8 - touch front/dist/index.html - - save_cache: - key: v2-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "api/requirements.txt" }} - paths: - - ./venv - - *persist_to_workspace - - - &install_steps - steps: - - checkout - - *attach_workspace - - restore_cache: - keys: - - v1-node-dependencies-{{ checksum "front/yarn.lock" }} - - v1-node-dependencies- - - run: - command: | - cd front - yarn install --frozen-lockfile - - save_cache: - key: v1-node-depdencies-{{ checksum "front/yarn.lock" }} - paths: - - ./front/node_modules/ - - *persist_to_workspace - - - &test_steps - steps: - - *attach_workspace - - *install_system_dependencies - - *install_audiowaveform - - run: - name: Linters - command: | - . venv/bin/activate - cd api - black --check . - flake8 . --count --show-source --statistics - - run: - name: Tests - command: | - . venv/bin/activate - cd api - mkdir test-reports - export AUTHLIB_INSECURE_TRANSPORT=1 - export APP_SETTINGS="config.testing.Config" - python setup.py test - - run: - name: Full migrations - command: | - 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 - . venv/bin/activate - cd api - 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 - - store_test_results: - path: api/test-reports - - store_artifacts: - path: api/test-reports - - - &lint_steps_front - steps: - - *attach_workspace - - run: - name: Front lint - command: | - cd front - npm run lint - - - &test_steps_front - steps: - - *attach_workspace - - run: - name: Front test - command: | - firefox --version - cd front - npm run unit - - - &build_front - steps: - - *attach_workspace - - run: - name: Install rsync - command: | - sudo apt-get update - sudo apt-get install -y rsync - - run: - name: Front build - command: | - cd front - npm run build - - persist_to_workspace: - root: ~/projects/ - paths: - - ./reel2bits/front/dist - - - &sync_front - steps: - - *attach_workspace - - add_ssh_keys: - fingerprints: - - "8b:e8:75:22:8a:21:35:5a:50:1c:da:75:2f:11:6c:2b" - - "66:7c:0f:97:42:b2:eb:fe:53:3c:0a:db:a5:5c:7a:27" - - run: - name: Install rsync - command: | - sudo apt-get update - sudo apt-get install -y rsync - - deploy: - name: zip and sync artifacts - command: | - cd front - if [ "${CIRCLE_BRANCH}" = "master" ]; then - export NAME="front-dist-${CIRCLE_BRANCH}" - zip -r "${NAME}.zip" dist/ - rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" ${NAME}.zip assets.reel2bits.org@cadance.licorn.eu:/ - fi - if [ ! -z "${CIRCLE_TAG}" ]; then - export NAME="front-dist-${CIRCLE_TAG}" - zip -r "${NAME}.zip" dist/ - rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" ${NAME}.zip assets.reel2bits.org@cadance.licorn.eu:/ - fi - - - &build_and_sync_doc - steps: - - checkout - - *attach_workspace - - add_ssh_keys: - fingerprints: - - "66:80:b8:db:44:06:34:e1:f0:ac:35:b2:a0:80:98:bd" - - run: - name: Install rsync - command: | - sudo apt-get update - sudo apt-get install -y rsync graphviz - - run: - name: Install dependencies - command: | - python3 -m venv venv - . venv/bin/activate - pip install sphinx-guillotina-theme sphinx - - run: - name: Build docs - command: | - . venv/bin/activate - cd docs && ./build_docs.sh - - deploy: - name: deploy - command: | - rsync -avc -e "ssh -o StrictHostKeyChecking=no -p 22" --delete docs-build/ docs-develop.reel2bits.org@cadance.licorn.eu:/ -jobs: - install: - <<: *defaults - <<: *install_steps - - install-python3.6: - <<: *defaults - <<: *install_python_dependencies - - install-python3.7: - <<: *defaults - docker: - - image: circleci/python:3.7-buster-node - <<: *install_python_dependencies - - install-python3.8: - <<: *defaults - docker: - - image: circleci/python:3.8-buster-node - <<: *install_python_dependencies - - install-python3.9: - <<: *defaults - docker: - - image: circleci/python:3.9-rc-buster-node - <<: *install_python_dependencies - - test-python3.6: - <<: *defaults - docker: - - image: circleci/python:3.6-buster-node - - image: circleci/postgres:11-alpine - environment: - POSTGRES_USER: postgres - POSTGRES_DB: reel2bits_test - <<: *test_steps - - test-python3.7: - <<: *defaults - docker: - - image: circleci/python:3.7-buster-node - - image: circleci/postgres:11-alpine - environment: - POSTGRES_USER: postgres - POSTGRES_DB: reel2bits_test - <<: *test_steps - - test-python3.8: - <<: *defaults - docker: - - image: circleci/python:3.8-buster-node - - image: circleci/postgres:11-alpine - environment: - POSTGRES_USER: postgres - POSTGRES_DB: reel2bits_test - <<: *test_steps - - test-python3.9: - <<: *defaults - docker: - - image: circleci/python:3.9-rc-buster-node - - image: circleci/postgres:11-alpine - environment: - POSTGRES_USER: postgres - POSTGRES_DB: reel2bits_test - <<: *test_steps - - front-lint: - <<: *defaults - docker: - - image: circleci/node:12.9.0-buster-browsers - <<: *lint_steps_front - - front-lint-lts: - <<: *defaults - docker: - - image: circleci/node:10.16.3-buster-browsers - <<: *lint_steps_front - - front-test-lts: - <<: *defaults - docker: - - image: circleci/node:10.16.3-buster-browsers - <<: *test_steps_front - - front-build: - <<: *defaults - docker: - - image: circleci/node:10.16.3-buster-browsers - <<: *build_front - - front-sync: - <<: *defaults - docker: - - image: circleci/node:10.16.3-buster-browsers - <<: *sync_front - - build-develop-doc: - <<: *defaults - docker: - - image: circleci/python:3.7-buster-node - environment: - BUILD_PATH: ../docs-build - <<: *build_and_sync_doc - -workflows: - version: 2 - build-docs: - jobs: - - build-develop-doc: - filters: - branches: - only: master - build-and-test: - jobs: - - install - - install-python3.6: - requires: - - install - - install-python3.7: - requires: - - install - - install-python3.8: - requires: - - install - - install-python3.9: - requires: - - install - - test-python3.6: - requires: - - install-python3.6 - - test-python3.7: - requires: - - install-python3.7 - - test-python3.8: - requires: - - install-python3.8 - - test-python3.9: - requires: - - install-python3.9 - - front-lint-lts: - requires: - - install - - front-test-lts: - requires: - - front-lint-lts - - front-lint: - requires: - - install - - front-build: - requires: - - front-lint - - front-sync: - requires: - - front-lint-lts - - front-build - filters: - branches: - only: master 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 diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 00000000..49227eaf --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,38 @@ +name: Build documentation + +on: + push: + branches: + - master + +env: + BUILD_PATH: ../docs-build + +jobs: + build: + runs-on: ubuntu-latest + name: Build and sync latest documentation + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + apt install -y graphviz + pip3 install sphinx-guillotina-theme sphinx + - name: Build docs + run: ./build_docs.sh + working-directory: docs + - name: Deploy docs + uses: burnett01/rsync-deployments@4.1 + with: + switches: -avc --delete + path: docs-build/ + remote_path: / + remote_host: ${{ secrets.DOCS_DEPLOY_HOST }} + remote_user: ${{ secrets.DOCS_DEPLOY_USER }} + remote_key: ${{ secrets.DOCS_DEPLOY_KEY }} |