Update pr-build.yml #103
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pr-build | |
on: | |
pull_request: | |
types: ['opened', 'reopened', 'synchronize'] | |
branches: | |
- 'main' | |
jobs: | |
detect-change-scope: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
etl: ${{ steps.filter.outputs.etl }} | |
api: ${{ steps.filter.outputs.api }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: dorny/[email protected] | |
id: filter | |
with: | |
filters: | | |
etl: | |
- 'air-quality-backend/src/etl/**' | |
- 'air-quality-backend/tests/etl_tests/**' | |
api: | |
- 'air-quality-backend/src/api/**' | |
- 'air-quality-backend/tests/api_tests/**' | |
run-lint: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
channels: conda-forge | |
environment-file: air-quality-backend/conda/utility_environment.yml | |
auto-activate-base: false | |
activate-environment: utility-env | |
- name: Run lint check | |
run: python -m flake8 --append-config air-quality-backend/.flake8 air-quality-backend | |
etl: | |
needs: detect-change-scope | |
if: ${{ needs.detect-change-scope.outputs.etl == 'true' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
channels: conda-forge | |
environment-file: air-quality-backend/conda/etl_environment.yml | |
auto-activate-base: false | |
activate-environment: etl-dev | |
- name: Run etl unit tests | |
run: python -m pytest --cov=air-quality-backend/tests --cov=scripts air-quality-backend/tests/etl_tests | |
- name: Rename coverage file | |
run: mv air-quality-backend/tests/.coverage.coverage .coverage.etl.coverage | |
- name: Upload coverage | |
uses: actions/upload-artifact@master | |
with: | |
name: etl_test_report | |
path: air-quality-backend/tests/.coverage.etl.coverage | |
api: | |
needs: detect-change-scope | |
if: ${{ needs.detect-change-scope.outputs.api == 'true' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
channels: conda-forge | |
environment-file: air-quality-backend/conda/api_environment.yml | |
auto-activate-base: false | |
activate-environment: api-dev | |
- name: Run api unit tests | |
run: python -m pytest --cov=air-quality-backend/tests --cov=scripts air-quality-backend/tests/api_tests | |
- name: Rename coverage file | |
run: mv air-quality-backend/tests/.coverage .coverage.api | |
- name: Upload coverage | |
uses: actions/upload-artifact@master | |
with: | |
name: api_test_report | |
path: air-quality-backend/tests/.coverage.api | |
combine-coverage: | |
needs: [detect-change-scope, etl, api] | |
if: ${{ needs.detect-change-scope.outputs.etl == 'true' && needs.detect-change-scope.outputs.api == 'true' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
channels: conda-forge | |
environment-file: air-quality-backend/conda/api_environment.yml | |
auto-activate-base: false | |
activate-environment: api-dev | |
- uses: actions/download-artifact@master | |
with: | |
name: api_test_report | |
path: air-quality-backend/tests/.coverage.api | |
- uses: actions/download-artifact@master | |
with: | |
name: etl_test_report | |
path: air-quality-backend/tests/.coverage.api | |
- name: print dr | |
run: ls air-quality-backend/tests/ | |
- name: Code Coverage Combine Reports | |
run: python -m coverage combine air-quality-backend/tests/.coverage* |