This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
114 lines (96 loc) · 3.86 KB
/
unit-test.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
name: Unit Tests (Docker)
on:
push:
branches:
- main
pull_request:
branches:
- '**'
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
test-harvester:
runs-on: ubuntu-latest
env:
GALV_HARVESTER_TEST_PATH: .test_datafiles
steps:
- uses: actions/checkout@v3
- name: Install smbclient
run: |
sudo apt-get update
sudo apt-get install -y smbclient
- name: Restore cached test suite
id: cache-restore
uses: actions/cache/restore@v3
with:
path: ${{ env.GALV_HARVESTER_TEST_PATH }}
key: liionsden-test-suite
- name: Download test suite
if: steps.cache-restore.outputs.cache-hit != 'true'
env:
LIIONSDEN_SMB_PATH: ${{ secrets.LIIONSDEN_SMB_PATH }}
LIIONSDEN_SMB_USERNAME: ${{ secrets.LIIONSDEN_SMB_USERNAME}}
LIIONSDEN_SMB_PASSWORD: ${{ secrets.LIIONSDEN_SMB_PASSWORD}}
run: |
sudo mkdir -p $GALV_HARVESTER_TEST_PATH
cd $GALV_HARVESTER_TEST_PATH
sudo smbget -R $LIIONSDEN_SMB_PATH/test-suite-small -U "$LIIONSDEN_SMB_USERNAME%$LIIONSDEN_SMB_PASSWORD"
- name: Cache test suite
id: cache-save
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ${{ env.GALV_HARVESTER_TEST_PATH }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Build the stack
run: touch .env.secret && docker-compose -f docker-compose.test.yml build harvester_test
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run tests
run: docker-compose -f docker-compose.test.yml up harvester_test
test-backend:
runs-on: ubuntu-latest
env:
POSTGRES_PASSWORD: "galv"
DJANGO_SECRET_KEY: "long-and-insecure-key-12345"
FRONTEND_VIRTUAL_HOST: "http://localhost"
VIRTUAL_HOST: "localhost"
steps:
- uses: actions/checkout@v3
- name: Set up secrets
run: |
touch .env.secret
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" > .env.secret
echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" >> .env.secret
echo "FRONTEND_VIRTUAL_HOST=$FRONTEND_VIRTUAL_HOST" >> .env.secret
echo "VIRTUAL_HOST=$VIRTUAL_HOST" >> .env.secret
echo "POSTGRES_HOST=postgres_test" >> .env.secret
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Build the stack
run: docker-compose -f docker-compose.test.yml up -d --build app_test
- name: Run tests
run: docker-compose -f docker-compose.test.yml run --rm app_test bash -c "cd .. && ./server.sh"
test-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up secrets
run: touch .env.secret
- name: Build the stack
run: docker-compose -f docker-compose.test.yml build frontend_test
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run tests
run: docker-compose -f docker-compose.test.yml run --rm frontend_test bash -c "./src/test/run_tests.sh"