forked from craws/OpenAtlas
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (111 loc) · 4.25 KB
/
starter.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
name: 'OpenAtlas Github Tests'
on:
push: {}
jobs:
build_openatlas:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create tags based on git data
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}/container-preview
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value={{sha}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: install/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
test_openatlas:
env:
POSTGRES_PASSWORD: verysecret
POSTGRES_DB: openatlas_test
POSTGRES_USER: openatlas
runs-on: ubuntu-latest
needs: [build_openatlas]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create openatlas network
run: |
docker network create --internal openatlas
- name: Create postgis container
run: |
docker run -d -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD\
-e POSTGRES_DB=$POSTGRES_DB\
-e POSTGRES_USER=$POSTGRES_USER\
--name postgres --network openatlas\
postgis/postgis:13-3.3
- name: Wait
run: sleep 8
- name: Create openatlas container and run tests
run: |
COOKIE_KEY=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32;echo;)
echo "COOKIE_KEY=$COOKIE_KEY"
docker create -e OVERWRITE_DATABASE=TRUE\
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD\
-e POSTGRES_DB=$POSTGRES_DB\
-e POSTGRES_USER=$POSTGRES_USER\
-e POSTGRES_HOST=postgres\
-e COOKIE_KEY=$COOKIE_KEY\
--name openatlas --network openatlas\
ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')/container-preview:${{ github.ref_name }}
set -x
cat <<EOF > testing.py
SERVER_NAME = 'local.host'
DATABASE_NAME='openatlas_test'
DATABASE_USER='openatlas'
DATABASE_HOST='postgres'
DATABASE_PORT=5432
DATABASE_PASS='verysecret'
MAIL_PASSWORD='asdQWEtzu123'
SECRET_KEY='$COOKIE_KEY' # Used for cookies
DEBUG = True
WTF_CSRF_ENABLED = False
WTF_CSRF_METHODS: list[str] = []
ARCHE = {
'id': 0,
'collection_ids': [0],
'base_url': 'https://arche-curation.acdh-dev.oeaw.ac.at/',
'thumbnail_url': 'https://arche-thumbnails.acdh.oeaw.ac.at/'}
EOF
# production.py is recreated on every start
sudo chown 33:33 testing.py
docker cp -a testing.py openatlas:/var/www/openatlas/instance/
docker start openatlas
until [ "$(docker inspect -f {{.State.Running}} openatlas)"=="true" ]; do
sleep 0.1;
done;
docker cp openatlas:/var/www/openatlas/instance/production.py .
cat production.py
docker exec -i openatlas /bin/bash -c "cd /var/www/openatlas/instance/ && ls -la && cat testing.py && cat production.py"
- name: Run tests
run: |
docker exec -i openatlas /bin/bash -c "cd /var/www/openatlas/tests && nosetests3 --verbosity=2 --nologcapture --nocapture && echo passed"