Skip to content

Commit 4c88e3f

Browse files
committed
initial commit
0 parents  commit 4c88e3f

25 files changed

Lines changed: 2118 additions & 0 deletions

‎.github/CODEOWNERS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Default owner(s) of all files in this repository
2+
* @jeffkala
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Setup the Poetry environment
2+
3+
Composite action that installs Python and Poetry, then restores the Poetry virtualenv from the Actions cache or
4+
creates it with `poetry install`. Imported from
5+
[`networktocode/gh-action-setup-poetry-environment`](https://github.com/networktocode/gh-action-setup-poetry-environment)
6+
at `v7.2`; that repository is unchanged and keeps serving its existing tags.
7+
8+
```yaml
9+
- name: "Setup environment"
10+
uses: "networktocode/github-reusable-workflows/.github/actions/setup-poetry-environment@v1"
11+
with:
12+
poetry-version: "2.1.3"
13+
python-version: "3.12"
14+
poetry-install-options: "--only dev"
15+
```
16+
17+
The cache key is:
18+
19+
```text
20+
${{ runner.os }}-poetry-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}${{ inputs.cache-version }}
21+
```
22+
23+
A changed `poetry.lock`, a different exact Python version or a new `cache-version` invalidates the cache and a fresh
24+
environment is installed and saved.
25+
26+
## Inputs
27+
28+
| Input | Default | Purpose |
29+
| --- | --- | --- |
30+
| `python-version` | `"3.11"` | Python version passed to `actions/setup-python`. |
31+
| `poetry-version` | `""` (latest) | Poetry version installed with `pipx`, e.g. `2.1.3`. Versions `1.x` also get a compatible `virtualenv` plugin. |
32+
| `poetry-install-options` | `"--only dev"` | Options appended to `poetry install`. |
33+
| `cache-version` | `""` | Extra string appended to the cache key to force a fresh environment. |
34+
35+
## Outputs
36+
37+
| Output | Purpose |
38+
| --- | --- |
39+
| `cache-used` | `true` when the virtualenv was restored from cache, empty otherwise. |
40+
| `python-version` | Exact Python version installed, e.g. `3.12.4`. |
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# Imported from networktocode/gh-action-setup-poetry-environment@v7.2 (whitespace/quoting normalised only)
3+
# (commit c31e438e32194e3ef5779152713dd570f2dfc511). Referenced as
4+
# networktocode/github-reusable-workflows/.github/actions/setup-poetry-environment@<ref>
5+
name: "Setup the environment"
6+
description: "This action creates the Poetry environment and load virtual environment from cache if cache exists."
7+
inputs:
8+
poetry-install-options:
9+
description: "Options pass to the poetry install command"
10+
required: false
11+
default: "--only dev"
12+
poetry-version:
13+
description: "Poetry version that will be deployed. Leave blank for latest. Example: 1.4.2"
14+
required: false
15+
default: ""
16+
python-version:
17+
description: "Python version that will be deployed"
18+
required: false
19+
default: "3.11"
20+
cache-version:
21+
description: "Cache version for the environment, can be used to invalidate the current cache"
22+
required: false
23+
default: ""
24+
outputs:
25+
cache-used:
26+
description: "The property that defines if cache was used"
27+
value: "${{ steps.cached-poetry.outputs.cache-hit }}"
28+
python-version:
29+
description: "Exact python version used"
30+
value: "${{ steps.python-setup.outputs.python-version }}"
31+
runs:
32+
using: "composite"
33+
steps:
34+
- name: "Set up Python"
35+
uses: "actions/setup-python@v6"
36+
id: "python-setup"
37+
with:
38+
python-version: "${{ inputs.python-version }}"
39+
- name: "Log: Install Poetry"
40+
run: "echo Installing Poetry"
41+
shell: "bash"
42+
- name: "Install Poetry"
43+
run: |
44+
if [ -z "${{ inputs.poetry-version }}" ]
45+
then
46+
pipx install poetry
47+
else
48+
pipx install poetry==${{ inputs.poetry-version }}
49+
fi
50+
env:
51+
PIPX_DEFAULT_PYTHON: "${{ steps.python-setup.outputs.python-path }}"
52+
shell: "bash"
53+
- name: "Add poetry to PATH"
54+
run: "ln -s /root/.local/bin/poetry /usr/local/bin/poetry"
55+
shell: "bash"
56+
- name: "Install Virtualenv compatible with Poetry 1.X"
57+
if: "startsWith(inputs.poetry-version, '1.')"
58+
run: "poetry self add virtualenv@20.30.0"
59+
shell: "bash"
60+
- name: "Log: Check cache"
61+
run: "echo Checking cache"
62+
shell: "bash"
63+
- name: "Cache"
64+
uses: "actions/cache@v5"
65+
id: "cached-poetry"
66+
with:
67+
path: "~/.cache/pypoetry/virtualenvs/"
68+
key: "${{ runner.os }}-poetry-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}${{ inputs.cache-version }}"
69+
- name: "Install environment"
70+
run: "poetry install ${{ inputs.poetry-install-options }}"
71+
shell: "bash"

‎.github/dependabot.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
github-actions:
10+
patterns:
11+
- "*"

‎.github/workflows/_ci.yml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
# CI for this repository: lint the reusable workflows and the caller examples.
3+
name: "CI"
4+
concurrency:
5+
group: "${{ github.workflow }}-${{ github.ref }}"
6+
cancel-in-progress: true
7+
on: # yamllint disable-line rule:truthy rule:comments
8+
push:
9+
branches:
10+
- "main"
11+
pull_request: ~
12+
13+
permissions:
14+
contents: "read"
15+
16+
jobs:
17+
yamllint:
18+
name: "Linting: yamllint"
19+
runs-on: "ubuntu-latest"
20+
steps:
21+
- name: "Check out repository code"
22+
uses: "actions/checkout@v7"
23+
- name: "Set up Python"
24+
uses: "actions/setup-python@v6"
25+
with:
26+
python-version: "3.12"
27+
- name: "Install yamllint"
28+
run: "pip install yamllint"
29+
- name: "Linting: yamllint"
30+
run: "yamllint --strict ."
31+
32+
actionlint:
33+
name: "Linting: actionlint"
34+
runs-on: "ubuntu-latest"
35+
steps:
36+
- name: "Check out repository code"
37+
uses: "actions/checkout@v7"
38+
- name: "Install actionlint"
39+
run: "bash <(curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.7/scripts/download-actionlint.bash) 1.7.7 /usr/local/bin"
40+
- name: "Linting: actionlint (reusable workflows)"
41+
run: "actionlint -color"
42+
# The caller examples live outside .github/workflows, so lint them explicitly.
43+
- name: "Linting: actionlint (caller examples)"
44+
run: "actionlint -color examples/*/*.yml"
45+
46+
action-smoke-test:
47+
name: "Smoke test: setup-poetry-environment"
48+
runs-on: "ubuntu-latest"
49+
steps:
50+
- name: "Check out repository code"
51+
uses: "actions/checkout@v7"
52+
# The action installs whatever Poetry project sits in the workspace root, so borrow a real NTC project.
53+
- name: "Check out a Poetry project to install"
54+
uses: "actions/checkout@v7"
55+
with:
56+
repository: "networktocode/netutils"
57+
ref: "develop"
58+
path: "project"
59+
- name: "Place the project files in the workspace root"
60+
run: "cp project/pyproject.toml project/poetry.lock ."
61+
- name: "Run the action from this branch"
62+
id: "setup"
63+
uses: "./.github/actions/setup-poetry-environment"
64+
with:
65+
poetry-version: "2.1.3"
66+
python-version: "3.12"
67+
poetry-install-options: "--only dev --no-root"
68+
- name: "Verify the environment"
69+
run: |
70+
poetry --version
71+
poetry run ruff --version
72+
echo "python-version output: ${{ steps.setup.outputs.python-version }}"
73+
echo "cache-used output: ${{ steps.setup.outputs.cache-used }}"

‎.github/workflows/_tag-major.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
# Keeps the floating major tag (v1, v2, ...) pointing at the newest release so callers can pin `@v1`.
3+
name: "Update major version tag"
4+
on: # yamllint disable-line rule:truthy rule:comments
5+
release:
6+
types: ["published"]
7+
8+
permissions:
9+
contents: "write"
10+
11+
jobs:
12+
tag-major:
13+
name: "Move major tag to ${{ github.ref_name }}"
14+
runs-on: "ubuntu-latest"
15+
if: "startsWith(github.ref, 'refs/tags/v')"
16+
steps:
17+
- name: "Check out repository code"
18+
uses: "actions/checkout@v7"
19+
with:
20+
fetch-depth: 0
21+
- name: "Move the major tag"
22+
env:
23+
TAG_NAME: "${{ github.ref_name }}"
24+
run: |
25+
if ! [[ "$TAG_NAME" =~ ^v([0-9]+)\.[0-9]+\.[0-9]+$ ]]; then
26+
echo "::notice::Tag $TAG_NAME is not a vMAJOR.MINOR.PATCH release; not moving a major tag."
27+
exit 0
28+
fi
29+
MAJOR_TAG="v${BASH_REMATCH[1]}"
30+
git config user.name "github-actions[bot]"
31+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
32+
git tag -f -a "$MAJOR_TAG" -m "Update $MAJOR_TAG to $TAG_NAME" "$TAG_NAME"
33+
# Leading '+' in the refspec overwrites the existing remote tag.
34+
git push origin "+refs/tags/$MAJOR_TAG:refs/tags/$MAJOR_TAG"
35+
echo "Moved $MAJOR_TAG to $TAG_NAME"

0 commit comments

Comments
 (0)