Skip to content

Commit bd0a798

Browse files
authored
Merge pull request #2 from cfe-lab/1-update-package-manager-from-pipenv-to-uv
1 update package manager from pipenv to uv
2 parents f92bf05 + f6b4f4a commit bd0a798

22 files changed

+1454
-861
lines changed

.devcontainer/devcontainer.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3+
{
4+
"image": "python:3.10-slim",
5+
"features": {
6+
"ghcr.io/devcontainers/features/git:1": {
7+
"ppa": true,
8+
"version": "latest"
9+
},
10+
"ghcr.io/va-h/devcontainers-features/uv:1": {
11+
"shellautocompletion": true,
12+
"version": "latest"
13+
},
14+
"ghcr.io/jsburckhardt/devcontainer-features/ruff:1": {},
15+
"ghcr.io/itsmechlark/features/redis-server:1": {
16+
"version": "latest"
17+
}
18+
},
19+
"updateRemoteUserUID": true,
20+
"containerEnv": {
21+
"WORKON_HOME": "${containerWorkspaceFolder}/.venv",
22+
"PYTHONPATH": "${containerWorkspaceFolder}"
23+
},
24+
"onCreateCommand": {
25+
"update apt": [
26+
"/usr/bin/apt",
27+
"update"
28+
],
29+
"sync venv/install if missing": [
30+
"/usr/local/bin/uv",
31+
"sync",
32+
"--frozen"
33+
]
34+
},
35+
"postCreateCommand": {
36+
"install ssh client": [
37+
"/usr/bin/apt",
38+
"install",
39+
"--no-install-recommends",
40+
"-y",
41+
"openssh-client"
42+
]
43+
},
44+
"postAttachCommand": {
45+
"message": [
46+
"/usr/bin/echo",
47+
"Sleeping while environment activates"
48+
],
49+
"sleep": [
50+
"/usr/bin/sleep",
51+
"10s"
52+
]
53+
},
54+
"customizations": {
55+
"vscode": {
56+
"extensions": [
57+
"ms-python.python",
58+
"ryanluker.vscode-coverage-gutters",
59+
"ms-azuretools.vscode-docker",
60+
"ms-python.isort",
61+
"matangover.mypy",
62+
"davidanson.vscode-markdownlint",
63+
"ms-vscode.vscode-typescript-next",
64+
"charliermarsh.ruff",
65+
"tamasfe.even-better-toml",
66+
"mechatroner.rainbow-csv"
67+
],
68+
"settings": {
69+
"python.terminal.activateEnvironment": true,
70+
"python.terminal.activateEnvInCurrentTerminal": true,
71+
"python.venvPath": "${containerWorkspaceFolder}"
72+
}
73+
}
74+
}
75+
}

.github/workflows/python.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: [ubuntu-latest]
25-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-beta.5 - 3.11"]
25+
python-version: ["3.10", "3.11", "3.12"]
2626

2727
steps:
2828
- uses: actions/checkout@v3
@@ -32,20 +32,29 @@ jobs:
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434

35-
- name: Install Hatch
36-
run: pip install --upgrade hatch
35+
- name: Install dependencies
36+
run:
37+
- apt update && apt install yamllint
38+
- pip install uv
3739

38-
- name: Run tests
39-
run: hatch run ci-report
40-
41-
- name: Upload coverage data
42-
uses: actions/upload-artifact@v3
43-
with:
44-
name: coverage-data
45-
path: coverage.xml
40+
- name: Check code
41+
run:
42+
- yamllint .
43+
- uv run mypy --check .
44+
- uv run ruff check .
4645

47-
- name: Publish Test Report
48-
uses: mikepenz/action-junit-report@v3
49-
if: success() || failure()
50-
with:
51-
report_paths: unit_test.xml
46+
- name: Run tests
47+
run: uv run pytest --junitxml=pytest.xml
48+
49+
# TODO: Look into github actions, these are out of date
50+
# - name: Upload coverage data
51+
# uses: actions/upload-artifact@v3
52+
# with:
53+
# name: coverage-data
54+
# path: coverage.xml
55+
56+
# - name: Publish Test Report
57+
# uses: mikepenz/action-junit-report@v3
58+
# if: success() || failure()
59+
# with:
60+
# report_paths: unit_test.xml

.gitlab-ci.yml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
variables:
3+
JUNIT_TEST_REPORT: test_report_${CI_COMMIT_SHORT_SHA}.html
4+
COVERAGE_TEST_REPORT: coverage_report_${CI_COMMIT_SHORT_SHA}
35
PYTHON_VERSION:
4-
value: "3.8"
6+
value: "3.10"
57
options:
6-
- "3.8"
7-
- "3.9"
88
- "3.10"
99
- "3.11"
10+
- "3.12"
1011
description: Python version to use
1112

1213
stages:
@@ -26,13 +27,21 @@ validate-yaml:
2627
- "*.yml"
2728
- "*.yaml"
2829

