Skip to content

Commit c0cdf6e

Browse files
authored
feat: replace poetry with uv (#245)
1 parent 8c5401a commit c0cdf6e

File tree

22 files changed

+1680
-1622
lines changed

22 files changed

+1680
-1622
lines changed

.cz.toml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
[tool.commitizen]
3+
version_files = ["pyproject.toml:version"]
4+
version = "2.8.28"
5+
tag_format = "v$version"
6+
name = "cz_customize"
7+
8+
[tool.commitizen.customize]
9+
message_template = "{{prefix}}{% if scope %}({{scope}}){% endif %}: {{subject}}{% if body %}\n\n{{body}}{% endif %}{% if is_breaking_change %}\n\nBREAKING CHANGE: {{footer}}{% else %}\n\n{{footer}}{% endif %}"
10+
11+
bump_pattern = "^(BREAKING[\\-\\ ]CHANGE|feat|fix|refactor|perf|ci|docs|style|test|chore|revert|build)(\\(.+\\))?(!)?"
12+
change_type_order = [
13+
"BREAKING CHANGE",
14+
"Feat",
15+
"Fix",
16+
"Refactor",
17+
"Perf",
18+
"CI",
19+
"Docs",
20+
"Technical",
21+
"Tests",
22+
]
23+
bump_message = "bump: version $current_version → $new_version"
24+
schema = "<type>(<scope>): <subject>\n<BLANK LINE>\n<body>\n<BLANK LINE>\n(BREAKING CHANGE: )<footer>"
25+
schema_pattern = "(?s)(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\\(\\S+\\))?!?:( [^\\n\\r]+)((\\n\\n.*)|(\\s*))?$"
26+
commit_parser = "^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE|ci|docs|style|test|chore|revert|build)(?:\\((?P<scope>[^()\\r\\n]*)\\)|\\()?(?P<breaking>!)?:\\s(?P<message>.*)?"
27+
version_parser = "(?P<version>([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?(\\w+)?)"
28+
changelog_pattern = "^(BREAKING[\\-\\ ]CHANGE|feat|fix|refactor|perf|ci|docs|style|test|chore|revert|build)(\\(.+\\))?(!)?" # same as bump_pattern
29+
[tool.commitizen.customize.bump_map]
30+
"^.+!$" = "MAJOR"
31+
"^BREAKING[\\-\\ ]CHANGE" = "MAJOR"
32+
"^feat" = "MINOR"
33+
"^fix" = "PATCH"
34+
"^refactor" = "PATCH"
35+
"^perf" = "PATCH"
36+
"^ci" = "PATCH"
37+
"^docs" = "PATCH"
38+
"^style" = "PATCH"
39+
"^test" = "PATCH"
40+
"^chore" = "PATCH"
41+
"^revert" = "PATCH"
42+
"^build" = "PATCH"
43+
44+
[tool.commitizen.customize.change_type_map]
45+
"feat" = "Feat"
46+
"fix" = "Fix"
47+
"refactor" = "Refactor"
48+
"perf" = "Perf"
49+
"ci" = "CI"
50+
"docs" = "Docs"
51+
"style" = "Technical"
52+
"test" = "Tests"
53+
"chore" = "Technical"
54+
"revert" = "Fix"
55+
"build" = "Technical"
56+
57+
[[tool.commitizen.customize.questions]]
58+
type = "list"
59+
name = "prefix"
60+
message = "Select the type of change you are committing"
61+
choices = [
62+
{ value = "fix", name = "fix: A bug fix. Correlates with PATCH in SemVer", key = "x" },
63+
{ value = "feat", name = "feat: A new feature. Correlates with MINOR in SemVer", key = "f" },
64+
{ value = "docs", name = "docs: Documentation only changes", key = "d" },
65+
{ value = "style", name = "style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)", key = "s" },
66+
{ value = "refactor", name = "refactor: A code change that neither fixes a bug nor adds a feature", key = "r" },
67+
{ value = "perf", name = "perf: A code change that improves performance", key = "p" },
68+
{ value = "test", name = "test: Adding missing or correcting existing tests", key = "t" },
69+
{ value = "build", name = "build: Changes that affect the build system or external dependencies (example scopes: pip, docker, npm)", key = "b" },
70+
{ value = "ci", name = "ci: Changes to our CI configuration files and scripts (example scopes: GitLabCI)", key = "c" },
71+
]
72+
73+
[[tool.commitizen.customize.questions]]
74+
type = "input"
75+
name = "scope"
76+
message = "What is the scope of this change? ((story number, class or file name): (press [enter] to skip)\n"
77+
78+
[[tool.commitizen.customize.questions]]
79+
type = "input"
80+
name = "subject"
81+
message = "Write a short and imperative summary of the code changes: (lower case and no period)\n"
82+
83+
[[tool.commitizen.customize.questions]]
84+
type = "input"
85+
name = "body"
86+
message = "Provide additional contextual information about the code changes: (press [enter] to skip)\n"
87+
88+
[[tool.commitizen.customize.questions]]
89+
type = "confirm"
90+
message = "Is this a BREAKING CHANGE? Correlates with MAJOR in SemVer"
91+
name = "is_breaking_change"
92+
default = false
93+
94+
[[tool.commitizen.customize.questions]]
95+
type = "input"
96+
name = "footer"
97+
message = "Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)\n"

.github/workflows/auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Dependabot metadata
1414
id: metadata
15-
uses: dependabot/[email protected]
15+
uses: dependabot/fetch-metadata@a3e5f86ae9f2f49b441498973ddec20035d326b8 # v1.1.1
1616
with:
1717
github-token: "${{ secrets.GITHUB_TOKEN }}"
1818
- name: Enable auto-merge for Dependabot PRs

.github/workflows/build-test.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# This workflow builds the package, installs it, and tests basic functionality
2+
3+
name: Build and Test Package
4+
5+
on:
6+
push:
7+
branches: ["main"]
8+
pull_request:
9+
branches: ["main"]
10+
11+
jobs:
12+
test-build-package:
13+
name: Test package build
14+
runs-on: ubuntu-latest
15+
if: "!startsWith(github.event.head_commit.message, 'bump:')"
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1
23+
24+
- name: Build the package
25+
run: uv build
26+
27+
- name: List built artifacts
28+
run: ls -la dist/
29+
30+
- name: Install the built wheel
31+
run: |
32+
uv venv
33+
# Find the wheel file and install it
34+
WHEEL_FILE=$(ls dist/*.whl | head -1)
35+
echo "Installing wheel: $WHEEL_FILE"
36+
uv pip install "$WHEEL_FILE"
37+
38+
- name: Test --version flag
39+
run: |
40+
# Test that the CLI is available and --version works
41+
uv run twyn --version
42+
43+
should-test-docker-build:
44+
permissions:
45+
contents: read
46+
pull-requests: read
47+
name: Check if should `test_docker_build` run
48+
runs-on: ubuntu-latest
49+
if: "!startsWith(github.event.head_commit.message, 'bump:')"
50+
steps:
51+
- name: Check out the repo
52+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53+
54+
- name: Check if Dockerfile changed
55+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
56+
id: dockerfile-changes
57+
with:
58+
filters: |
59+
dockerfile:
60+
- 'Dockerfile'
61+
- '.dockerignore'
62+
outputs:
63+
docker: ${{ steps.dockerfile-changes.outputs.dockerfile }}
64+
65+
test-docker-build:
66+
needs: [should-test-docker-build]
67+
name: Test Docker build
68+
runs-on: ubuntu-latest
69+
if: needs.should-test-docker-build.outputs.docker == 'true' && !startsWith(github.event.head_commit.message, 'bump:')
70+
permissions:
71+
contents: read
72+
packages: read
73+
steps:
74+
- name: Check out the repo
75+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76+
77+
- name: Log in to GitHub Container Registry
78+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
79+
with:
80+
registry: ghcr.io
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
86+
87+
- name: Extract metadata (tags, labels) for Docker
88+
id: meta
89+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
90+
with:
91+
images: elementsinteractive/twyn
92+
93+
- name: Build Docker image
94+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
95+
with:
96+
context: .
97+
file: ./Dockerfile
98+
push: false
99+
platforms: linux/amd64,linux/arm64
100+
tags: ${{ steps.meta.outputs.tags }}
101+
labels: ${{ steps.meta.outputs.labels }}
102+
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache

.github/workflows/bumpversion.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,34 @@ jobs:
77
bump_version:
88
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') && github.ref == 'refs/heads/main' }}
99
runs-on: ubuntu-latest
10+
container:
11+
image: commitizen/commitizen:4.8.3@sha256:08a078c52b368f85f34257a66e10645ee74d8cbe9b471930b80b2b4e95a9bd4a
12+
1013
name: "Bump version and create changelog with commitizen"
1114
steps:
12-
- uses: actions/create-github-app-token@v1
15+
- uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
1316
id: app-token
1417
with:
1518
app-id: ${{ vars.ELEMENTSINTERACTIVE_BOT_APP_ID }}
1619
private-key: ${{ secrets.ELEMENTSINTERACTIVE_BOT_PRIVATE_KEY }}
17-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1821
with:
1922
fetch-depth: 0
2023
token: ${{ steps.app-token.outputs.token }}
2124
ref: ${{ github.head_ref }}
22-
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
23-
persist-credentials: false
25+
26+
- name: Configure git
27+
run: |
28+
git config --global --add safe.directory "*"
29+
git config user.name "github-actions[bot]"
30+
git config user.email "github-actions[bot]@users.noreply.github.com"
31+
2432
- id: cz
2533
name: Create bump and changelog
26-
uses: commitizen-tools/commitizen-action@master
27-
with:
28-
github_token: ${{ steps.app-token.outputs.token }}
34+
run: |
35+
cz bump --yes --changelog
36+
git push origin HEAD:main
37+
git push origin --tags
38+
2939
- name: Print Version
30-
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
40+
run: echo "Bumped to version $(cz version -p)"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
on:
22
pull_request_target:
3-
types: [ opened, edited ]
3+
types: [opened, edited]
44
name: conventional-release-labels
55
jobs:
66
label:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: bcoe/conventional-release-labels@v1
9+
- uses: bcoe/conventional-release-labels@886f696738527c7be444262c327c89436dfb95a8 #v1.3.1
1010
with:
11-
type_labels: '{"feat": "feature", "fix": "fix", "breaking": "breaking", "ci": "CI"}'
11+
type_labels: '{"feat": "feature", "fix": "fix", "BREAKING CHANGE": "breaking", "ci": "CI", "build": "build", "refactor": "refactor", "test": "test"}'

.github/workflows/lgtm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
exit 1
3636
3737
- name: Checkout PR code
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3939
with:
4040
ref: refs/pull/${{ github.event.issue.number }}/merge
4141

.github/workflows/lint.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,40 @@ on:
1111
jobs:
1212
lint:
1313
runs-on: ubuntu-latest
14+
if: "!startsWith(github.event.head_commit.message, 'bump:')"
1415
steps:
15-
- uses: actions/checkout@v4
16-
- name: Set up Python 3.13
17-
uses: actions/setup-python@v4
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1
20+
21+
- name: Install the project
22+
run: uv sync --locked --group dev
23+
24+
- name: Cache mypy cache
25+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.1
1826
with:
19-
python-version: "3.13"
20-
- name: Install just
21-
run: |
22-
sudo apt update
23-
sudo snap install --edge --classic just
24-
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry
28-
poetry install
27+
path: .mypy_cache
28+
key: mypy-${{ runner.os }}
29+
restore-keys: |
30+
mypy-${{ runner.os }}
2931
3032
- name: Lint
3133
run: |
32-
just lint
34+
uv run ruff format --check src tests
35+
uv run ruff check src tests
36+
uv run mypy src tests
3337
3438
lint-commit:
3539
runs-on: ubuntu-latest
40+
if: "!startsWith(github.event.head_commit.message, 'bump:')"
3641
name: "Lint commit message"
42+
container:
43+
image: commitizen/commitizen:4.8.3@sha256:08a078c52b368f85f34257a66e10645ee74d8cbe9b471930b80b2b4e95a9bd4a
3744
steps:
3845
- name: Check out
39-
uses: actions/checkout@v4
40-
- name: Install commitizen
41-
run: |
42-
python -m pip install --upgrade pip
43-
python -m pip install commitizen
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4447
- name: Check commit message
45-
run: cz check --rev-range HEAD
48+
run: |
49+
git config --global --add safe.directory /__w/twyn/twyn
50+
cz check --rev-range HEAD

0 commit comments

Comments
 (0)