90 lines (74 loc) · 2.31 KB
/
pre-commit.yml
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
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
DJANGO_SETTINGS_MODULE: cc_licenses.settings.ephemeral
services:
postgres:
image: postgres:12.3-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install system dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gcc gettext pandoc
# https://github.com/actions/checkout
- name: Checkout cc-licenses
uses: actions/checkout@v2
# https://github.com/actions/checkout
- name: Checkout cc-licenses-data
uses: actions/checkout@v2
with:
repository: creativecommons/cc-licenses-data
path: cc-licenses-data
- name: Configure testing git identity
run: |
git config --global user.email "testing_user@localhost"
git config --global user.name "Testing User"
# https://github.com/actions/setup-python
- name: actions/setup-python@v2 Python 3.7
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install pipenv
# Use pipenv 2021.5.29 to circumvent errors:
# https://github.com/pypa/pipenv/issues/4833
run: |
python -m pip install --no-cache-dir --upgrade pip
python -m pip install --no-cache-dir pipenv==2021.5.29
- name: Install Python dependencies
run: |
pipenv sync --dev --system
- name: Update Django database schema
env:
DATA_REPOSITORY_DIR: cc-licenses-data
run: |
./manage.py migrate
- name: Start Django development web server
env:
DATA_REPOSITORY_DIR: cc-licenses-data
run: |
./manage.py runserver &>/dev/null &
# https://github.com/pre-commit/action
- uses: pre-commit/action@v2.0.3
env:
DATA_REPOSITORY_DIR: cc-licenses-data