Mixonomer/.github/workflows/ci.yml

207 lines
5.8 KiB
YAML
Raw Normal View History

name: test and deploy
on: [push]
2021-02-07 18:32:07 +00:00
jobs:
build:
strategy:
fail-fast: false
matrix:
2022-07-28 07:00:27 +01:00
python-version: ['3.10']
poetry-version: [1.1.14]
node: [18]
os: [ubuntu-latest]
2021-02-07 18:32:07 +00:00
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3 # get source
2021-02-07 18:32:07 +00:00
# PYTHON
- name: Install Python ${{ matrix.python-version }}
2021-02-07 18:32:07 +00:00
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# PYTHON dependency management
- name: Install Poetry ${{ matrix.poetry-version }}
2021-02-07 18:32:07 +00:00
uses: abatilo/actions-poetry@v2.1.0
with:
poetry-version: ${{ matrix.poetry-version }}
# PYTHON install dependencies
- name: Install Python Dependencies
2021-02-07 18:32:07 +00:00
run: poetry install
# PYTHON for authentication when testing
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0.7.3
2021-02-07 20:40:59 +00:00
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
export_environment_variables: true
create_credentials_file: true
2021-02-07 20:40:59 +00:00
# PYTHON run unit tests
- name: Run Python Tests
2021-02-07 20:40:59 +00:00
run: poetry run python -m unittest discover -s tests
# JS setup for testing
- name: Install Node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
2021-02-07 18:32:07 +00:00
# JS install from lock.json
- name: Install Node Packages
run: npm ci
# JS build for checking errors
- name: Compile Front-end
run: npm run build --if-present
# JS tests
# - name: Run JavaScript Tests
# run: npm test
2021-02-07 18:32:07 +00:00
2022-08-26 19:28:17 +01:00
documentation:
runs-on: ubuntu-latest
needs: build # for ignoring bad builds
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3 # get source
2022-07-28 07:00:27 +01:00
2022-08-26 19:28:17 +01:00
# PYTHON
- name: Install Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
# PYTHON for dependency export only, not installing
- name: Install Poetry 1.1.14
uses: abatilo/actions-poetry@v2.1.0
with:
poetry-version: 1.1.14
2022-07-28 07:00:27 +01:00
2022-08-26 19:28:17 +01:00
# PYTHON install dependencies
- name: Install Python Dependencies
run: poetry install
2022-07-28 07:00:27 +01:00
# # JS setup for jsdoc
# - name: Install Node 18
# uses: actions/setup-node@v2
# with:
# node-version: 18
# # JS setup for jsdoc
# - name: Install jsdoc
# run: npm install jsdoc
# # JS setup for jsdoc
# - name: Add node_modules/.bin to PATH
# run: echo "${GITHUB_WORKSPACE}/node_modules/.bin" >> $GITHUB_PATH
2022-08-26 19:28:17 +01:00
# DEPLOY for setting up cloud API
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0.7.3
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
export_environment_variables: true
create_credentials_file: true
2022-07-28 07:00:27 +01:00
2022-08-26 19:28:17 +01:00
- name: Generate Documentation
run: poetry run sphinx-build docs public -b html
2022-07-28 07:00:27 +01:00
2022-08-26 19:28:17 +01:00
- name: Write CNAME
run: echo docs.mixonomer.sarsoo.xyz > ./public/CNAME
- name: Deploy To Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
2021-03-23 22:26:59 +00:00
2021-02-07 20:40:59 +00:00
deploy:
runs-on: ubuntu-latest
needs: build # for ignoring bad builds
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
2021-02-07 20:40:59 +00:00
steps:
- uses: actions/checkout@v3 # get source
2021-02-07 20:40:59 +00:00
2022-07-28 07:57:27 +01:00
# PYTHON (pinned to 3.9 for gcloud attribute mapping error)
- name: Install Python 3.9
2021-02-07 20:40:59 +00:00
uses: actions/setup-python@v2
with:
2022-07-28 07:57:27 +01:00
python-version: '3.9'
# PYTHON for dependency export only, not installing
- name: Install Poetry 1.1.14
uses: abatilo/actions-poetry@v2.1.0
with:
poetry-version: 1.1.14
# PYTHON Export Poetry dependencies as requirements.txt
- name: Export Poetry Dependencies
run: python admin.py pydepend
2021-02-07 20:40:59 +00:00
# JS setup
- name: Install Node 18
2021-02-07 20:40:59 +00:00
uses: actions/setup-node@v2
with:
node-version: 18
2021-02-07 20:40:59 +00:00
# JS install from lock.json
- name: Install Node Packages
run: npm ci
# JS will be built again, for flagging errors
- name: Compile Front-end
run: npm run build --if-present
# JS for compiling scss
- name: Compile Sass
uses: gha-utilities/sass-build@v0.3.5
with:
source: src/scss/style.scss
destination: build/style.css
# DEPLOY for setting up cloud API
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0.7.3
2021-02-07 18:32:07 +00:00
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
export_environment_variables: true
create_credentials_file: true
2021-02-07 18:32:07 +00:00
# DEPLOY set project
- name: Set GCP Project
run: python admin.py set_project
2022-08-09 08:02:50 +01:00
# DEPLOY domain routes
- name: Deploy dispatch.yaml
run: gcloud app deploy dispatch.yaml --quiet
# DEPLOY app engine service, -nb for skipping compile
- name: Deploy App Engine Service
run: python admin.py app -nb
### MAIN FUNCTIONS
# DEPLOY update_tag function
- name: Deploy update_tag Function
run: python admin.py tag
# DEPLOY run_user_playlist function
- name: Deploy run_user_playlist Function
run: python admin.py playlist
### CRON FUNCTIONS
# DEPLOY run_all_playlists function
- name: Deploy run_all_playlists Function
run: python admin.py playlist_cron
# DEPLOY run_all_playlist_stats function
- name: Deploy run_all_playlist_stats Function
run: python admin.py playlist_stats_cron
2021-02-07 20:40:59 +00:00
# DEPLOY run_all_tags function
- name: Deploy run_all_tags Function
2022-03-24 10:14:44 +00:00
run: python admin.py tags_cron