Skip to content

Commit 346a532

Browse files
authored
Merge pull request #21 from redjax/dev
Dev
2 parents d9a7dbc + 9f4efc0 commit 346a532

14 files changed

+698
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
## Github Action to upgrade all packages with uv
3+
name: Upgrade uv packages
4+
on:
5+
## Make this an on-demand Action
6+
workflow_dispatch:
7+
8+
jobs:
9+
10+
bump-dependencies:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
## Checkout code
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
23+
## Install uv in pipeline
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
version: "${{ inputs.uv_version || 'latest' }}"
28+
29+
## Update packages
30+
- name: Upgrade dependencies
31+
run: uv lock -U
32+
33+
## Open new PR to main
34+
- name: Create PR for dependency updates
35+
uses: peter-evans/create-pull-request@v5
36+
with:
37+
branch: chore/bump-depends
38+
commit-message: "${{ inputs.commit_message || 'chore: bump dependencies' }}"
39+
title: "${{ inputs.commit_title || 'Update dependencies' }}"
40+
body: "${{ inputs.commit_body || 'Bump dependency versions' }}"
41+
base: main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
## Pipeline to export requirements*.txt files
3+
4+
name: Uv export requirements
5+
6+
on:
7+
workflow_dispatch:
8+
9+
# pull_request:
10+
# branches:
11+
# - main
12+
# types:
13+
# - opened
14+
# - reopened
15+
# - synchronize
16+
# paths:
17+
# - "pyproject.toml"
18+
# - "uv.lock"
19+
20+
jobs:
21+
export-and-commit:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
## Checkout code in pipeline
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
## Install uv in pipeline
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
32+
33+
## Export production & dev requirements
34+
- name: Export requirements.txt
35+
run: |
36+
uv export --no-hashes -o requirements.txt
37+
uv export --no-hashes --only-dev -o requirements.dev.txt
38+
39+
## Call re-usable workflow to commit changes
40+
# - name: Commit changes back to branch
41+
# uses: ./.github/workflows/commit-changes.yml
42+
# with:
43+
# commit_message: "${{ github.event.inputs.commit_message || 'chore: update requirements' }}"
44+
45+
## Uncomment if you don't have a commit-changes workflow to call
46+
- name: Commit and push changes
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
git config user.name "github-actions[bot]"
51+
git config user.email "github-actions[bot]@users.noreply.github.com"
52+
if ! git diff --quiet; then
53+
echo "Changes detected. Committing..."
54+
git add requirements.txt requirements.dev.txt
55+
git commit -m "${{ github.event.inputs.commit_message }}"
56+
git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref_name }}"
57+
else
58+
echo "No changes detected. Skipping commmit."
59+
fi
60+
61+
## Open new PR to main
62+
- name: Create PR for dependency updates
63+
uses: peter-evans/create-pull-request@v5
64+
with:
65+
branch: chore/bump-depends
66+
commit-message: "${{ inputs.commit_message || 'chore: export requirements' }}"
67+
title: "${{ inputs.commit_title || 'Export requirements*.txt' }}"
68+
body: "${{ inputs.commit_body || 'Export production & development requirements' }}"
69+
base: main
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
## Lint code with ruff
3+
name: Code Quality Check
4+
5+
on:
6+
## Make this an on-demand Action
7+
workflow_dispatch:
8+
pull_request:
9+
branches:
10+
- main
11+
types:
12+
- opened
13+
- reopened
14+
- synchronize
15+
## Run only when changes detected in specified paths
16+
# paths:
17+
## Changes in a src/ directory
18+
# - "src/**"
19+
## Changes in a sandbox/ directory
20+
## Any Python file in the root directory (non-recursive)
21+
# - "./*.py"
22+
## Ignore changes in specified paths, don't trigger pipeline
23+
paths-ignore:
24+
## Ignore changes in a tests/ directory
25+
- "tests/*"
26+
## Ignore changes to any Jupyter notebooks
27+
- "*.ipynb"
28+
## Ignore changes in a docs/ directory
29+
- "docs/*"
30+
31+
jobs:
32+
lint:
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
## Checkout repository
37+
- name: Check out code
38+
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ github.event.pull_request.head.ref }}
41+
42+
## Install Python in container
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.12"
47+
48+
## Install uv in container
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v5
51+
with:
52+
version: "latest"
53+
54+
## Setup venv, install dependencies
55+
- name: Create virtual environment and install dependencies
56+
run: |
57+
uv venv
58+
uv pip install ruff
59+
60+
## Check with ruff
61+
- name: Run Ruff checks & fix errors
62+
## Note: paths must exist or ruff will throw an error. Remove any directories you do not use in your project.
63+
run: |
64+
uv run ruff check libs/ sandbox/ scripts/ tests/ ./noxfile.py --fix
65+
66+
## Import re-usable workflow from commit-changes.yml
67+
# Commits changes back to branch for pull request
68+
# - name: Commit changes back to branch
69+
# uses: ./.github/workflows/commit-changes.yml
70+
# with:
71+
# commit_message: "Apply lint fixes via Ruff"
72+
73+
## Use the code below if you did not create an on-deman commit-changes.yml workflow
74+
## Commit changes back to branch
75+
- name: Commit and push changes
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
run: |
79+
git config user.name "github-actions[bot]"
80+
git config user.email "github-actions[bot]@users.noreply.github.com"
81+
if ! git diff --quiet; then
82+
echo "Changes detected. Committing..."
83+
git add .
84+
git commit -m "Apply lint fixes via Ruff"
85+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
86+
else
87+
echo "No changes detected. Skipping commmit."
88+
fi

noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ def export_requirements(session: nox.Session, requirements_output_dir: Path):
171171
str(REQUIREMENTS_OUTPUT_DIR / "requirements.txt"),
172172
)
173173

174-
log.info("Exporting development requirements
174+
log.info("Exporting development requirements")
175175
session.run(
176176
"uv",
177177
"export",
178178
"--only-dev",
179179
"--no-hashes",
180-
str(REQUIREMENTS_OUTPUT_DIR / "requirements.dev.txt"
180+
str(REQUIREMENTS_OUTPUT_DIR / "requirements.dev.txt"),
181181
)
182182

183183

pipelines/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Pipelines <!-- omit in toc -->
2+
3+
Reference files for various workflow/pipeline platforms.
4+
5+
## Table of Contents <!-- omit in toc -->
6+
7+
- [Disclaimer](#disclaimer)
8+
- [Supported CI/CD Platforms](#supported-cicd-platforms)
9+
10+
11+
## Disclaimer
12+
13+
**!! MAKE SURE TO CHECK THE VERSION FOR EACH WORKFLOW STEP !!**
14+
15+
---
16+
17+
I make no effort to keep individual Action steps' version tags up to date. You can open any action by copying and pasting the `uses: ` name and adding https://github.com/ before it.
18+
19+
`https://github.com/{owner}/{action-name}`
20+
21+
For example, the URL for the `actions/checkout` Action is [`https://github.com/actions/checkout`](https://github.com/actions/checkout).
22+
23+
## Supported CI/CD Platforms
24+
25+
This repository has workflows for the following CI/CD platforms.
26+
27+
| Platform | URL | Description |
28+
| ----------------------------------- | --------------------------------------------------------- | --------------------------------- |
29+
| [Github Actions](./github-actions/) | [Github Actions docs](https://docs.github.com/en/actions) | Github's CI/CD pipeline platform. |

pipelines/github-actions/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Github Actions <!-- omit in toc -->
2+
3+
Reference pipeline files, some ready to use as-is, some requiring modification from a starting point. Templates aim to be well-documented, describing when you would need to make a change and how.
4+
5+
## Notes
6+
7+
## Links
8+
9+
- [Github Actions documentation](https://docs.github.com/en/actions)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
## Workflow to build MkDocs site & deploy to Github pages
3+
name: Build & Deploy MkDocs site
4+
5+
on:
6+
## Uncomment to trigger on PRs to main with a specific label
7+
# pull_request:
8+
# branches:
9+
# - main
10+
# types: [ labeled ]
11+
12+
## Uncomment to make the pipeline an on-demand workflow
13+
workflow_dispatch:
14+
inputs:
15+
requirements_file:
16+
required: false
17+
type: string
18+
default: requirements.txt
19+
20+
## Uncomment to allow other pipelines to trigger this one
21+
workflow_call:
22+
inputs:
23+
requirements_file:
24+
required: false
25+
type: string
26+
default: requirements.txt
27+
28+
jobs:
29+
deploy-mkdocs:
30+
name: Deploy to Github Pages
31+
## Run if PR has the publish label
32+
if: ${{ github.event.label.name == 'publish' }}
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
## Checkout code in pipeline
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
40+
## Build & deploy MkDocs site
41+
- name: Deploy MkDocs
42+
uses: mhausenblas/[email protected]
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
REQUIREMENTS: ${{ github.event.inputs.requirements_file || 'requirements.txt' }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
## Re-usable workfloww to commit changes made in pipelines.
3+
# Usage:
4+
# In another pipeline, add a step that calls this workflow:
5+
# - name: Commit changes back to branch
6+
# uses: ./.github/workflows/commit-changes.yml
7+
#
8+
# Inputs:
9+
# commit_message: Commit message to use. If not provided, defaults to "Changes committed from pipeline"
10+
11+
name: Commit Changes
12+
13+
on:
14+
## Allows this workflow to be called by other workflows
15+
workflow_call:
16+
inputs:
17+
commit_message:
18+
required: false
19+
type: string
20+
default: "Changes committed from pipeline"
21+
22+
jobs:
23+
commit-changes:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Commit and push changes
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
git add .
33+
git commit -m "${{ inputs.commit_message }}"
34+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
## Github Action to upgrade all packages with uv
3+
name: Upgrade uv packages
4+
on:
5+
## Make this an on-demand Action
6+
workflow_dispatch:
7+
workflow_call:
8+
9+
inputs:
10+
uv_version:
11+
required: false
12+
type: string
13+
default: "latest"
14+
commit_title:
15+
required: false
16+
type: string
17+
default: Update packages
18+
commit_message:
19+
required: false
20+
type: string
21+
default: "chore: bump dependencies using uv"
22+
commit_body:
23+
required: false
24+
type: string
25+
default: "Automated dependency version bumps via uv"
26+
27+
jobs:
28+
29+
bump-dependencies:
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
33+
pull-requests: write
34+
35+
steps:
36+
## Checkout code
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ github.event.pull_request.head.ref }}
41+
42+
## Install uv in pipeline
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v5
45+
with:
46+
version: "${{ inputs.uv_version || 'latest' }}"
47+
48+
## Update packages
49+
- name: Upgrade dependencies
50+
run: uv lock -U
51+
52+
## Open new PR to main
53+
- name: Create PR for dependency updates
54+
uses: peter-evans/create-pull-request@v5
55+
with:
56+
branch: chore/bump-depends
57+
commit-message: "${{ inputs.commit_message || 'chore: bump dependencies' }}"
58+
title: "${{ inputs.commit_title || 'Update dependencies' }}"
59+
body: "${{ inputs.commit_body || 'Bump dependency versions' }}"
60+
base: main

0 commit comments

Comments
 (0)