ci: optimize workflow structure
- add concurrency control to cancel stale runs - job dependencies (test waits for lint) - move syntax check to lint job - quieter apt-get and pip output - remove continue-on-error on pip-audit
This commit is contained in:
@@ -6,29 +6,86 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.11"
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
|
PIP_NO_CACHE_DIR: "1"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
lint:
|
||||||
|
name: Lint & Format
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: debian:bookworm-slim
|
image: python:3.11-slim
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Setup and checkout
|
||||||
run: |
|
run: |
|
||||||
apt-get update && apt-get install -y --no-install-recommends git ca-certificates
|
apt-get update -qq && apt-get install -yqq --no-install-recommends git >/dev/null
|
||||||
|
git clone --depth 1 --branch "${GITHUB_REF_NAME}" \
|
||||||
|
"https://oauth2:${{ github.token }}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" .
|
||||||
|
|
||||||
|
- name: Install tools
|
||||||
|
run: pip install -q ruff mypy
|
||||||
|
|
||||||
|
- name: Syntax check
|
||||||
|
run: python -m py_compile run.py wsgi.py app/*.py app/**/*.py
|
||||||
|
|
||||||
|
- name: Ruff lint
|
||||||
|
run: ruff check app/ tests/ fpaste
|
||||||
|
|
||||||
|
- name: Ruff format
|
||||||
|
run: ruff format --check app/ tests/ fpaste
|
||||||
|
|
||||||
|
- name: Type check
|
||||||
|
run: mypy app/ --ignore-missing-imports --no-error-summary
|
||||||
|
|
||||||
|
security:
|
||||||
|
name: Security Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: python:3.11-slim
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup and checkout
|
||||||
|
run: |
|
||||||
|
apt-get update -qq && apt-get install -yqq --no-install-recommends git >/dev/null
|
||||||
git clone --depth 1 --branch "${GITHUB_REF_NAME}" \
|
git clone --depth 1 --branch "${GITHUB_REF_NAME}" \
|
||||||
"https://oauth2:${{ github.token }}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" .
|
"https://oauth2:${{ github.token }}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" .
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
apt-get install -y --no-install-recommends python3 python3-pip python3-venv
|
pip install -q -r requirements.txt
|
||||||
python3 -m venv venv
|
pip install -q bandit pip-audit
|
||||||
./venv/bin/pip install --quiet --upgrade pip
|
|
||||||
./venv/bin/pip install --quiet -r requirements.txt
|
- name: Bandit scan
|
||||||
./venv/bin/pip install --quiet pytest pytest-cov
|
run: bandit -r app/ -ll -q
|
||||||
|
|
||||||
|
- name: Dependency audit
|
||||||
|
run: pip-audit --strict --progress-spinner=off
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint]
|
||||||
|
container:
|
||||||
|
image: python:3.11-slim
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup and checkout
|
||||||
|
run: |
|
||||||
|
apt-get update -qq && apt-get install -yqq --no-install-recommends git >/dev/null
|
||||||
|
git clone --depth 1 --branch "${GITHUB_REF_NAME}" \
|
||||||
|
"https://oauth2:${{ github.token }}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" .
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -q -r requirements.txt
|
||||||
|
pip install -q pytest
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./venv/bin/pytest tests/ -v --tb=short
|
run: pytest tests/ -v --tb=short
|
||||||
|
|
||||||
- name: Check syntax
|
|
||||||
run: ./venv/bin/python -m py_compile run.py wsgi.py app/*.py app/**/*.py
|
|
||||||
|
|||||||
Reference in New Issue
Block a user