-
Notifications
You must be signed in to change notification settings - Fork 54
127 lines (124 loc) · 4.86 KB
/
ci.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
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
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-22.04
strategy:
matrix:
test_env: [django, functional, api]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
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 python manage.py makemigrations --check --dry-run
# run migrations
docker exec --env DJANGO_LOG_LEVEL seed_web ./manage.py migrate
docker exec --env DJANGO_LOG_LEVEL seed_web ./manage.py create_default_user [email protected] --password=demo123
docker exec --env DJANGO_LOG_LEVEL seed_web /bin/bash -c 'echo "y" | ./manage.py make_superuser --user [email protected]'
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
npm install
sudo apt update
sudo apt 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 coverage run manage.py test --settings=config.settings.docker_dev
if [[ ! -z "${COVERALLS_REPO_TOKEN}" ]]; then
docker exec --env COVERALLS_REPO_TOKEN seed_web 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'
run: |
Xvfb :99 &
npm test
- name: Test API
if: ${{ matrix.test_env == 'api' }}
run: |
docker exec seed_web ./manage.py create_test_user_json --username [email protected] --host http://localhost --file ./seed/tests/api/api_test_user.json
docker exec seed_web 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-22.04
strategy:
matrix:
tox_env: [docs, precommit, mypy, lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install deps
run: |
pip install --upgrade pip
pip install tox==3.14.3
sudo apt update
sudo apt 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: tox -e ${{ matrix.tox_env }}