Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"image": "python:3.10-slim",
"features": {
"ghcr.io/devcontainers/features/git:1": {
"ppa": true,
"version": "latest"
},
"ghcr.io/va-h/devcontainers-features/uv:1": {
"shellautocompletion": true,
"version": "latest"
},
"ghcr.io/jsburckhardt/devcontainer-features/ruff:1": {},
"ghcr.io/itsmechlark/features/redis-server:1": {
"version": "latest"
}
},
"updateRemoteUserUID": true,
"containerEnv": {
"WORKON_HOME": "${containerWorkspaceFolder}/.venv",
"PYTHONPATH": "${containerWorkspaceFolder}"
},
"onCreateCommand": {
"update apt": [
"/usr/bin/apt",
"update"
],
"sync venv/install if missing": [
"/usr/local/bin/uv",
"sync",
"--frozen"
]
},
"postCreateCommand": {
"install ssh client": [
"/usr/bin/apt",
"install",
"--no-install-recommends",
"-y",
"openssh-client"
]
},
"postAttachCommand": {
"message": [
"/usr/bin/echo",
"Sleeping while environment activates"
],
"sleep": [
"/usr/bin/sleep",
"10s"
]
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ryanluker.vscode-coverage-gutters",
"ms-azuretools.vscode-docker",
"ms-python.isort",
"matangover.mypy",
"davidanson.vscode-markdownlint",
"ms-vscode.vscode-typescript-next",
"charliermarsh.ruff",
"tamasfe.even-better-toml",
"mechatroner.rainbow-csv"
],
"settings": {
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"python.venvPath": "${containerWorkspaceFolder}"
}
}
}
}
41 changes: 25 additions & 16 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-beta.5 - 3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -32,20 +32,29 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: pip install --upgrade hatch
- name: Install dependencies
run:
- apt update && apt install yamllint
- pip install uv

- name: Run tests
run: hatch run ci-report

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: coverage.xml
- name: Check code
run:
- yamllint .
- uv run mypy --check .
- uv run ruff check .

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure()
with:
report_paths: unit_test.xml
- name: Run tests
run: uv run pytest --junitxml=pytest.xml

# TODO: Look into github actions, these are out of date
# - name: Upload coverage data
# uses: actions/upload-artifact@v3
# with:
# name: coverage-data
# path: coverage.xml

# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: success() || failure()
# with:
# report_paths: unit_test.xml
56 changes: 36 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
variables:
JUNIT_TEST_REPORT: test_report_${CI_COMMIT_SHORT_SHA}.html
COVERAGE_TEST_REPORT: coverage_report_${CI_COMMIT_SHORT_SHA}
PYTHON_VERSION:
value: "3.8"
value: "3.10"
options:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
description: Python version to use

stages:
Expand All @@ -26,13 +27,21 @@ validate-yaml:
- "*.yml"
- "*.yaml"

Check-For-Black:
.python:
image:
name: python:${PYTHON_VERSION}-slim
pull_policy: if-not-present
before_script:
- pip install uv
allow_failure: false

Code-Check:
extends: .python
stage: validate
image: black
script:
- cd $CI_PROJECT_DIR
- black --check src/
allow_failure: false
- uv run mypy --check .
- uv run ruff check .
rules:
- if: $CI_JOB_MANUAL
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
Expand All @@ -42,15 +51,14 @@ Check-For-Black:

Check-HLA-Modified-Dates:
stage: validate
image: python:${PYTHON_VERSION}-slim
before_script:
extends: .python
variables:
PYTHONPATH: "${CI_BUILDS_DIR}/src"
script:
- apt update
- apt install git-restore-mtime -y --no-install-recommends
- pip install typer
script:
- cd $CI_PROJECT_DIR
- python tools/check_date_modified.py check-dates
allow_failure: false
- uv run tools/check_date_modified.py check-dates
rules:
- if: $CI_JOB_MANUAL
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
Expand All @@ -59,23 +67,31 @@ Check-HLA-Modified-Dates:
- src/**/*.mtime

Unit-Tests:
image: python:${PYTHON_VERSION}-slim
before_script:
- pip install hatch
extends: .python
stage: test
script:
- hatch env run --env test ci-report
- cd $CI_PROJECT_DIR
- uv run pytest
-vra
--html=${JUNIT_TEST_REPORT}
--self-contained-html
--cov-report=html:${COVERAGE_TEST_REPORT}
--cov-report=term
--junitxml=pytest.xml
parallel:
matrix:
- PYTHON_VERSION:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
coverage: '/^TOTAL.+?(\d+\%)$/'
interruptible: true
artifacts:
reports:
junit: unit_test.xml
junit: pytest.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- ${COVERAGE_TEST_REPORT}/*
- ${JUNIT_TEST_REPORT}
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ repos:
- id: end-of-file-fixer
- id: name-tests-test
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.9
hooks:
- id: black
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"ms-python.python",
"ryanluker.vscode-coverage-gutters",
"ms-azuretools.vscode-docker",
"ms-python.isort",
"matangover.mypy",
"davidanson.vscode-markdownlint",
"ms-vscode.vscode-typescript-next",
"charliermarsh.ruff",
"tamasfe.even-better-toml",
"mechatroner.rainbow-csv"
],
}
47 changes: 47 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"[python]": {
"diffEditor.ignoreTrimWhitespace": true,
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.wordBasedSuggestions": "off",
"gitlens.codeLens.symbolScopes": [
"!Module"
],
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "always"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
},
"editor.renderControlCharacters": true,
"editor.renderFinalNewline": "dimmed",
"editor.renderWhitespace": "none",
"editor.rulers": [
80,
110
],
"files.associations": {
"*.env": "properties"
},
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"python.envFile": "${workspaceFolder}/.env",
"python.languageServer": "Default",
"python.terminal.activateEnvironment": true,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"search.exclude": {
"**/.pytest_cache": false,
"**/.venv": false,
"**/__pycache__": false,
"**/output": false
},
"testing.gutterEnabled": true
}
11 changes: 11 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ignore:
- .git/*
- .venv/*

extends: default

rules:
truthy:
ignore: .github/*
document-end: disable
document-start: disable
26 changes: 0 additions & 26 deletions Pipfile

This file was deleted.

Loading