aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/lint-backend.yaml
blob: 62fad71502bc668897a67d5f3afdebe262d8b4f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
on:
  workflow_call:

jobs:
  lint:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_USER: backend
          POSTGRES_PASSWORD: backend
          POSTGRES_DB: backend
        ports:
          - 5432/tcp
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Python Dependencies
        uses: HassanAbouelela/actions/setup-python@setup-python_v1.6.0
        with:
          python_version: "3.12"

      - name: Ensure requirements.txt is up to date
        shell: bash
        run: |
          poetry export --output temp-requirements.txt -vvv

          if ! cmp -s "thallium-backend/requirements.txt" "temp-requirements.txt"; then
            echo "::error file=requirements.txt,title=Requirements out of date!::Run 'make lock'"
            exit 1
          fi

      - name: Run pre-commit hooks
        run: SKIP=ruff-lint pre-commit run --all-files

      # Run `ruff` using github formatting to enable automatic inline annotations.
      - name: Run ruff
        run: ruff check --output-format=github .

      - name: Run tests
        run: make test
        env:
          BACKEND_SIGNING_KEY: for-testing-use-only
          BACKEND_DATABASE_URL: postgresql+psycopg_async://backend:backend@localhost:${{ job.services.postgres.ports[5432] }}/backend
          BACKEND_SUPER_ADMIN_TOKEN: hunter2
          BACKEND_PRINTFUL_TOKEN: not-valid