-
Notifications
You must be signed in to change notification settings - Fork 19
131 lines (122 loc) · 4.4 KB
/
automated-testing.yaml
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
name: Automated Test
# We run this automated testing job on every commit on master and develop and for every pull request.
on:
push:
branches:
- master
- develop
pull_request:
jobs:
run-tests:
runs-on: ubuntu-20.04
env:
# LD_PRELOAD: /lib/x86_64-linux-gnu/libSegFault.so
# SEGFAULT_SIGNALS: all
OEP_DJANGO_USER: "postgres"
OEP_DB_PW: "postgres"
LOCAL_DB_USER: "postgres"
LOCAL_DB_PASSWORD: "postgres"
TOXENV: py3
permissions:
contents: read
# We create a service container with a provisioned postgres. oeplatform will use this database for its tests.
services:
postgres:
# We use our own prepared postgres image for this.
image: ghcr.io/openenergyplatform/oeplatform-postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# We open up port 5432 to be able to use `localhost:5432` to connect to the database.
# We also could omit this and use `postgres:5432` to connect to the database after modifying security settings.
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
fuseki:
image: stain/jena-fuseki
ports:
- 3030:3030
options: >-
--name fuseki
-e FUSEKI_DATASET_1=ds
-e FUSEKI_MEM_1=true
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install linux dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y postgresql-client
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Wait for Fuseki to start
run: |
for i in {1..30}; do
if nc -z localhost 3030; then
echo "Fuseki is up!"
break
fi
echo "Waiting for Fuseki..."
sleep 2
done
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip 'setuptools<72.0.0' wheel
pip install -r requirements.txt
pip install tox-uv
- name: Add schemas for testing
env:
PGPASSWORD: postgres
run: |
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS sandbox" oedb
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS _sandbox" oedb
- name: oeo & oeo-ext integration
run: |
mkdir -p ontologies/oeo/1/
mkdir -p ontologies/oeo/1/imports
mkdir -p ontologies/oeo/1/modules
wget https://openenergyplatform.org/ontology/oeo/releases/oeo-full.owl -P ontologies/oeo/1/
mkdir -p media/oeo_ext/
cp oeo_ext/oeo_extended_store/oeox_template/oeo_ext_template_empty.owl media/oeo_ext/oeo_ext.owl
- name: Collectstatic files & compress
run: |
cp oeplatform/securitysettings.py.default oeplatform/securitysettings.py
python manage.py collectstatic
python manage.py compress
- name: Migrations & User creation
run: |
python manage.py makemigrations --check
python manage.py migrate
python manage.py alembic upgrade head
python manage.py shell -c "from login.models import myuser; u=myuser.objects.create_user(name='test',email='[email protected]',affiliation='');u.is_mail_verified=True;u.save()"
- name: Create API token
run: |
echo LOCAL_OEP_TOKEN=`python manage.py shell -c "from login.models import Token; print(Token.objects.filter(user__name='test').first().key)"` >> $GITHUB_ENV
- name: Start OEP
run: python manage.py runserver 8000 &
#- name: Run tests without tox
# run: python manage.py test --no-input
- name: Run tests with tox
run: tox -v