Skip to content

Use uv #9

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 5 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version-file: .python-version
cache: pip

- name: Show python version
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/basic_uv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Basic (uv)"

on:
push:
schedule:
- cron: "0 0 1 * *" # Midnight every month (UTC)
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Setup python
run: |
uv python install
uv run -- python -V

- name: Install python dependencies
run: |
uv sync --locked
uv tree

- name: Run test
run: uv run -- pytest basic.py
2 changes: 1 addition & 1 deletion .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup fortune
- name: Install fortune
run: brew install fortune

- name: Run fortune
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# Virtual environments
.venv
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ A collection of GitHub Actions workflows demonstrating various capabilities and

<details>

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

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

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

</details>

## basic_uv.yml

<details>

<summary>Same as basic.yml but uses the uv project manager.</summary>

<br/>

[basic_uv.yml](.github/workflows/basic_uv.yml)

</details>

## branch_name.yml

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

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.

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

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

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

[.github/workflows/context.yml](.github/workflows/context.yml)
[context.yml](.github/workflows/context.yml)
- Shows various contexts

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

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

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

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.

[.github/workflows/github_script.yml](.github/workflows/github_script.yml)
[github_script.yml](.github/workflows/github_script.yml)
- Uses [actions/github-script](https://github.com/actions/github-script)

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

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

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

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

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

[.github/workflows/system_path.yml](.github/workflows/system_path.yml)
[system_path.yml](.github/workflows/system_path.yml)
- Modify PATH env var

</details>

## References

- [GitHub Docs: GitHub Actions](https://docs.github.com/en/actions)
<br/><br/>
- [GitHub Docs: Accessing contextual information about workflow runs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/contexts)
- [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)
- [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)
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
[project]
name = "tutorial-github-actions"
version = "0.1.0"
description = "A quickstart and reference for GitHub Actions to help you get up and running fast."
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.13"
dependencies = [
"pytest==8.3.5",
]

[tool.pytest.ini_options]
addopts = "--color=yes"
65 changes: 65 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.