Skip to content

Commit c580e7d

Browse files
committed
ci|docs: initial revision of GHA workflows
also make several improvements to the docs Signed-off-by: Bryant Finney <[email protected]>
1 parent 6f990dd commit c580e7d

18 files changed

+837
-23
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
______________________________________________________________________
2+
3+
## name: Bug report about: Report a bug to help us improve title: "bug: ..." labels: bug assignees: ""
4+
5+
# Bug Report
6+
7+
<!-- 1-3 sentences summarizing the bug you encountered -->
8+
9+
## Steps to Reproduce
10+
11+
<!--
12+
provide detailed steps to reproduce the bug. these steps will be used to write an acceptance test
13+
for the bug fix, so snippets of Python are welcome.
14+
-->
15+
16+
1. _Step 1_
17+
1. _Step 2_
18+
1. _Step 3_
19+
1. ...
20+
21+
### Expected Behavior
22+
23+
<!-- what you expected to happen when following the steps above -->
24+
25+
### Actual Behavior
26+
27+
<!-- what actually happened when following the steps above -->
28+
29+
## Environment
30+
31+
<!-- provide information needed to reproduce the environment where the bug occurred -->
32+
33+
```sh
34+
poetry env info
35+
```
36+
37+
### Virtualenv
38+
39+
- Python:
40+
- Implementation:
41+
- Path:
42+
- Executable:
43+
- Valid:
44+
45+
### System
46+
47+
- Platform:
48+
- OS:
49+
- Python:
50+
- Path:
51+
- Executable:
52+
53+
## Additional Information
54+
55+
<!-- any other information about the bug that you think might be helpful -->
56+
57+
### Possible Solution
58+
59+
<!-- if you have any ideas on how to solve the bug, please suggest them here -->
60+
61+
### Related Issues
62+
63+
<!-- are there any related issues? if yes, please list them here -->
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
______________________________________________________________________
2+
3+
## name: Feature request about: Suggest an idea for this project title: "feat: ..." labels: feature assignees: ""
4+
5+
# Feature Request
6+
7+
<!-- 1-3 sentences describing the feature you would like to see implemented -->
8+
9+
## User Story
10+
11+
<!--
12+
describe the specific use case and users of this feature in the format of a user story
13+
14+
for example:
15+
16+
> As a cloud engineer, most of my configuration files are stored in AWS SSM Parameter Store. I would
17+
> like the ability for `pyspry` to retrieve these files automatically.
18+
-->
19+
20+
### Proposed Solution
21+
22+
<!--
23+
if you have any ideas or suggestions on how the feature could be implemented, please summarize them
24+
here, including any relevant code examples or concepts.
25+
-->
26+
27+
## Additional Information
28+
29+
<!-- any additional information that might help the developers evaluate your feature request -->
30+
31+
### Related Issues
32+
33+
<!-- are there any related issues? if yes, please list them here -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
______________________________________________________________________
2+
3+
## name: Propose an enhancement about: Suggest an improvement to this project's existing implementation, operations, or maintenance title: "refactor: ..." labels: enhancement assignees: ""
4+
5+
# Enhancement Proposal
6+
7+
<!-- a brief 1-3 sentence summary of the proposal -->
8+
9+
## Problem Statement
10+
11+
<!-- define the problem you are presenting and why it’s a problem that should be solved. -->
12+
13+
### Additional Details
14+
15+
<!-- any additional information that might help to clarify characteristics of the problem, its extent (degree or scope), and/or severity (level of risk, magnitude of impact, or amount of costs) -->
16+
17+
### Related Issues
18+
19+
<!-- are there any related issues? if yes, please list them here -->
20+
21+
## Proposed Solution
22+
23+
<!-- if you have any ideas or suggestions on how the problem could be solved, please summarize them here, including any relevant code examples or concepts. -->
24+
25+
### Acceptance Criteria
26+
27+
<!-- what criteria must be met in order to implement the proposed solution? -->

.github/actions/poe/action.yaml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: setup
2+
description: Execute steps to set up the project
3+
inputs:
4+
artifacts:
5+
description: The path to the artifacts to upload
6+
default: docs
7+
8+
poe-task:
9+
description: Execute this 'poe' task
10+
default: test
11+
12+
poetry-groups:
13+
description: The dependency groups to install with poetry
14+
default: ""
15+
16+
python-version:
17+
description: The version of Python to use
18+
default: "3.12"
19+
20+
runs:
21+
steps:
22+
- run: pipx install poetry
23+
shell: sh
24+
25+
- run: pipx inject poetry 'poethepoet[poetry_plugin]'
26+
shell: sh
27+
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ inputs.python-version }}
31+
32+
- id: poetry
33+
run: tr -d '\n' <<<"${{ inputs.poetry-groups }}" |
34+
tr -c '[:alnum:]' '-' |
35+
xargs printf 'groups=%s\n' >>"$GITHUB_OUTPUT"
36+
shell: bash
37+
38+
- uses: actions/cache@v4
39+
with:
40+
path: ~/.cache
41+
key: ${{ inputs.python-version }}-${{ steps.poetry.outputs.groups }}
42+
43+
- run: poetry
44+
${{ inputs.poetry-groups && format('install --only {0}', inputs.poetry-groups) || 'install'}}
45+
--all-extras
46+
--sync
47+
shell: sh
48+
49+
# note: 'poetry' is used to run 'poe' tasks because `poetry_command = ""` in 'pyproject.toml'
50+
# ref: https://github.com/ElucidBioimaging/back-end-health-checks/blob/452556c544c243ef829c469f0e11fcb0ebcbe4f0/pyproject.toml#L46
51+
- run: poetry ${{ inputs.poe-task }}
52+
shell: sh
53+
54+
- if: ${{ inputs.artifacts }}
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{ inputs.poe-task }}-${{ inputs.artifacts }}-py${{ inputs.python-version }}
58+
overwrite: true
59+
path: ${{ inputs.artifacts }}
60+
61+
- if: ${{ runner.debug }}
62+
run: git status
63+
shell: sh
64+
65+
using: composite

