Skip to content

Commit 5981df0

Browse files
authored
Merge pull request #4 from minvws/poetry-ci
Added initial poetry/ci things
2 parents fdba260 + 0ecaa98 commit 5981df0

38 files changed

Lines changed: 1746 additions & 144 deletions

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2
10+
11+
[*.py]
12+
indent_size = 4
13+
max_line_length = 120
14+
15+
[Makefile]
16+
indent_style = tab
17+
18+
[*.md]
19+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# use unix-style line endings (LF)
2+
* text=auto eol=lf
3+
*.{cmd,[cC][mM][dD]} text eol=crlf

.github/workflows/ci.yaml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
name: Build
17+
runs-on: ubuntu-22.04
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Run build action
24+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
25+
with:
26+
python_version: "3.11"
27+
28+
lint:
29+
name: Run code linter
30+
runs-on: ubuntu-22.04
31+
needs: build
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
37+
- name: Run build action
38+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
39+
with:
40+
python_version: "3.11"
41+
42+
- name: Lint
43+
run: poetry run $(make lint --just-print --silent)
44+
45+
type-check:
46+
name: Check static types
47+
runs-on: ubuntu-22.04
48+
needs: build
49+
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
54+
- name: Run build action
55+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
56+
with:
57+
python_version: "3.11"
58+
59+
- name: Check static types
60+
run: poetry run $(make type-check --just-print --silent)
61+
62+
safety-check:
63+
name: Scan packages for vulnerabilities
64+
runs-on: ubuntu-22.04
65+
needs: build
66+
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
- name: Run build action
72+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
73+
with:
74+
python_version: "3.11"
75+
76+
- name: Scan packages for vulnerabilities
77+
run: poetry run $(make safety-check --just-print --silent)
78+
79+
spelling-check:
80+
name: Run spelling check
81+
runs-on: ubuntu-22.04
82+
needs: build
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
88+
- name: Run build action
89+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
90+
with:
91+
python_version: "3.11"
92+
93+
- name: Run spelling check
94+
run: poetry run $(make spelling-check --just-print --silent)
95+
96+
test:
97+
name: Run the tests
98+
runs-on: ubuntu-22.04
99+
needs: build
100+
101+
steps:
102+
- name: Checkout repository
103+
uses: actions/checkout@v4
104+
105+
- name: Run build action
106+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/poetry-install@main
107+
with:
108+
python_version: "3.11"
109+
110+
- name: Run the tests
111+
run: poetry run $(make test --just-print --silent)
112+
113+
- name: Upload coverage report
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: coverage
117+
path: coverage.xml
118+
119+
sonar:
120+
name: SonarCloud
121+
runs-on: ubuntu-latest
122+
needs: test
123+
steps:
124+
- name: Checkout repository
125+
uses: actions/checkout@v4
126+
with:
127+
fetch-depth: 0
128+
- name: Download coverage report
129+
uses: actions/download-artifact@v4
130+
- name: Run SonarCloud scanner
131+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/sonarcloud@main
132+
with:
133+
sonar-token: ${{ secrets.SONAR_TOKEN }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Package python virtual env
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
python_version: ['3.11']
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- name: Set env
16+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV &&
17+
echo "PKG_NAME=`basename $GITHUB_REPOSITORY -private`" >> $GITHUB_ENV
18+
19+
- name: Build venv package
20+
uses: minvws/nl-irealisatie-generic-pipelines/.github/actions/python-venv-package@main
21+
with:
22+
python_version: ${{ matrix.python_version }}
23+
package_file_name: ${{ env.PKG_NAME }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Create release package
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Set env
13+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV &&
14+
echo "PKG_NAME=`basename $GITHUB_REPOSITORY -private`" >> $GITHUB_ENV
15+
16+
- uses: actions/checkout@v4
17+
18+
- name: Add version file
19+
run: 'echo "{ \"version\": \"${{ env.RELEASE_VERSION }}\", \"git_ref\": \"$GITHUB_SHA\"}" > version.json'
20+
21+
- name: Create tar
22+
run: tar -czf ${{ env.PKG_NAME }}_${{ env.RELEASE_VERSION }}.tar.gz app docs tools ./version.json
23+
24+
- name: Upload release tar
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ env.PKG_NAME }}_${{ env.RELEASE_VERSION }}
28+
path: ${{ env.PKG_NAME }}_${{ env.RELEASE_VERSION }}.tar.gz

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__
22
.venv
3-
ssl/*
3+
secrets/ssl/*
44
secrets/*
5+
app.conf

Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
NEW_UID = 1000
2+
NEW_GID = 1000
3+
4+
ifdef DOCKER
5+
RUN_PREFIX := docker compose run --rm app
6+
else
7+
RUN_PREFIX :=
8+
endif
9+
10+
.SILENT: help
11+
all: help
12+
13+
container-build: ## Build the container
14+
docker compose build --build-arg="NEW_UID=${NEW_UID}" --build-arg="NEW_GID=${NEW_GID}"
15+
16+
up: ## Start the container
17+
docker compose up
18+
19+
bash: ## Runs a bash prompt inside the container
20+
docker compose run --rm app bash
21+
22+
lint: ## Check for linting errors
23+
$(RUN_PREFIX) ruff check
24+
25+
lint-fix: ## Fix linting errors
26+
$(RUN_PREFIX) ruff check --fix --show-fixes
27+
28+
type-check: ## Check for typing errors
29+
$(RUN_PREFIX) mypy app
30+
31+
safety-check: ## Check for security vulnerabilities
32+
$(RUN_PREFIX) safety check
33+
34+
spelling-check: ## Check spelling mistakes
35+
$(RUN_PREFIX) codespell .
36+
37+
spelling-fix: ## Fix spelling mistakes
38+
$(RUN_PREFIX) codespell . --write-changes --interactive=3
39+
40+
test: ## Runs automated tests
41+
$(RUN_PREFIX) pytest --cov --cov-report=term --cov-report=xml
42+
43+
check: lint type-check safety-check spelling-check test ## Runs all checks
44+
fix: lint-fix spelling-fix ## Runs all fixers
45+
46+
help: ## Display available commands
47+
echo "Available make commands:"
48+
echo
49+
grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'

app.conf renamed to app.conf.autopilot

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
[app]
22
loglevel=debug
3-
keystore=hsm
4-
#keystore=json
5-
#auth_override_cert = ./ssl/ov-cert.pem
6-
#auth_override_cert = ./ssl/ev-cert.pem
7-
auth_override_cert = ./ssl/uzi-cert.pem
3+
keystore=json
4+
auth_override_cert = ./secrets/ssl/prs-uzi.crt
85

96
[uvicorn]
107
swagger_enabled = True
@@ -23,7 +20,6 @@ ssl_key_file = server.key
2320
key_name = REK
2421
key_version = 1
2522
alg = AES-256-GCM
26-
max_encryptions = 9223372036854775807
2723
key_renewal_at = 1000
2824
iv_prefix = RIVF
2925
max_age_for_pdn_exchange_via_vad = 1000

app/__init__.py

Whitespace-only changes.

app/application.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import os
32

43
from typing import Any
54

0 commit comments

Comments
 (0)