Skip to content

feature/2/create-first-version #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f9939c6
[#2]: initialize python project; done with:
dd-ssc Mar 10, 2025
df1a257
[#2]: align python project conf with corporate convention, extend:
dd-ssc Mar 10, 2025
6747326
[#2]: get `uv sync` to work; add uv.lock; done with:
dd-ssc Mar 10, 2025
597989a
[#2]: $ (cd code/python && uv add keyring)
dd-ssc Mar 10, 2025
f033368
[#2]: $ (cd code/python && uv add --group dev ruff)
dd-ssc Mar 10, 2025
7384d79
[#2]: implement the very first version of the backend; add py.typed
dd-ssc Mar 11, 2025
fd144d6
[#2]: make keyring load backend: conf project entry points; doc issues
dd-ssc Mar 11, 2025
02e8d82
[#2]: $ (cd code/python && uv add platformdirs pydantic PyYAML rich)
dd-ssc Mar 11, 2025
ddd60fe
[#2]: add conf file model; process conf, set up logging; add conf file
dd-ssc Mar 11, 2025
1806b19
[#2]: add data file; add to conf file model/conf; use it; add func docs
dd-ssc Mar 13, 2025
ac5da62
[#2]: ruff doesn't show any live issues in VS Code; remove:
dd-ssc Mar 18, 2025
f1e01d4
[#2]: enable live issues in VS Code: add VS Code conf file
dd-ssc Mar 18, 2025
9cf6a91
[#2]: suppress pyright issue; doc keyring issue; add doc and TODO
dd-ssc Mar 18, 2025
3b2219b
[#2]: doc issues with rich logging ./. two backends; work around
dd-ssc Mar 18, 2025
a5bc498
[#2]: add a pydantic model for python logging configuration, many TODOs;
dd-ssc Mar 21, 2025
6c7391a
[#2]: add pydantic model for rich logging conf extending logging conf
dd-ssc Mar 21, 2025
cee34a2
[#2]: add conf for console and reference to it in handler conf
dd-ssc Mar 21, 2025
294d5b5
[#2]: move sample log output to match flow and simplify coming changes
dd-ssc Mar 21, 2025
9cdf830
[#2]: adapt to reviewed conf data model: prep log root wherever needed
dd-ssc Mar 21, 2025
f61895e
[#2]: refactor to using reviewed conf data model: process console confs,
dd-ssc Mar 21, 2025
b111e67
[#2]: review approach to methods: do not return values, but set members;
dd-ssc Mar 21, 2025
6ab2ec5
[#2]: gitlab.com project deploy tokens were rotated: update local copies
dd-ssc Mar 22, 2025
1ad9466
[#2]: add first GitHub Action / CI/CD conf: do setup, run `uv sync`
dd-ssc Mar 23, 2025
e7b17d6
[#2]: add second GitHub Action / CI/CD conf: do setup, run `uv build`;
dd-ssc Mar 23, 2025
389a002
[#2]: add third GitHub Action / CI/CD conf: do setup, run `uv publish`;
dd-ssc Mar 23, 2025
bd08313
[#2]: add link to medium.com article, update Publish GitHub Action
dd-ssc Mar 23, 2025
57c864b
[#2]: manually increase project version number: 0.0.0 -> 0.0.1
dd-ssc Mar 23, 2025
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
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# build.yaml
#
# GitHub Action Build Workflow CI/CD configuration.
#
# author : stefan schablowski
# contact : stefan.schablowski@desmodyne.com
# created : 2025-03-23


# uv > Using uv in GitHub Actions:
# https://docs.astral.sh/uv/guides/integration/github


name: Build
on: [push]

jobs:
build:
name: build
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: 0.6.9

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: code/python/pyproject.toml

- name: Run `uv build`
run: uv build --directory code/python
88 changes: 88 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
# publish.yaml
#
# GitHub Action Publish Workflow CI/CD configuration.
#
# author : stefan schablowski
# contact : stefan.schablowski@desmodyne.com
# created : 2025-03-23


# Publishing a Python Package from GitHub to PyPI in 2024:
# https://medium.com/@blackary/ ...
# ... publishing-a-python-package-from-github-to-pypi-in-2024-a6fb8635d45d
# configuration in here adapted from "Step 3"


name: Publish
on:
release:
types: [created]

jobs:
publish:
environment:
name: pypi
url: https://pypi.org/p/keyring-insecure-backend
name: publish
permissions:
id-token: write
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: 0.6.9

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: code/python/pyproject.toml

# NOTE: these two jobs don't agree on where the package is built:
# + `uv build` out of the box builds package in .../code/python/dist
# + `gh-action-pypi-publish` action fails with error message
# No such file or directory: '/github/workspace/dist'
# so ostensibly, expects package there
# + attempting to adapt `uv build` to action fails with
# failed to create directory `/github/workspace/dist`:
# Permission denied
# --> enforce corporate convention `.../tmp/artifacts` unto both:
# 1. in `uv build` call, add `--out-dir`:
# https://docs.astral.sh/uv/reference/cli/#uv-build--out-dir
# 2. in `gh-action-pypi-publish` action, configure `packages-dir`:
# https://github.com/marketplace/actions/pypi-publish ...
# ... #customizing-target-package-dists-directory
# TODO: don't run `uv build` here again, but set up artifact in build job

- name: Run `uv build`
run: uv build --directory code/python --out-dir tmp/artifacts

# TODO: from the GitHub action log:
# Checking tmp/artifacts/dist/keyring_insecure_backend-0.0.1-py3-none-any.whl: PASSED with warnings
# WARNING `long_description_content_type` missing. defaulting to `text/x-rst`.
# WARNING `long_description` missing.
# Checking tmp/artifacts/dist/keyring_insecure_backend-0.0.1.tar.gz: PASSED with warnings
# WARNING `long_description_content_type` missing. defaulting to `text/x-rst`.
# WARNING `long_description` missing.
# also, from https://pypi.org/project/keyring-insecure-backend:
# The author of this package has not provided a project description
# --> `long_description` was supported in `setup.py` (or `setup.cfg`):
# https://github.com/pypi/warehouse/issues/4036
# https://packaging.python.org/en/latest/guides/ ...
# ... making-a-pypi-friendly-readme/#including- ...
# ... your-readme-in-your-package-s-metadata
# https://stackoverflow.com/a/58062850
# https://github.com/pypa/packaging.python.org/ ...
# ... issues/1535#issuecomment-2072711593
# but is not supported in pyproject.toml 🤦🏻‍♂️
# python packaging is just a sad laughing stock 😞
# TODO: see e.g. https://pypi.org/project/uv for possible project info
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: tmp/artifacts
37 changes: 37 additions & 0 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# sync.yaml
#
# GitHub Action Sync Workflow CI/CD configuration.
#
# author : stefan schablowski
# contact : stefan.schablowski@desmodyne.com
# created : 2025-03-23


# see ./build.yaml


name: Sync
on: [push]

jobs:
sync:
name: sync
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: 0.6.9

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: code/python/pyproject.toml

- name: Run `uv sync`
run: uv sync --directory code/python
51 changes: 51 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// settings.json
//
// Visual Studio Code workspace settings
//
// author : stefan schablowski
// contact : stefan.schablowski@desmodyne.com
// created : 2021-09-25


// NOTE: file suffix says .json, but actual file format is some proprietary
// Microsoft mess: mostly a json file, but with JavaScript-style (?) comments;
// can't be read/modified or even displayed properly by regular json tools :-/

// NOTE: VS Code user ./. workspace settings:
// + user settings are stored in
// $HOME/Library/Application Support/Code/User/settings.json
// + workspace settings are stored in
// .../.vscode/settings.json
// + workspace settings take precedence over user settings:
// https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence
//
// TODO: review VS Code settings, move from user to workspace settings
// TODO: review VS Code analysis / linting / etc. settings:
// https://code.visualstudio.com/docs/python/settings-reference


{
// make auto indentation less dumb
"editor.autoIndent": "advanced",
// display a vertical line at 80 characters
"editor.rulers": [ 80 ],

// remove trailing whitespace upon saving files
"files.trimTrailingWhitespace": true,

// pylance > pyright settings
"python.analysis.diagnosticMode": "workspace",
"python.analysis.exclude": [
"attic",
"code/python/.venv",
"doc/python/.venv",
"tmp"
],
"python.analysis.typeCheckingMode": "strict",

// NOTE: one single argument is probably not worth creating a shell frontend
"shellcheck.customArgs": [
"--enable=all",
"-x"
]
}
33 changes: 33 additions & 0 deletions code/python/keyring_insecure_backend/ConfFileModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# encoding: utf-8

"""
ConfFileModel.py

Insecure Keyring Backend configuration file data model.

author : stefan schablowski
contact : stefan.schablowski@desmodyne.com
created : 2025-03-11
"""


from pathlib import Path

# https://pypi.org/project/pydantic
from pydantic import BaseModel, ConfigDict

from .ConfRichLoggingModel import ConfRichLoggingModel


# -----------------------------------------------------------------------------
# public types

class ConfFileModel(BaseModel):
"""
Pydantic model that defines configuration file attributes.
"""

model_config = ConfigDict(extra='forbid')
logging: ConfRichLoggingModel
path_to_data_file: Path
Loading