generated from HIRO-MicroDataCenters-BV/template-web-service
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (115 loc) · 3.76 KB
/
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
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
name: Test and build server
on:
push:
branches:
- '**'
tags:
- '**'
paths-ignore:
- 'releases/**'
pull_request:
branches:
- '**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
test_server:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pip install poetry
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-root --with dev,test
- name: Run style checks
run: |
poetry run mypy .
poetry run isort . --check --diff
poetry run flake8 .
poetry run black . --check --diff
- name: Run tests
run: poetry run pytest
- name: Verify OpenAPI spec has been updated
run: |
cd "${{ github.workspace }}"
poetry run --directory server python ./tools/extract_openapi.py app.main:app --app-dir ./server --out ./api/openapi_generated.yaml --app_version_file ./VERSION
git diff --exit-code ./api/openapi.yaml ./api/openapi_generated.yaml
# Disabled because we do not need a client yet
# - name: Verify client has been updated
# run: |
# cd "${{ github.workspace }}"
# poetry --directory server run python ./tools/client_generator/generate.py --file ./api/openapi.yaml
# git diff --exit-code -- ./client
build_server:
needs: [test_server]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Make versions
run: |
cd "${{ github.workspace }}"
chmod +x ./tools/version.sh
./tools/version.sh "${{ env.REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}"
echo "VERSION_APP=$(cat "./VERSION_APP")" >> $GITHUB_ENV
echo "DOCKER_IMAGES=$(cat "./DOCKER_IMAGES")" >> $GITHUB_ENV
echo "DOCKER_TAGS=$(cat "./VERSION_DOCKER")" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}
tags: ${{ env.DOCKER_TAGS }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.DOCKER_IMAGES }}
labels: ${{ steps.meta.outputs.labels }}
context: "${{ github.workspace }}/server"
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Create a github release
run: gh release create "${{ env.VERSION_APP }}"
env:
GH_TOKEN: ${{ github.token }}
- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ github.token }}
charts_dir: "./server/charts/"
target_dir: "./helm-charts/"