-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 2.53 KB
/
ci.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
on:
pull_request:
type: [opened]
push:
paths:
- '.github/workflows/ci.yaml'
- '.github/workflows/init_db.sql'
- 'insalan/**'
- 'requirements.txt'
- '*.sh'
- 'locale/**'
- 'Dockerfile*'
jobs:
linting:
env:
PYLINT_MINSCORE: 8.0
runs-on: ubuntu-22.04
steps:
- run: echo "### Linting" >> $GITHUB_STEP_SUMMARY
- uses: actions/checkout@v3
# Install Python 3.12
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# Set the environment up
- run: python3 -m venv env
- run: source env/bin/activate
# Install dependencies
- name: Install dependencies
run: pip3 install -r requirements.txt
- name: Install pylint and pylint-django
run: pip3 install -r requirements-dev.txt
# Run lints
- name: Run linter evaluation
shell: bash
run: |
pylint --fail-under ${{ env.PYLINT_MINSCORE }} ./insalan | tee >(grep "Your code has been" | sed 's/^Your code has been rated at \(.*\)\/10.*/PYLINT_SCORE=\1/' >> "$GITHUB_ENV")
# Summary
- name: Summary
run: echo ::notice title=Pylint Score::Your \`pylint\` score is ${{ env.PYLINT_SCORE }}
- run: echo Your \`pylint\` score is ${{ env.PYLINT_SCORE }} >> "$GITHUB_STEP_SUMMARY"
unit-tests:
if: always()
needs: [linting]
runs-on: ubuntu-22.04
env:
DB_NAME: insalan
DB_USER: insalan
DB_PASS: insalan
DB_HOST: "127.0.0.1"
DB_PORT: 5432
services:
postgresql:
image: postgres
env:
POSTGRES_PASSWORD: ${{ env.DB_PASS }}
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_DB: ${{ env.DB_NAME }}
ports:
- "5432:5432"
options: --health-cmd pg_isready --health-interval 1s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v3
# Install Python 3.12
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# Set the environment up
- run: python3 -m venv env
- run: source env/bin/activate
# Install dependencies
- run: pip3 install -r requirements.txt
# Initialize the database
- run: psql postgresql://${{ env.DB_USER }}:${{ env.DB_PASS }}@${{ env.DB_HOST }}:${{ env.DB_PORT }}/${{ env.DB_NAME }} -f .github/workflows/init_db.sql
# Prepare database
- run: python3 manage.py makemigrations
- run: python3 manage.py migrate
- run: python3 manage.py test --parallel auto