|
1 | | -name: linkedevents-ci |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [main] |
6 | 6 | pull_request: |
7 | 7 | branches: [main] |
8 | 8 |
|
9 | | - # Allows you to run this workflow manually from the Actions tab |
10 | | - workflow_dispatch: |
11 | | -env: |
12 | | - SECRET_KEY: topsecret123 |
13 | | - POSTGRES_DB: test_linkedevents |
14 | | - POSTGRES_USER: postgres |
15 | | - POSTGRES_PASSWORD: postgres |
16 | | - DATABASE_URL: "postgis://postgres:postgres@localhost/test_linkedevents" |
17 | | - FIELD_ENCRYPTION_KEYS: c87a6669a1ded2834f1dfd0830d86ef6cdd20372ac83e8c7c23feffe87e6a051 |
18 | | - |
19 | | -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
20 | 9 | jobs: |
21 | | - build: |
22 | | - runs-on: ubuntu-latest |
23 | | - strategy: |
24 | | - matrix: |
25 | | - python: [3.9] |
26 | | - services: |
27 | | - postgres: |
28 | | - image: postgis/postgis:14-3.2-alpine |
29 | | - env: |
30 | | - # Note: not redundant, parent env is not applied to service |
31 | | - POSTGRES_USER: postgres |
32 | | - POSTGRES_PASSWORD: postgres |
33 | | - POSTGRES_DB: test_linkedevents |
34 | | - ports: |
35 | | - - 5432:5432 |
36 | | - # needed because the postgres container does not provide a healthcheck |
37 | | - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
38 | | - |
39 | | - steps: |
40 | | - - name: Checkout |
41 | | - uses: actions/checkout@v3 |
42 | | - with: |
43 | | - # Required by Sonar |
44 | | - fetch-depth: 0 |
45 | | - |
46 | | - - name: Update apt |
47 | | - run: sudo apt-get update |
48 | | - |
49 | | - - name: psycopg2 prerequisites |
50 | | - run: sudo apt-get install libpq-dev |
51 | | - |
52 | | - - name: System requirements for Django |
53 | | - run: sudo apt-get install gdal-bin gettext postgresql-client |
54 | | - |
55 | | - - name: Setup Python ${{ matrix.python-version }} |
56 | | - uses: actions/setup-python@v4 |
57 | | - with: |
58 | | - python-version: ${{ matrix.python }} |
59 | | - cache: pip |
60 | | - |
61 | | - - name: Install dependencies |
62 | | - run: | |
63 | | - python -m pip install --upgrade pip |
64 | | - pip install -r requirements.txt -r requirements-dev.txt |
65 | | -
|
66 | | - - name: Configure sysctl limits |
67 | | - run: | |
68 | | - sudo swapoff -a |
69 | | - sudo sysctl -w vm.swappiness=1 |
70 | | - sudo sysctl -w fs.file-max=262144 |
71 | | - sudo sysctl -w vm.max_map_count=262144 |
72 | | -
|
73 | | - - name: Check migrations |
74 | | - run: | |
75 | | - python manage.py makemigrations --dry-run --check |
76 | | -
|
77 | | - - name: Apply migrations |
78 | | - run: | |
79 | | - python manage.py migrate |
80 | | -
|
81 | | - - name: Compile translations |
82 | | - run: | |
83 | | - django-admin compilemessages |
84 | | -
|
85 | | - - name: Check OpenAPI schema |
86 | | - run: | |
87 | | - python manage.py spectacular --lang en --validate --fail-on-warn --api-version v1 |
88 | | -
|
89 | | - - name: Run Ruff lint |
90 | | - uses: astral-sh/ruff-action@v1 |
91 | | - with: |
92 | | - version: 0.7.1 |
93 | | - |
94 | | - - name: Run Ruff format check |
95 | | - uses: astral-sh/ruff-action@v1 |
96 | | - with: |
97 | | - version: 0.7.1 |
98 | | - args: "format --check" |
99 | | - |
100 | | - - name: Check commitlint |
101 | | - uses: wagoid/commitlint-github-action@0d749a1a91d4770e983a7b8f83d4a3f0e7e0874e # v5.4.4 |
102 | | - |
103 | | - # With pytest-cov use: --cov=. |
104 | | - # Some errors, skipping --doctest-modules for now |
105 | | - - name: Run tests |
106 | | - uses: liskin/gh-problem-matcher-wrap@v2 |
107 | | - with: |
108 | | - linters: pytest |
109 | | - run: pytest -ra -vvv --cov=. |
110 | | - |
111 | | - - name: Codecov |
112 | | - uses: codecov/codecov-action@v3 |
113 | | - |
114 | | - # Without this workaround Sonar reports a warning about an incorrect source path |
115 | | - - name: Override coverage report source path for Sonar |
116 | | - run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml |
117 | | - |
118 | | - - name: SonarCloud Scan |
119 | | - uses: SonarSource/sonarcloud-github-action@master |
120 | | - env: |
121 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
122 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 10 | + common: |
| 11 | + uses: tuomas777/.github/.github/workflows/ci-django-api.yml@reusable_workflow_precommit |
| 12 | + secrets: inherit |
| 13 | + with: |
| 14 | + python-version: 3.9 |
| 15 | + use-postgis: true |
| 16 | + extra-commands: | |
| 17 | + python manage.py spectacular --lang en --validate --fail-on-warn --api-version v1 |
0 commit comments