2021-02-07 22:02:28 +00:00
|
|
|
name: test and deploy
|
2022-02-20 12:12:32 +00:00
|
|
|
on: [push]
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2023-09-05 20:05:58 +01:00
|
|
|
env:
|
|
|
|
python-version: '3.11'
|
2024-07-20 11:35:49 +01:00
|
|
|
poetry-version: 1.8.3
|
2024-07-20 12:32:28 +01:00
|
|
|
node-version: 22.5.1
|
2023-09-05 20:05:58 +01:00
|
|
|
|
2021-02-07 18:32:07 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2023-09-05 20:05:58 +01:00
|
|
|
runs-on: ubuntu-latest
|
2023-09-08 17:48:50 +01:00
|
|
|
name: Build & Unit Test
|
2021-02-07 18:32:07 +00:00
|
|
|
steps:
|
2024-07-20 11:35:49 +01:00
|
|
|
- uses: actions/checkout@v4 # get source
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# PYTHON
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Python ${{ env.python-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-02-07 18:32:07 +00:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
python-version: ${{ env.python-version }}
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# PYTHON dependency management
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Poetry ${{ env.poetry-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: abatilo/actions-poetry@v2.1.6
|
2021-02-07 18:32:07 +00:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
poetry-version: ${{ env.poetry-version }}
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# PYTHON install dependencies
|
|
|
|
- name: Install Python Dependencies
|
2021-02-07 18:32:07 +00:00
|
|
|
run: poetry install
|
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# PYTHON for authentication when testing
|
|
|
|
- name: Set up Cloud SDK
|
2022-07-26 22:17:39 +01:00
|
|
|
uses: google-github-actions/auth@v0.7.3
|
2021-02-07 20:40:59 +00:00
|
|
|
with:
|
2022-07-26 22:17:39 +01:00
|
|
|
credentials_json: '${{ secrets.GCP_SA_KEY }}'
|
|
|
|
export_environment_variables: true
|
|
|
|
create_credentials_file: true
|
2021-02-07 20:40:59 +00:00
|
|
|
|
2021-02-07 22:02:28 +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
|
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# JS setup for testing
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Node ${{ env.node-version }}
|
2021-02-16 22:51:13 +00:00
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
node-version: ${{ env.node-version }}
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# JS install from lock.json
|
2021-02-16 22:51:13 +00:00
|
|
|
- name: Install Node Packages
|
|
|
|
run: npm ci
|
2021-02-07 22:02:28 +00:00
|
|
|
|
2021-02-16 22:51:13 +00:00
|
|
|
# JS build for checking errors
|
|
|
|
- name: Compile Front-end
|
2024-07-20 11:49:47 +01:00
|
|
|
run: npm run build
|
2021-02-16 22:51:13 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# JS tests
|
|
|
|
# - name: Run JavaScript Tests
|
|
|
|
# run: npm test
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2023-09-08 17:48:50 +01:00
|
|
|
deploytest:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Deploy Test
|
|
|
|
environment:
|
|
|
|
name: test
|
|
|
|
url: https://test.mixonomer.sarsoo.xyz
|
|
|
|
needs: build # for ignoring bad builds
|
2023-10-13 20:30:39 +01:00
|
|
|
if: github.event_name == 'push'
|
2023-09-08 17:48:50 +01:00
|
|
|
steps:
|
2024-07-20 11:35:49 +01:00
|
|
|
- uses: actions/checkout@v4 # get source
|
2023-09-08 17:48:50 +01:00
|
|
|
|
|
|
|
# PYTHON (pinned to 3.9 for gcloud attribute mapping error)
|
|
|
|
- name: Install Python ${{ env.python-version }}
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.python-version }}
|
|
|
|
|
|
|
|
# PYTHON for dependency export only, not installing
|
|
|
|
- name: Install Poetry ${{ env.poetry-version }}
|
|
|
|
uses: abatilo/actions-poetry@v2.1.6
|
|
|
|
with:
|
|
|
|
poetry-version: ${{ env.poetry-version }}
|
|
|
|
|
|
|
|
# PYTHON Export Poetry dependencies as requirements.txt
|
|
|
|
- name: Export Poetry Dependencies
|
|
|
|
run: python admin.py pydepend
|
|
|
|
|
|
|
|
# JS setup
|
|
|
|
- name: Install Node ${{ env.node-version }}
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: ${{ env.node-version }}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
with:
|
|
|
|
credentials_json: '${{ secrets.GCP_SA_KEY }}'
|
|
|
|
export_environment_variables: true
|
|
|
|
create_credentials_file: true
|
|
|
|
|
|
|
|
# DEPLOY set project
|
|
|
|
- name: Set GCP Project
|
|
|
|
run: python admin.py set_project ${{ vars.GCP_PROJECT }}
|
|
|
|
|
2023-09-08 18:12:00 +01:00
|
|
|
# DEPLOY app engine service, -nb for skipping compile
|
|
|
|
- name: Deploy App Engine Service
|
|
|
|
run: python admin.py app -nb
|
|
|
|
|
2023-09-08 17:48:50 +01:00
|
|
|
- name: Set Test Dispatch Rules
|
|
|
|
run: |
|
|
|
|
cp dispatch.test.yaml dispatch.yaml
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
# DEPLOY domain routes
|
|
|
|
- name: Deploy dispatch.yaml
|
|
|
|
run: gcloud app deploy dispatch.yaml --quiet
|
|
|
|
|
|
|
|
### MAIN FUNCTIONS
|
|
|
|
|
|
|
|
# DEPLOY update_tag function
|
|
|
|
- name: Deploy update_tag Function
|
|
|
|
run: python admin.py tag ${{ vars.GCP_PROJECT }}
|
|
|
|
|
|
|
|
# DEPLOY run_user_playlist function
|
|
|
|
- name: Deploy run_user_playlist Function
|
|
|
|
run: python admin.py playlist ${{ vars.GCP_PROJECT }}
|
|
|
|
|
|
|
|
### CRON FUNCTIONS
|
|
|
|
|
|
|
|
# DEPLOY run_all_playlists function
|
|
|
|
- name: Deploy run_all_playlists Function
|
|
|
|
run: python admin.py playlist_cron ${{ vars.GCP_PROJECT }}
|
|
|
|
|
|
|
|
# DEPLOY run_all_playlist_stats function
|
|
|
|
- name: Deploy run_all_playlist_stats Function
|
|
|
|
run: python admin.py playlist_stats_cron ${{ vars.GCP_PROJECT }}
|
|
|
|
|
|
|
|
# DEPLOY run_all_tags function
|
|
|
|
- name: Deploy run_all_tags Function
|
|
|
|
run: python admin.py tags_cron ${{ vars.GCP_PROJECT }}
|
|
|
|
|
2022-08-26 19:28:17 +01:00
|
|
|
documentation:
|
|
|
|
runs-on: ubuntu-latest
|
2023-09-08 17:48:50 +01:00
|
|
|
name: Build & Deploy Documentation
|
|
|
|
needs: deployprod # for ignoring bad builds
|
2022-08-26 19:28:17 +01:00
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
steps:
|
2024-07-20 11:35:49 +01:00
|
|
|
- uses: actions/checkout@v4 # get source
|
2022-07-28 07:00:27 +01:00
|
|
|
|
2022-08-26 19:28:17 +01:00
|
|
|
# PYTHON
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Python ${{ env.python-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: actions/setup-python@v4
|
2022-08-26 19:28:17 +01:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
python-version: ${{ env.python-version }}
|
2022-08-26 19:28:17 +01:00
|
|
|
|
|
|
|
# PYTHON for dependency export only, not installing
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Poetry ${{ env.poetry-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: abatilo/actions-poetry@v2.1.6
|
2022-08-26 19:28:17 +01:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
poetry-version: ${{ env.poetry-version }}
|
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
|
2023-09-05 20:05:58 +01:00
|
|
|
# - name: Install Node ${{ env.node-version }}
|
2022-07-28 07:00:27 +01:00
|
|
|
# uses: actions/setup-node@v2
|
|
|
|
# with:
|
2023-09-05 20:05:58 +01:00
|
|
|
# node-version: ${{ env.node-version }}
|
2022-07-28 07:00:27 +01:00
|
|
|
|
|
|
|
# # 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
|
|
|
|
2023-05-16 18:30:00 +01:00
|
|
|
package:
|
|
|
|
runs-on: ubuntu-latest
|
2023-09-08 17:48:50 +01:00
|
|
|
name: Package & Push Container
|
2023-05-16 18:30:00 +01:00
|
|
|
needs: [build] # for ignoring bad builds
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build & Push Container
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
tags: sarsoo/mixonomer:latest
|
|
|
|
|
2023-09-08 17:48:50 +01:00
|
|
|
deployprod:
|
2022-07-26 22:17:39 +01:00
|
|
|
runs-on: ubuntu-latest
|
2023-09-08 17:48:50 +01:00
|
|
|
name: Deploy Production
|
|
|
|
environment:
|
|
|
|
name: prod
|
|
|
|
url: https://mixonomer.sarsoo.xyz
|
|
|
|
needs: deploytest # for ignoring bad builds
|
2021-03-20 18:21:33 +00:00
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
2021-02-07 20:40:59 +00:00
|
|
|
steps:
|
2024-07-20 11:35:49 +01:00
|
|
|
- uses: actions/checkout@v4 # 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)
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Python ${{ env.python-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-02-07 20:40:59 +00:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
python-version: ${{ env.python-version }}
|
2021-02-07 22:02:28 +00:00
|
|
|
|
|
|
|
# PYTHON for dependency export only, not installing
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Poetry ${{ env.poetry-version }}
|
2022-12-20 21:33:52 +00:00
|
|
|
uses: abatilo/actions-poetry@v2.1.6
|
2021-02-07 22:02:28 +00:00
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
poetry-version: ${{ env.poetry-version }}
|
2021-02-16 22:51:13 +00:00
|
|
|
|
|
|
|
# PYTHON Export Poetry dependencies as requirements.txt
|
|
|
|
- name: Export Poetry Dependencies
|
|
|
|
run: python admin.py pydepend
|
2021-02-07 20:40:59 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# JS setup
|
2023-09-05 20:05:58 +01:00
|
|
|
- name: Install Node ${{ env.node-version }}
|
2021-02-07 20:40:59 +00:00
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
2023-09-05 20:05:58 +01:00
|
|
|
node-version: ${{ env.node-version }}
|
2021-02-07 20:40:59 +00:00
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# JS install from lock.json
|
|
|
|
- name: Install Node Packages
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
# JS will be built again, for flagging errors
|
2021-02-16 22:51:13 +00:00
|
|
|
- name: Compile Front-end
|
2021-02-07 22:02:28 +00:00
|
|
|
run: npm run build --if-present
|
|
|
|
|
2021-02-08 00:30:17 +00:00
|
|
|
# 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
|
|
|
|
|
2021-02-07 22:02:28 +00:00
|
|
|
# DEPLOY for setting up cloud API
|
2022-07-26 22:17:39 +01:00
|
|
|
- name: Set up Cloud SDK
|
2022-11-11 07:06:17 +00:00
|
|
|
uses: google-github-actions/auth@v0.7.3
|
2021-02-07 18:32:07 +00:00
|
|
|
with:
|
2022-07-26 22:17:39 +01:00
|
|
|
credentials_json: '${{ secrets.GCP_SA_KEY }}'
|
|
|
|
export_environment_variables: true
|
|
|
|
create_credentials_file: true
|
2021-02-07 18:32:07 +00:00
|
|
|
|
2021-02-16 22:51:13 +00:00
|
|
|
# DEPLOY set project
|
|
|
|
- name: Set GCP Project
|
2023-09-05 20:05:58 +01:00
|
|
|
run: python admin.py set_project ${{ vars.GCP_PROJECT }}
|
2021-02-16 22:51:13 +00:00
|
|
|
|
|
|
|
# DEPLOY app engine service, -nb for skipping compile
|
2022-11-11 07:06:17 +00:00
|
|
|
- name: Deploy App Engine Service
|
2021-02-16 22:51:13 +00:00
|
|
|
run: python admin.py app -nb
|
|
|
|
|
2023-09-08 18:12:00 +01:00
|
|
|
# DEPLOY domain routes
|
|
|
|
- name: Deploy dispatch.yaml
|
|
|
|
run: gcloud app deploy dispatch.yaml --quiet
|
|
|
|
|
2021-02-16 22:51:13 +00:00
|
|
|
### MAIN FUNCTIONS
|
|
|
|
|
|
|
|
# DEPLOY update_tag function
|
2022-11-10 22:13:50 +00:00
|
|
|
- name: Deploy update_tag Function
|
2023-09-06 20:07:14 +01:00
|
|
|
run: python admin.py tag ${{ vars.GCP_PROJECT }}
|
2021-02-16 22:51:13 +00:00
|
|
|
|
|
|
|
# DEPLOY run_user_playlist function
|
|
|
|
- name: Deploy run_user_playlist Function
|
2023-09-06 20:07:14 +01:00
|
|
|
run: python admin.py playlist ${{ vars.GCP_PROJECT }}
|
2021-02-16 22:51:13 +00:00
|
|
|
|
|
|
|
### CRON FUNCTIONS
|
|
|
|
|
|
|
|
# DEPLOY run_all_playlists function
|
|
|
|
- name: Deploy run_all_playlists Function
|
2023-09-06 20:07:14 +01:00
|
|
|
run: python admin.py playlist_cron ${{ vars.GCP_PROJECT }}
|
2021-02-16 22:51:13 +00:00
|
|
|
|
|
|
|
# DEPLOY run_all_playlist_stats function
|
|
|
|
- name: Deploy run_all_playlist_stats Function
|
2023-09-06 20:07:14 +01:00
|
|
|
run: python admin.py playlist_stats_cron ${{ vars.GCP_PROJECT }}
|
2021-02-07 20:40:59 +00:00
|
|
|
|
2021-02-16 22:51:13 +00:00
|
|
|
# DEPLOY run_all_tags function
|
|
|
|
- name: Deploy run_all_tags Function
|
2023-09-06 20:07:14 +01:00
|
|
|
run: python admin.py tags_cron ${{ vars.GCP_PROJECT }}
|