Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tcjennings committed Dec 5, 2024
1 parent eb74380 commit c43f8a5
Show file tree
Hide file tree
Showing 11 changed files with 1,757 additions and 25 deletions.
54 changes: 48 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ env:
# this version. Quote the version to avoid interpretation as a floating
# point number.
PYTHON_VERSION: "3.12"
UV_PYTHON_PREFERENCE: "system"

"on":
merge_group: {}
pull_request: {}
pull_request:
types:
- closed
push:
branches-ignore:
# These should always correspond to pull requests, so ignore them for
Expand All @@ -19,8 +22,8 @@ env:
- "dependabot/**"
- "gh-readonly-queue/**"
- "renovate/**"
- "tickets/**"
- "u/**"
# - "tickets/**"
# - "u/**"
tags:
- "*"

Expand All @@ -35,7 +38,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
python-version-file: "pyproject.toml"

- name: Run pre-commit
uses: pre-commit/[email protected]
Expand Down Expand Up @@ -66,8 +69,10 @@ jobs:
# won't be set.
if: >
github.event_name != 'merge_group'
&& (startsWith(github.ref, 'refs/tags/')
|| startsWith(github.head_ref, 'tickets/'))
&& (
startsWith(github.ref, 'refs/tags/') ||
startsWith(github.head_ref, 'u/tobyj/')
)
steps:
- uses: actions/checkout@v4
Expand All @@ -79,3 +84,40 @@ jobs:
with:
image: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}

# Release -- when PR is merged to main, bump version, make tag, recommit
release:
runs-on: ubuntu-latest
timeout-minutes: 10
if: >-
github.event.pull_request.merged == true
github.ref == "refs/heads/main" &&
steps:
- uses: actions/checkout@v4

- name: Set up UV
uses: astral-sh/setup-uv@v4
with:
version: "0.5"

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

- name: Install Release Manager
run: >-
uv tool install python-semantic-release
- name: Configure Git
run:
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"

- name: Bump Project Version
env:
GIT_COMMIT_AUTHOR: "${{github.actor}} <${{github.actor}}@users.noreply.github.com>"
run: >-
semantic-release
version --patch
--no-vcs-release --skip-build --no-changelog
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.8.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ help:
@echo "make update - Update pinned dependencies and run make init"
@echo "make update-deps - Update pinned dependencies"

.venv:
uv venv

.PHONY: init
init:
pip install --upgrade uv
uv pip install -r requirements/main.txt -r requirements/dev.txt \
-r requirements/tox.txt
uv pip install --editable .
rm -rf .tox
uv pip install --upgrade pre-commit
pre-commit install
uv run pre-commit install

.PHONY: run
run:
Expand All @@ -24,10 +26,9 @@ run:
update: update-deps init

.PHONY: update-deps
update-deps:
pip install --upgrade uv
update-deps: .venv
uv pip install --upgrade pre-commit
pre-commit autoupdate
uv run pre-commit autoupdate
uv pip compile --upgrade --universal --generate-hashes \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade --universal --generate-hashes \
Expand Down
39 changes: 36 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ Homepage = "https://tobyj-demo-app.lsst.io"
Source = "https://github.com/lsst-dm/tobyj-demo-app"

[build-system]
requires = ["setuptools>=61", "wheel", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.setuptools_scm]
[tool.hatch.build.targets.wheel]
packages = ["src/tobyjdemoapp"]

[tool.hatch.version]
path = "src/tobyjdemoapp/__init__.py"
fallback-version = "0.0.0"

[tool.coverage.run]
parallel = true
Expand Down Expand Up @@ -111,3 +116,31 @@ format = "md"
md_header_level = "2"
new_fragment_template = "file:changelog.d/_template.md.jinja"
skip_fragments = "_template.md.jinja"

[tool.semantic_release]
version_variables = ["src/tobyjdemoapp/__init__.py:__version__"]
commit_author = {env = "GIT_COMMIT_AUTHOR"}
tag_format = "{version}"

[tool.semantic_release.branches.main]
match = "main"
prerelease = false

[tool.semantic_release.branches.ticket]
match = "^tickets/DM-\\d+(.*)$"
prerelease_token = "rc"
prerelease = false

[tool.semantic_release.branches.user]
match = "^u/(.*)/(.*)$"
prerelease_token = "alpha"
prerelease = true

[tool.semantic_release.changelog]

[tool.semantic_release.publish]
upload_to_vcs_release = false

[tool.semantic_release.remote]
name = "origin"
type = "github"
3 changes: 3 additions & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ asgi-lifespan
coverage[toml]
httpx
mypy
pre-commit
pydantic
pytest
pytest-asyncio
pytest-cov
ruff
python-semantic-release>=9.15.1

# Documentation
scriv
Loading

0 comments on commit c43f8a5

Please sign in to comment.