Repository navigation
147 lines (138 loc) · 5.77 KB
/
Copy pathautomated-testing.yaml
File metadata and controls
147 lines (138 loc) · 5.77 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: 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-latest
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:
# ADMIN_PASSWORD must be set: Fuseki serves queries to anyone but
# answers UPDATES with 401 unless the credentials are valid, and
# securitysettings.py.default expects admin/admin. Without it the OEKG
# graph tests skip instead of running, and the claim they exist to
# prove -- one update request is one transaction -- is never checked.
# Pinned to the version production runs, and on the same backend:
# this dataset is TDB2 on disk. It used to also set FUSEKI_MEM_1=true
# and say it was in-memory, which was never true -- that image reads
# no such variable, and the config it generates from FUSEKI_DATASET_1
# is tdb2:DatasetTDB2 at /fuseki/databases/ds (measured 2026-09-21,
# and the data survives a container restart). Running the real backend
# is the better of the two anyway; it is just not what was written
# here. It is also what makes the run slow: an INSERT DATA costs
# ~310 ms on TDB2 against ~6 ms for a SELECT, whatever its size.
image: stain/jena-fuseki:5.1.0
ports:
- 3030:3030
options: >-
--name fuseki -e ADMIN_PASSWORD=admin -e FUSEKI_DATASET_1=ds
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 ca-certificates
sudo update-ca-certificates
- 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: OEKG shape artifacts
# The scenario-bundle API validates against these, so without them its
# tests skip and the validation this slice exists for is never checked.
# Needs the ontology step above: the label subset is generated from it.
run: python manage.py fetch_oekg_shapes
- 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='test@test.com',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