forked from SEED-platform/seed
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (144 loc) · 5.59 KB
/
Copy pathci.yml
File metadata and controls
147 lines (144 loc) · 5.59 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
146
147
name: CI
on:
pull_request:
push:
branches:
- 'develop'
- 'main'
jobs:
# Currently GH Actions provides no simple method for "sharing"
# our setup steps. Ideally this would be in an action, but we would need to use
# actions inside of our actions which you cannot currently do (see https://github.com/actions/runner/issues/438)
#
# As a result, the DRYest method for now is to use a testing matrix and
# use conditional steps for actually running the tests.
unittests:
runs-on: ubuntu-24.04
strategy:
matrix:
test_env: [django, functional, api]
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Cache Docker layers
uses: actions/cache@v5
with:
path: /tmp/.buildx-cache
# using `-v3` in key to clear old cache due to errors
# See: https://stackoverflow.com/questions/63521430/clear-cache-in-github-actions
key: ${{ runner.os }}-buildx-v3-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-v3-
- name: Build Docker dev image
run: /usr/bin/docker buildx build --tag seedplatform/seed:develop --cache-from type=local,src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --load --file Dockerfile-dev .
- name: Start the stack
env:
DJANGO_LOG_LEVEL: ERROR
run: |
docker volume create --name=seed_pgdata
docker volume create --name=seed_media
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
- name: Migrate
env:
DJANGO_LOG_LEVEL: ERROR
run: |
# verify no migrations need to be made...
docker exec seed_web uv run python manage.py makemigrations --check --dry-run
# run migrations
docker exec --env DJANGO_LOG_LEVEL seed_web uv run python manage.py migrate
docker exec --env DJANGO_LOG_LEVEL seed_web uv run python manage.py create_default_user --username=demo@example.com --password=demo123
docker exec --env DJANGO_LOG_LEVEL seed_web /bin/bash -lc 'echo "y" | uv run python manage.py make_superuser --user demo@example.com'
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
echo "Disk space after cleanup:"
df -h
- name: Install dependencies
run: |
pnpm install
sudo apt-get update
sudo apt-get install -y xvfb
- name: Test Django
if: ${{ matrix.test_env == 'django' }}
env:
SEED_PM_UN: ${{ secrets.SEED_PM_UN }}
SEED_PM_PW: ${{ secrets.SEED_PM_PW }}
SF_INSTANCE: ${{ secrets.SF_INSTANCE }}
SF_USERNAME: ${{ secrets.SF_USERNAME }}
SF_PASSWORD: ${{ secrets.SF_PASSWORD }}
SF_DOMAIN: ${{ vars.SF_DOMAIN }}
SF_SECURITY_TOKEN: ${{ secrets.SF_SECURITY_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
DJANGO_LOG_LEVEL: ERROR
run: |
docker exec seed_web touch /seed/config/settings/local_untracked.py
docker exec --env SEED_PM_UN --env SEED_PM_PW --env DJANGO_LOG_LEVEL --env SF_INSTANCE --env SF_USERNAME --env SF_PASSWORD --env SF_SECURITY_TOKEN --env SF_DOMAIN seed_web /bin/bash -lc 'uv run coverage run manage.py test --settings=config.settings.docker_test --parallel="$(nproc)" --verbosity=2'
if [[ ! -z "${COVERALLS_REPO_TOKEN}" ]]; then
docker exec --env COVERALLS_REPO_TOKEN seed_web uv run coveralls
else
echo "INFO: Env var COVERALLS_REPO_TOKEN was not found, skipping coveralls update"
fi
- name: Test Frontend
if: ${{ matrix.test_env == 'functional' }}
env:
DISPLAY: ':99'
PUPPETEER_SKIP_DOWNLOAD: true
run: |
Xvfb :99 &
pnpm test
- name: Test API
if: ${{ matrix.test_env == 'api' }}
run: |
docker exec seed_web uv run python manage.py create_test_user_json --username demo@example.com --host http://localhost --file ./seed/tests/api/api_test_user.json
docker exec seed_web uv run python seed/tests/api/test_seed_host_api.py --noinput --nofile
- name: Web container logs
if: ${{ always() }}
run: docker logs seed_web
formatting:
runs-on: ubuntu-24.04
strategy:
matrix:
tox_env: [docs, precommit, mypy, lint]
steps:
- uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-python@v6
with:
python-version-file: '.python-version'
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Install deps
run: |
uv sync --frozen --all-groups
sudo apt-get update
sudo apt-get install gdal-bin
- name: Setup config
run: |
cat <<EOF > config/settings/local_untracked.py
{
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
EOF
- name: Run tox
run: uv run tox -e ${{ matrix.tox_env }}