Skip to content

Commit ce6fa8b

Browse files
authored
Use uv (#9)
* Add .gitignore * Use .python-version * Use uv * Cleanup * Update README
1 parent ec69f64 commit ce6fa8b

File tree

8 files changed

+143
-11
lines changed

8 files changed

+143
-11
lines changed

.github/workflows/basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup python
1818
uses: actions/setup-python@v5
1919
with:
20-
python-version: 3.x
20+
python-version-file: .python-version
2121
cache: pip
2222

2323
- name: Show python version

.github/workflows/basic_uv.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Basic (uv)"
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: "0 0 1 * *" # Midnight every month (UTC)
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup uv
18+
uses: astral-sh/setup-uv@v6
19+
with:
20+
enable-cache: true
21+
22+
- name: Setup python
23+
run: |
24+
uv python install
25+
uv run -- python -V
26+
27+
- name: Install python dependencies
28+
run: |
29+
uv sync --locked
30+
uv tree
31+
32+
- name: Run test
33+
run: uv run -- pytest basic.py

.github/workflows/homebrew.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup homebrew
2222
uses: Homebrew/actions/setup-homebrew@master
2323

24-
- name: Setup fortune
24+
- name: Install fortune
2525
run: brew install fortune
2626

2727
- name: Run fortune

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
9+
# Virtual environments
10+
.venv

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ A collection of GitHub Actions workflows demonstrating various capabilities and
66

77
<details>
88

9-
<summary>A basic workflow to do the essentials.</summary>
9+
<summary>A basic workflow to do the essentials for a Python project.</summary>
1010

1111
<br/>If you're unfamiliar with GitHub Actions this will help you get started quickly.
1212

13-
[.github/workflows/basic.yml](.github/workflows/basic.yml)
13+
[basic.yml](.github/workflows/basic.yml)
1414
- Runs when changes are pushed
1515
- Runs on a schedule
1616
- Can be run manually from the GitHub UI
@@ -21,6 +21,18 @@ A collection of GitHub Actions workflows demonstrating various capabilities and
2121

2222
</details>
2323

24+
## basic_uv.yml
25+
26+
<details>
27+
28+
<summary>Same as basic.yml but uses the uv project manager.</summary>
29+
30+
<br/>
31+
32+
[basic_uv.yml](.github/workflows/basic_uv.yml)
33+
34+
</details>
35+
2436
## branch_name.yml
2537

2638
<details>
@@ -37,7 +49,7 @@ For example, if your commit is tagged this method will return the tag instead of
3749

3850
You may also get an unexpected result depending on the event that triggered the workflow. This demo is set to trigger on `pull_request` and on `push` to illustrate this behavior.
3951

40-
[.github/workflows/branch_name.yml](.github/workflows/branch_name.yml)
52+
[branch_name.yml](.github/workflows/branch_name.yml)
4153
- Shows various `github` context properties that may or may not contain the branch name
4254
- Sets branch name to the top level `env` so it can be accessed by the entire workflow
4355

@@ -51,7 +63,7 @@ You may also get an unexpected result depending on the event that triggered the
5163

5264
<br/>This can be helpful for debugging workflow errors or bugs, but be careful as it has the potential to output sensitive information.
5365

54-
[.github/workflows/context.yml](.github/workflows/context.yml)
66+
[context.yml](.github/workflows/context.yml)
5567
- Shows various contexts
5668

5769
</details>
@@ -68,7 +80,7 @@ They're also fairly self-contained, so any changes you make are isolated to the
6880

6981
One quirk that can cause confusion is the fact that environment variables defined within a step aren't accessible until the next step.
7082

71-
[.github/workflows/env_var.yml](.github/workflows/env_var.yml)
83+
[env_var.yml](.github/workflows/env_var.yml)
7284
- Read env vars
7385
- Write env vars
7486
- Pass env vars
@@ -85,7 +97,7 @@ One quirk that can cause confusion is the fact that environment variables define
8597

8698
The action also includes an object with the current workflow context, references to other useful packages, and it's a pre-authenticated octokit/rest.js client.
8799

88-
[.github/workflows/github_script.yml](.github/workflows/github_script.yml)
100+
[github_script.yml](.github/workflows/github_script.yml)
89101
- Uses [actions/github-script](https://github.com/actions/github-script)
90102

91103
</details>
@@ -98,7 +110,7 @@ The action also includes an object with the current workflow context, references
98110

99111
<br/>Leverage the convenience of homebrew to install applications on GitHub Actions runners.
100112

101-
[.github/workflows/homebrew.yml](.github/workflows/homebrew.yml)
113+
[homebrew.yml](.github/workflows/homebrew.yml)
102114
- Uses [Homebrew/actions/setup-homebrew](https://github.com/Homebrew/actions/tree/master/setup-homebrew)
103115

104116
</details>
@@ -111,15 +123,14 @@ The action also includes an object with the current workflow context, references
111123

112124
<br/>Read, write, and modify PATH like any other environment variable.
113125

114-
[.github/workflows/system_path.yml](.github/workflows/system_path.yml)
126+
[system_path.yml](.github/workflows/system_path.yml)
115127
- Modify PATH env var
116128

117129
</details>
118130

119131
## References
120132

121133
- [GitHub Docs: GitHub Actions](https://docs.github.com/en/actions)
122-
<br/><br/>
123134
- [GitHub Docs: Accessing contextual information about workflow runs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/contexts)
124135
- [GitHub Docs: Adding a system path](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path)
125136
- [GitHub Docs: Configuration options for the dependabot.yml file](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file)

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1+
[project]
2+
name = "tutorial-github-actions"
3+
version = "0.1.0"
4+
description = "A quickstart and reference for GitHub Actions to help you get up and running fast."
5+
readme = "README.md"
6+
license = "MIT"
7+
license-files = ["LICENSE"]
8+
requires-python = ">=3.13"
9+
dependencies = [
10+
"pytest==8.3.5",
11+
]
12+
113
[tool.pytest.ini_options]
214
addopts = "--color=yes"

uv.lock

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)