-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (82 loc) · 2.77 KB
/
server-tests.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
# See more: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Server Tests
defaults:
run:
working-directory: server
on:
pull_request:
paths:
- "server/**"
- ".github/workflows/**"
push:
paths:
- "server/**"
- ".github/workflows/**"
workflow_dispatch:
permissions:
contents: write
jobs:
test-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
sparse-checkout: "server/"
- name: Install just
uses: extractions/setup-just@v1
- name: create .env file
run: |
echo "DATABASE_URL=dummy" >> .env
echo "MONGO_DATABASE=dummy" >> .env
echo "JWT_SECRET_KEY=dummy" >> .env
- name: Install poetry
run: pipx install poetry
- name: Debug info
run: |
ls -la
pwd
poetry --version
just --version
echo "github.workflow: ${{ github.workflow }}"
echo "github.action: ${{ github.action }}"
echo "github.run_id: ${{ github.run_id }}"
echo "github.run_number: ${{ github.run_number }}"
echo "github.action: ${{ github.action }}"
echo "github.workspace: ${{ github.workspace }}"
- name: Set up Python 3.11.3
uses: actions/setup-python@v4
with:
python-version: "3.11.3"
cache: "poetry"
- name: Install packages
run: just install
- name: Run pytest
run: just test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build docker image
uses: docker/build-push-action@v4
with:
context: server
file: ./server/Dockerfile
tags: "citest"
push: false
load: true
- name: Launch Docker container for test
run: docker run --env-file .env -p 8080:8080 --rm --detach "citest"
- name: Check if server in container responds
run: just server-check http://localhost:8080
# Generate OpenAPI specs for clients generator - it should be picked up by its gh action
- name: Commit OpenAPI specification for clients generator
if: github.event_name == 'push'
run: |
just export-openapi-specs ./generated/openapi
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add ./generated/openapi
if [ -z "$(git status --untracked-files=no --porcelain)" ]; then
echo "Working directory clean excluding untracked files"
else
git commit -m "Update OpenAPI spec by ${{ github.workflow }} ${{ github.run_id }} ${{ github.run_number }}"
git push
fi