Skip to content

Training test migration #85

Training test migration

Training test migration #85

Workflow file for this run

name: Backend Checks
on:
push:
branches:
- main
- nextjs
- prod-deploy
pull_request:
paths:
- "training/**"
jobs:
lint:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up mamba env
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Load Cached Mamba Env
id: cached-mamba-env
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key:
mamba-env-${{ runner.os }}-${{ hashFiles('**/training/environment.yml') }}
restore-keys: mamba-env-${{ runner.os }}-
- name: Install Mamba Env
if: steps.cached-mamba-env.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: training/environment.yml
miniforge-version: latest
use-mamba: true
activate-environment: dlp
use-only-tar-bz2: true
# - uses: mamba-org/setup-micromamba@v1
# with:
# micromamba-version: '1.4.5-0'
# environment-file: training/environment.yml
# init-shell: >-
# bash
# cache-environment: true
# cache-environment-key: mamba-env-${{ runner.os }}-${{ hashFiles('**/training/environment.yml') }}
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
restore-keys: training-venv-${{ runner.os }}-
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: /home/runner/micromamba/envs/dlp/
# key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
# restore-keys: training-venv-${{ runner.os }}-
#---------------------------------------------------
# install dependencies if cache does not exist
#---------------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: pwd && cd training && poetry install --no-interaction --no-root && poetry env info -p
shell: bash -el {0}
#shell: micromamba-shell {0}
#----------------------------------------------
# pyright static checker
#----------------------------------------------
- name: Run Pyright Static Checker
id: pyright-static-checker
uses: jordemort/action-pyright@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # You need this
reporter: github-pr-review # Change reporter.
lib: true
#----------------------------------------------
# black formatter
#----------------------------------------------
- uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- uses: stefanzweifel/git-auto-commit-action@v4
if: steps.action_black.outputs.is_formatted == 'true'
with:
commit_message: ":art: Format Python code with psf/black"
commit_options: '--no-verify'
commit_user_name: github-actions
commit_user_email: [email protected]
test:
needs: lint
runs-on: ubuntu-22.04
steps:
#----------------------------------------------
# check-out repo and set-up mamba env
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Load Cached Mamba Env
id: cached-mamba-env
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key:
mamba-env-${{ runner.os }}-${{ hashFiles('**/training/environment.yml') }}
restore-keys: mamba-env-${{ runner.os }}-
- name: Install Mamba Env
if: steps.cached-mamba-env.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: training/environment.yml
miniforge-version: latest
use-mamba: true
activate-environment: dlp
use-only-tar-bz2: true
# - uses: conda-incubator/setup-miniconda@v2
# with:
# environment-file: training/environment.yml
# miniforge-version: latest
# use-mamba: true
# activate-environment: dlp
# - uses: mamba-org/setup-micromamba@v1
# with:
# micromamba-version: '1.4.5-0'
# environment-file: training/environment.yml
# init-shell: >-
# bash
# cache-environment: true
# cache-environment-key: mamba-env-${{ runner.os }}-${{ hashFiles('**/training/environment.yml') }}
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
restore-keys: training-venv-${{ runner.os }}-
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: /home/runner/micromamba/envs/dlp/
# key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
# restore-keys: training-venv-${{ runner.os }}-
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: cd training && poetry install --no-interaction --no-root
shell: bash -el {0}
#shell: micromamba-shell {0}
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests with moto
run: |
export AWS_ACCESS_KEY_ID=testing
export AWS_SECRET_ACCESS_KEY=testing
export AWS_DEFAULT_REGION=us-west-2
cd training && pytest tests
shell: bash -el {0}
#shell: micromamba-shell {0}