-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (94 loc) · 3.25 KB
/
test_server.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
name: Test API server
on:
push:
branches: [ main ]
paths:
- server/**
- ".github/workflows/test_server.yaml"
pull_request:
branches: [ main ]
paths:
- server/**
- ".github/workflows/test_server.yaml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: [self-hosted, linux, large, jammy, x64]
defaults:
run:
working-directory: server
steps:
- name: Checkout repo & submodules
uses: actions/checkout@v4
with:
submodules: "true"
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."docker.io"]
mirrors = ["https://github-runner-dockerhub-cache.canonical.com:5000"]
- name: Install docker-compose
run: |
COMPOSE_URL="https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)"
echo "Downloading docker-compose from $COMPOSE_URL"
sudo curl -L -L $COMPOSE_URL -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo `docker-compose --version`
- name: Set dockerhub registry mirror at /etc/docker/daemon.json
run: |
echo '{"registry-mirrors": ["https://github-runner-dockerhub-cache.canonical.com:5000"]}' | sudo tee /etc/docker/daemon.json
- name: Restart dockerd
run: sudo systemctl restart docker
- name: Run tests with docker-compose
run: |
docker-compose up --attach-dependencies --abort-on-container-exit hwapi-test
sudo chown $USER -R coverage
sudo chgrp $USER -R coverage
- name: Upload coverage.xml as an artifact
uses: actions/upload-artifact@v4
with:
name: test_coverage
path: ./server/coverage/coverage.xml
if-no-files-found: error
retention-days: 2
report-coverage:
runs-on: [self-hosted, linux, large, jammy, x64]
if: github.event_name == 'pull_request'
needs: [test]
steps:
- name: Download build tests coverage report
uses: actions/download-artifact@v4
with:
name: test_coverage
- name: Report Coverage and annotate PR (if exists)
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.70
thresholdNew: 0.80
thresholdModified: 0.0
compare-openapi:
runs-on: [self-hosted, linux, large, jammy, x64]
defaults:
run:
working-directory: server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: Gr1N/setup-poetry@12c727a3dcf8c1a548d8d041c9d5ef5cebb3ba2e
with:
poetry-version: "2.0.0"
- run: poetry install
- name: Start FastAPI application
run: poetry run uvicorn hwapi.main:app --port 8001 &
shell: bash
- name: Fetch OpenAPI YAML
run: curl http://localhost:8001/v1/openapi.yaml -o fetched_openapi.yaml
- name: Compare with repository's openapi.yaml
run: diff fetched_openapi.yaml schemas/openapi.yaml