-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add project scaffolding and CI/CD workflows #1
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
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1fd4e12
chore: add project scaffolding and CI/CD workflows
Trozz ca4aa09
fix: add ruff and pip-audit as dev deps, pass GITLEAKS_LICENSE secret
Trozz c737075
Potential fix for pull request finding
Trozz ac17f86
fix: prevent duplicate release on manual dispatch
Trozz 536ebea
fix: remove unused Sequence import, add pull-requests permission for …
Trozz 569c185
fix: add fetch-depth 0 to security job for gitleaks PR scanning
Trozz 44bd12e
style: apply ruff formatting to existing files
Trozz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ## Summary | ||
|
|
||
| <!-- Brief description of what this PR does and why --> | ||
|
|
||
| ## Changes | ||
|
|
||
| - | ||
|
|
||
| ## Type of change | ||
|
|
||
| - [ ] feat: new feature | ||
| - [ ] fix: bug fix | ||
| - [ ] docs: documentation update | ||
| - [ ] refactor: code restructuring | ||
| - [ ] test: test additions or updates | ||
| - [ ] chore: maintenance or dependency update | ||
|
|
||
| ## Testing | ||
|
|
||
| - [ ] Tests added/updated | ||
| - [ ] All existing tests pass (`uv run pytest`) | ||
| - [ ] Linting passes (`uv run ruff check .`) | ||
|
|
||
| ## Breaking changes | ||
|
|
||
| <!-- Describe any breaking changes, or write "None" --> | ||
|
|
||
| None | ||
|
|
||
| ## Related issues | ||
|
|
||
| <!-- Link related issues: Fixes #123, Relates to #456 --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v[0-9]+.[0-9]+.[0-9]+" | ||
Trozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| workflow_dispatch: | ||
| inputs: | ||
| bump: | ||
| description: "Version bump type (leave empty to auto-detect from commits)" | ||
| required: false | ||
| type: choice | ||
| options: | ||
| - auto | ||
| - major | ||
| - minor | ||
| - patch | ||
| default: auto | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Determine version | ||
| id: version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "push" ]; then | ||
| TAG="${GITHUB_REF#refs/tags/}" | ||
| VERSION="${TAG#v}" | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | ||
| BUMP="${{ inputs.bump }}" | ||
|
|
||
| if [ "$BUMP" = "auto" ] || [ -z "$BUMP" ]; then | ||
| if [ -z "$LATEST_STABLE" ]; then | ||
| COMMITS=$(git log --pretty=format:"%s%n%b" HEAD) | ||
| else | ||
| COMMITS=$(git log --pretty=format:"%s%n%b" "${LATEST_STABLE}..HEAD") | ||
| fi | ||
|
|
||
| BUMP="patch" | ||
| if echo "$COMMITS" | grep -qE '^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then | ||
| BUMP="major" | ||
| elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then | ||
| BUMP="minor" | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "$LATEST_STABLE" ]; then | ||
| MAJOR=0; MINOR=1; PATCH=0 | ||
| else | ||
| VERSION="${LATEST_STABLE#v}" | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | ||
| fi | ||
|
|
||
| case "$BUMP" in | ||
| major) | ||
| MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 | ||
| ;; | ||
| minor) | ||
| MINOR=$((MINOR + 1)); PATCH=0 | ||
| ;; | ||
| patch) | ||
| PATCH=$((PATCH + 1)) | ||
| ;; | ||
| esac | ||
|
|
||
| NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}" | ||
| TAG="v${NEXT_VERSION}" | ||
|
|
||
| echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create and push tag (manual dispatch) | ||
| if: github.event_name == 'workflow_dispatch' | ||
| run: | | ||
| git tag "${{ steps.version.outputs.tag }}" | ||
| git push origin "${{ steps.version.outputs.tag }}" | ||
|
|
||
Trozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Generate changelog | ||
| id: changelog | ||
| run: | | ||
| PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -2 | tail -1) | ||
| if [ -z "$PREVIOUS_TAG" ]; then | ||
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD) | ||
| else | ||
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREVIOUS_TAG}..HEAD") | ||
| fi | ||
| { | ||
| echo "changelog<<EOF" | ||
| echo "$CHANGELOG" | ||
| echo "EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create GitHub release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.version.outputs.tag }} | ||
| name: ${{ steps.version.outputs.tag }} | ||
| body: | | ||
| ## What's Changed | ||
|
|
||
| ${{ steps.changelog.outputs.changelog }} | ||
| draft: false | ||
| prerelease: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: Release Candidate | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| rc-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Determine version bump from commits | ||
| id: bump | ||
| run: | | ||
| LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | ||
|
|
||
| if [ -z "$LATEST_STABLE" ]; then | ||
| COMMITS=$(git log --pretty=format:"%s%n%b" HEAD) | ||
| else | ||
| COMMITS=$(git log --pretty=format:"%s%n%b" "${LATEST_STABLE}..HEAD") | ||
| fi | ||
|
|
||
| BUMP="patch" | ||
|
|
||
| if echo "$COMMITS" | grep -qE '^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then | ||
| BUMP="major" | ||
| elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then | ||
| BUMP="minor" | ||
| fi | ||
|
|
||
| echo "bump=${BUMP}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Calculate next version | ||
| id: version | ||
| run: | | ||
| LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | ||
| BUMP="${{ steps.bump.outputs.bump }}" | ||
|
|
||
| if [ -z "$LATEST_STABLE" ]; then | ||
| MAJOR=0; MINOR=1; PATCH=0 | ||
| else | ||
| VERSION="${LATEST_STABLE#v}" | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | ||
| fi | ||
|
|
||
| case "$BUMP" in | ||
| major) | ||
| MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 | ||
| ;; | ||
| minor) | ||
| MINOR=$((MINOR + 1)); PATCH=0 | ||
| ;; | ||
| patch) | ||
| PATCH=$((PATCH + 1)) | ||
| ;; | ||
| esac | ||
|
|
||
| NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}" | ||
| RC_COUNT=$(git tag --sort=-v:refname | grep -cE "^v${NEXT_VERSION}-rc\." || true) | ||
| RC_NUM=$((RC_COUNT + 1)) | ||
| RC_TAG="v${NEXT_VERSION}-rc.${RC_NUM}" | ||
|
|
||
| echo "tag=${RC_TAG}" >> "$GITHUB_OUTPUT" | ||
| echo "version=${NEXT_VERSION}-rc.${RC_NUM}" >> "$GITHUB_OUTPUT" | ||
| echo "bump=${BUMP}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Generate changelog | ||
| id: changelog | ||
| run: | | ||
| LATEST_TAG=$(git tag --sort=-v:refname | head -1) | ||
| if [ -z "$LATEST_TAG" ]; then | ||
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD) | ||
| else | ||
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${LATEST_TAG}..HEAD") | ||
| fi | ||
| { | ||
| echo "changelog<<EOF" | ||
| echo "$CHANGELOG" | ||
| echo "EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create RC tag | ||
| run: | | ||
| git tag "${{ steps.version.outputs.tag }}" | ||
| git push origin "${{ steps.version.outputs.tag }}" | ||
|
|
||
| - name: Create GitHub pre-release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.version.outputs.tag }} | ||
| name: ${{ steps.version.outputs.tag }} | ||
| body: | | ||
| ## Pre-release: ${{ steps.version.outputs.tag }} | ||
|
|
||
| **Version bump**: `${{ steps.version.outputs.bump }}` (determined from conventional commits) | ||
|
|
||
| ${{ steps.changelog.outputs.changelog }} | ||
| draft: false | ||
| prerelease: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Lint & Security Scan | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install 3.13 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --all-extras | ||
|
|
||
| - name: Ruff lint | ||
| run: uv run ruff check . | ||
|
|
||
| - name: Ruff format check | ||
| run: uv run ruff format --check . | ||
|
|
||
Trozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| security: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Gitleaks secret scan | ||
| uses: gitleaks/gitleaks-action@v2 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install 3.13 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --all-extras | ||
|
|
||
| - name: Pip audit | ||
| run: uv run pip-audit | ||
Trozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Pull Request | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.9", "3.12", "3.13"] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| run: uv python install ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --all-extras | ||
|
|
||
| - name: Run tests | ||
| run: uv run pytest --tb=short -q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-added-large-files | ||
| - id: check-merge-conflict | ||
| - id: detect-private-key | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.9.10 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix] | ||
| - id: ruff-format | ||
|
|
||
| - repo: https://github.com/gitleaks/gitleaks | ||
| rev: v8.22.1 | ||
| hooks: | ||
| - id: gitleaks |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.