-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (129 loc) · 4.72 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
128
129
130
name: CI
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: '**/package-lock.json'
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
bundler-cache: true
- working-directory: frontend
run: npm install
- name: Run Vue tests
working-directory: frontend
shell: bash
run: npx vue-cli-service test:unit
- run: pip install -r requirements.txt
# Check requirements.txt contains production requirements.
- run: ./manage.py --help
- run: pip install -r requirements_dev.txt
- name: Run Django tests
env:
PYTHONWARNINGS: error
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
CELERY_BACKEND: db+postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/0
MEDIA_ROOT: /tmp/
FILE_UPLOAD_TEMP_DIR: /tmp/
shell: bash
run: |
./manage.py migrate
./manage.py makemigrations --check --dry-run
./manage.py check --fail-level WARNING
coverage run --source=core,spoonbill_web -m pytest -W error --no-migrations
- uses: coverallsapp/github-action@v2
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
redis:
image: bitnami/redis:6.2
env:
ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379/tcp
docker:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
# Build the images and start the containers.
- uses: actions/checkout@v4
- name: Create .env file
run: |
echo "DJANGO_ENV=production" >> .env
echo "DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:${{ job.services.postgres.ports[5432] }}/postgres" >> .env
echo "CELERY_BACKEND=db+postgresql://postgres:postgres@host.docker.internal:${{ job.services.postgres.ports[5432] }}/postgres" >> .env
echo "REDIS_URL=redis://redis:6379/0" >> .env
echo "CORS_ALLOWED_ORIGINS=http://127.0.0.1:8000,http://127.0.0.1" >> .env
- run: docker compose -f docker-compose.test.yaml pull --ignore-pull-failures
- run: docker compose -f docker-compose.test.yaml build
- run: docker compose -f docker-compose.test.yaml up -d
- run: docker compose -f docker-compose.test.yaml run --rm app python manage.py migrate
- run: docker ps
# If any containers are not up, debug with, for example:
# - run: docker compose -f docker-compose.test.yaml logs app
# Test the images.
- uses: actions/checkout@v4
with:
repository: open-contracting/spoonbill-test
path: test
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -r test/requirements_dev.txt
- name: Copy translation files for tests
run: |
cp core/locale/es/LC_MESSAGES/django.po test/resources/core_es.po
cp spoonbill_web/locale/es/LC_MESSAGES/django.po test/resources/backend_es.po
cp frontend/locale/es/lang.po test/resources/front_es.po
- env:
# See https://github.com/open-contracting/spoonbill-test
SITE_URL: http://127.0.0.1
working-directory: test
continue-on-error: true
run: python -m robot tests
- uses: actions/upload-artifact@v4
if: always()
with:
path: |
test/log.html
test/output.xml
test/report.html
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp