-
Notifications
You must be signed in to change notification settings - Fork 6
145 lines (129 loc) · 4.88 KB
/
django.yml
File metadata and controls
145 lines (129 loc) · 4.88 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Django CI
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
build:
runs-on: ubuntu-24.04
# Use your self-built image as container for the entire job
container: ghcr.io/${{ github.repository }}/ci-base:latest
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL and Redis
run: |
sudo service postgresql start
sudo service redis-server start
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache node packages
uses: actions/cache@v4
env:
cache-name: cache-node-packages
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Cache uv packages
uses: actions/cache@v4
env:
cache-name: cache-uv-packages
with:
path: ~/.cache/uv
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements/dev.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache testmon data
id: cache-testmon
uses: actions/cache@v4
with:
path: .testmondata
key: ${{ runner.os }}-testmon-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements/dev.txt', 'meinberlin/config/settings/travis.py', 'meinberlin/config/settings/test.py', 'pytest.ini') }}
restore-keys: |
${{ runner.os }}-testmon-${{ steps.setup-python.outputs.python-version }}-
- name: Checks
run: |
echo "node_modules cache hit: ${{ steps.cache-node-modules.outputs.cache-hit }}"
ls -la node_modules 2>/dev/null || echo "node_modules directory does not exist"
echo "testmon cache hit: ${{ steps.cache-testmon.outputs.cache-hit }}"
ls -la .testmondata || true
./scripts/a4-check.sh
- name: Install Python Dependencies
run: |
uv pip install -r requirements/dev.txt --system
uv pip install coveralls --system
- name: Clear npm cache
run: npm cache clean --force
- name: Install NPM Dependencies
run: |
if [ "${{ steps.cache-node-modules.outputs.cache-hit }}" != "true" ]; then
echo "node_modules cache miss - running npm ci"
npm ci --prefer-offline --no-audit --no-fund
else
echo "node_modules cache hit - skipping npm ci"
fi
- name: Build NPM
run: |
npm run build
- name: Run Tests
env:
PGPASSWORD: postgres
PGHOSTADDR: 127.0.0.1
run: |
python manage.py collectstatic > /dev/null
mkdir -p media
isort --diff -c meinberlin tests
python manage.py makemigrations --dry-run --check --noinput
python manage.py clear_cache
flake8 meinberlin tests --exclude migrations,settings
if [ "${{ github.event_name }}" = "push" ]; then
# Run all tests and update testmon cache for future PRs
# Delete .testmondata to force running all tests, but still update cache
rm -f .testmondata
py.test --ds=meinberlin.config.settings.travis --testmon --cov
elif [ "${{ github.event_name }}" = "pull_request" ]; then
# Use testmon to run only changed tests
py.test --ds=meinberlin.config.settings.travis --testmon --cov
fi
- name: Coveralls
env:
COVERALLS_SERVICE_NAME: github-actions
GITHUB_TOKEN: ${{ secrets.COV }}
run: |
git config --global --add safe.directory /__w/a4-meinberlin/a4-meinberlin
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
coveralls
- name: Run Frontend Tests
run: |
npm test
npm run lint
- name: Deploy dev
if: github.ref == 'refs/heads/dev'
env:
TRAVIS_SSH_SECRET: ${{ secrets.DEPLOY }}
PROJECT_BUILD: "meinberlin-design"
VERSION_BUILD: "dev"
run: |
./scripts/deploy.sh $PROJECT_BUILD ${VERSION_BUILD##*/}
- name: Deploy main
if: github.ref == 'refs/heads/main'
env:
TRAVIS_SSH_SECRET: ${{ secrets.DEPLOY }}
run: |
./scripts/deploy.sh