.github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
updates:
3+
- commit-message:
4+
prefix: deps
5+
prefix-development: chore(dev-deps)
6+
directory: /
7+
open-pull-requests-limit: 10
8+
package-ecosystem: pip
9+
reviewers: [bryant-finney]
10+
rebase-strategy: auto
11+
schedule:
12+
interval: daily
13+
14+
- package-ecosystem: github-actions
15+
directory: /
16+
schedule:
17+
interval: daily

.github/workflows/codeql.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: "26 4 * * *"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
# Runner size impacts CodeQL analysis time. To learn more, please see:
15+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
16+
# - https://gh.io/supported-runners-and-hardware-resources
17+
# - https://gh.io/using-larger-runners
18+
# Consider using larger runners for possible analysis time improvements.
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 360
21+
permissions:
22+
actions: read
23+
contents: read
24+
security-events: write
25+
26+
strategy:
27+
fail-fast: false
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: github/codeql-action/init@v3
33+
with:
34+
languages: python
35+
36+
- uses: github/codeql-action/analyze@v3
37+
with:
38+
category: "/language:python"
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Dependabot Auto
2+
on: pull_request
3+
4+
env:
5+
GH_TOKEN: ${{ github.token }}
6+
7+
jobs:
8+
metadata:
9+
if: github.actor == 'dependabot[bot]'
10+
11+
outputs:
12+
dependency-names: ${{ steps.metadata.outputs.dependency-names }}
13+
dependency-type: ${{ steps.metadata.outputs.dependency-type }}
14+
update-type: ${{ steps.metadata.outputs.update-type }}
15+
permissions:
16+
pull-requests: read
17+
18+
runs-on: ubuntu-latest
19+
steps:
20+
- id: metadata
21+
uses: dependabot/fetch-metadata@v2
22+
23+
auto-approve:
24+
env:
25+
APPROVE: gh pr review --approve ${{github.event.pull_request.html_url}} &&
26+
echo PR_APPROVED=true >>$GITHUB_OUTPUT
27+
28+
if: github.actor == 'dependabot[bot]'
29+
30+
needs: metadata
31+
permissions:
32+
pull-requests: write
33+
34+
runs-on: ubuntu-latest
35+
steps:
36+
# automatically approve dev dependencies and indirect dependencies that are not major updates
37+
- id: dev-or-indirect
38+
if: ( needs.metadata.outputs.dependency-type == 'direct:development' ||
39+
needs.metadata.outputs.dependency-type == 'indirect' ) &&
40+
needs.metadata.outputs.update-type != 'version-update:semver-major'
41+
run: eval "$APPROVE"
42+
43+
# automatically approve boto3 updates that are not major updates
44+
- id: boto3
45+
if: steps.dev-or-indirect.outputs.PR_APPROVED != 'true' &&
46+
needs.metadata.outputs.dependency-type == 'direct:production' &&
47+
contains(needs.metadata.outputs.dependency-names, 'boto3') &&
48+
needs.metadata.outputs.update-type != 'version-update:semver-major'
49+
run: eval "$APPROVE"
50+
51+
# post a comment that the PR needs to be reviewed
52+
- if: steps.dev-or-indirect.outputs.PR_APPROVED != 'true' &&
53+
steps.boto3.outputs.PR_APPROVED != 'true'
54+
uses: thollander/actions-comment-pull-request@v2
55+
with:
56+
message: |
57+
> [!IMPORTANT]
58+
> This PR should be reviewed by a maintainer.
59+
60+
auto-merge:
61+
if: github.actor == 'dependabot[bot]'
62+
63+
needs: metadata
64+
permissions:
65+
contents: write
66+
pull-requests: write
67+
68+
runs-on: ubuntu-latest
69+
steps:
70+
- run: gh pr merge --auto --merge ${{github.event.pull_request.html_url}}

.github/workflows/pr-poe-skipped.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Run this workflow to test Python code changes.
2+
name: 🎨 poe (PR)
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- "*"
8+
- "**"
9+
- "!**/*.py"
10+
- "!*.py"
11+
- "!.pre-commit-config.yaml"
12+
- "!poetry.lock"
13+
- "!pyproject.toml"
14+
- "!.github/workflows/pr-poe.yaml"
15+
- "!.github/actions/poe/*"
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- run: printf "skipping 'poe lint' job (no relevant changes) ✅"
21+
22+
test:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
py: ["3.8", "3.9", "3.10", "3.11", "3.12"]
27+
28+
steps:
29+
- run: printf "skipping 'poe test' job (no relevant changes) ✅"

.github/workflows/pr-poe.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Run this workflow to test Python code changes.
2+
name: 🎨 poe (PR)
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- "**/*.py"
8+
- "*.py"
9+
- .pre-commit-config.yaml
10+
- poetry.lock
11+
- pyproject.toml
12+
- .github/workflows/pr-poe.yaml
13+
- .github/actions/poe/*
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: ./.github/actions/poe
21+
with:
22+
poe-task: lint
23+
poetry-groups: main,build,test,lint
24+
25+
test:
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
py: ["3.8", "3.9", "3.10", "3.11", "3.12"]
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: ./.github/actions/poe
34+
with:
35+
poe-task: test
36+
poetry-groups: main,build,test
37+
python-version: ${{ matrix.py }}

0 commit comments

Comments
 (0)