Ensure we're on the latest versions CI actions + python (except lint check, due to issue) Also allow running the Microk8s tests on demand with workflow dispatch
70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
name: Backend Lint + Type Check
|
|
|
|
on: [push, pull_request]
|
|
|
|
# Cancel in progress workflows on pull_requests.
|
|
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# In order to be able to have required checks, a workflow can't be entirely
|
|
# skipped: see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
|
paths-filter:
|
|
name: "Changed files?"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matches: ${{ steps.filter.outputs.matches }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2 # important, to fetch previous commit
|
|
|
|
# workaround for https://github.com/dorny/paths-filter/issues/240
|
|
- id: previous-sha
|
|
run: 'echo "sha=$(git rev-parse HEAD^1)" >> $GITHUB_OUTPUT'
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
base: "${{ steps.previous-sha.outputs.sha }}"
|
|
filters: |
|
|
matches:
|
|
- 'backend/**'
|
|
- '.github/workflows/backend-lint.yaml'
|
|
|
|
unit-tests:
|
|
needs: paths-filter
|
|
if: needs.paths-filter.outputs.matches == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
cd backend/
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install -r dev-requirements.txt
|
|
|
|
- name: Style Check
|
|
run: |
|
|
black --check backend/btrixcloud/
|
|
|
|
- name: Lint Check
|
|
run: |
|
|
cd backend/
|
|
pylint btrixcloud/
|
|
|
|
- name: Type Check
|
|
run: |
|
|
cd backend/
|
|
mypy --install-types --non-interactive --check-untyped-defs btrixcloud/
|