29-
Check-For-Black:
30+
.python:
31+
image:
32+
name: python:${PYTHON_VERSION}-slim
33+
pull_policy: if-not-present
34+
before_script:
35+
- pip install uv
36+
allow_failure: false
37+
38+
Code-Check:
39+
extends: .python
3040
stage: validate
31-
image: black
3241
script:
3342
- cd $CI_PROJECT_DIR
34-
- black --check src/
35-
allow_failure: false
43+
- uv run mypy --check .
44+
- uv run ruff check .
3645
rules:
3746
- if: $CI_JOB_MANUAL
3847
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@@ -42,15 +51,14 @@ Check-For-Black:
4251

4352
Check-HLA-Modified-Dates:
4453
stage: validate
45-
image: python:${PYTHON_VERSION}-slim
46-
before_script:
54+
extends: .python
55+
variables:
56+
PYTHONPATH: "${CI_BUILDS_DIR}/src"
57+
script:
4758
- apt update
4859
- apt install git-restore-mtime -y --no-install-recommends
49-
- pip install typer
50-
script:
5160
- cd $CI_PROJECT_DIR
52-
- python tools/check_date_modified.py check-dates
53-
allow_failure: false
61+
- uv run tools/check_date_modified.py check-dates
5462
rules:
5563
- if: $CI_JOB_MANUAL
5664
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@@ -59,23 +67,31 @@ Check-HLA-Modified-Dates:
5967
- src/**/*.mtime
6068

6169
Unit-Tests:
62-
image: python:${PYTHON_VERSION}-slim
63-
before_script:
64-
- pip install hatch
70+
extends: .python
71+
stage: test
6572
script:
66-
- hatch env run --env test ci-report
73+
- cd $CI_PROJECT_DIR
74+
- uv run pytest
75+
-vra
76+
--html=${JUNIT_TEST_REPORT}
77+
--self-contained-html
78+
--cov-report=html:${COVERAGE_TEST_REPORT}
79+
--cov-report=term
80+
--junitxml=pytest.xml
6781
parallel:
6882
matrix:
6983
- PYTHON_VERSION:
70-
- "3.8"
71-
- "3.9"
7284
- "3.10"
7385
- "3.11"
86+
- "3.12"
7487
coverage: '/^TOTAL.+?(\d+\%)$/'
7588
interruptible: true
7689
artifacts:
7790
reports:
78-
junit: unit_test.xml
91+
junit: pytest.xml
7992
coverage_report:
8093
coverage_format: cobertura
8194
path: coverage.xml
95+
paths:
96+
- ${COVERAGE_TEST_REPORT}/*
97+
- ${JUNIT_TEST_REPORT}

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ repos:
99
- id: end-of-file-fixer
1010
- id: name-tests-test
1111
- id: trailing-whitespace
12-
- repo: https://github.com/psf/black
13-
rev: 23.1.0
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.9.9
1415
hooks:
15-
- id: black
16+
# Run the linter.
17+
- id: ruff
18+
args: [--fix]
19+
# Run the formatter.
20+
- id: ruff-format

.vscode/extensions.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"ryanluker.vscode-coverage-gutters",
5+
"ms-azuretools.vscode-docker",
6+
"ms-python.isort",
7+
"matangover.mypy",
8+
"davidanson.vscode-markdownlint",
9+
"ms-vscode.vscode-typescript-next",
10+
"charliermarsh.ruff",
11+
"tamasfe.even-better-toml",
12+
"mechatroner.rainbow-csv"
13+
],
14+
}

.vscode/settings.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"[python]": {
3+
"diffEditor.ignoreTrimWhitespace": true,
4+
"editor.detectIndentation": false,
5+
"editor.tabSize": 4,
6+
"editor.wordBasedSuggestions": "off",
7+
"gitlens.codeLens.symbolScopes": [
8+
"!Module"
9+
],
10+
"editor.codeActionsOnSave": {
11+
"source.organizeImports.ruff": "always"
12+
},
13+
"editor.formatOnSave": true,
14+
"editor.defaultFormatter": "charliermarsh.ruff"
15+
},
16+
"editor.renderControlCharacters": true,
17+
"editor.renderFinalNewline": "dimmed",
18+
"editor.renderWhitespace": "none",
19+
"editor.rulers": [
20+
80,
21+
110
22+
],
23+
"files.associations": {
24+
"*.env": "properties"
25+
},
26+
"files.encoding": "utf8",
27+
"files.eol": "\n",
28+
"files.insertFinalNewline": true,
29+
"files.trimFinalNewlines": true,
30+
"files.trimTrailingWhitespace": true,
31+
"python.envFile": "${workspaceFolder}/.env",
32+
"python.languageServer": "Default",
33+
"python.terminal.activateEnvironment": true,
34+
"python.testing.autoTestDiscoverOnSaveEnabled": true,
35+
"python.testing.pytestArgs": [
36+
"tests"
37+
],
38+
"python.testing.pytestEnabled": true,
39+
"python.testing.unittestEnabled": false,
40+
"search.exclude": {
41+
"**/.pytest_cache": false,
42+
"**/.venv": false,
43+
"**/__pycache__": false,
44+
"**/output": false
45+
},
46+
"testing.gutterEnabled": true
47+
}

.yamllint.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ignore:
2+
- .git/*
3+
- .venv/*
4+
5+
extends: default
6+
7+
rules:
8+
truthy:
9+
ignore: .github/*
10+
document-end: disable
11+
document-start: disable

Pipfile

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)