Skip to content

Commit 221cee2

Browse files
authored
Merge pull request #3 from webyneter/integrate-dependabot
Integrate Dependabot
2 parents 6b2eea1 + 479746a commit 221cee2

File tree

10 files changed

+622
-73
lines changed

10 files changed

+622
-73
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Generate Variant Action
2+
#
3+
# Generates a project from the cookiecutter template using a variant
4+
# defined in variants.json. Optionally installs dependencies.
5+
6+
name: Generate Variant
7+
description: Generate a project variant from variants.json
8+
9+
inputs:
10+
variant-name:
11+
description: Name of the variant in variants.json
12+
required: true
13+
output-name:
14+
description: Name for the generated project (defaults to variant-name)
15+
required: false
16+
default: ""
17+
clean:
18+
description: Remove existing project directory before generation
19+
required: false
20+
default: "false"
21+
install:
22+
description: Install dependencies after generation
23+
required: false
24+
default: "true"
25+
cache-key-suffix:
26+
description: Suffix for uv cache key
27+
required: false
28+
default: ""
29+
docker:
30+
description: Override Docker support (if not set, reads from variant in variants.json)
31+
required: false
32+
default: ""
33+
34+
outputs:
35+
project-path:
36+
description: Path to the generated project
37+
value: ${{ steps.generate.outputs.project-path }}
38+
39+
runs:
40+
using: composite
41+
steps:
42+
- name: Restore uv cache
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.cache/uv
46+
key: uv-${{ inputs.variant-name }}${{ inputs.cache-key-suffix }}-${{ hashFiles('variants.json') }}
47+
restore-keys: |
48+
uv-${{ inputs.variant-name }}${{ inputs.cache-key-suffix }}-
49+
50+
- name: Generate project
51+
id: generate
52+
shell: bash
53+
env:
54+
VARIANT_NAME: ${{ inputs.variant-name }}
55+
OUTPUT_NAME: ${{ inputs.output-name }}
56+
CLEAN: ${{ inputs.clean }}
57+
DOCKER: ${{ inputs.docker }}
58+
run: |
59+
variant=$(jq -r --arg name "${VARIANT_NAME}" '.variants[] | select(.name == $name)' variants.json)
60+
61+
if [[ -z "${variant}" || "${variant}" == "null" ]]; then
62+
echo "Error: variant '${VARIANT_NAME}' not found in variants.json" >&2
63+
exit 1
64+
fi
65+
66+
project_name="${OUTPUT_NAME:-${VARIANT_NAME}}"
67+
68+
clean_flag=""
69+
if [[ "${CLEAN}" == "true" ]]; then
70+
clean_flag="--clean"
71+
fi
72+
73+
docker_value="${DOCKER}"
74+
if [[ -z "${docker_value}" ]]; then
75+
docker_value=$(echo "${variant}" | jq -r '.docker // true')
76+
fi
77+
78+
./scripts/generate.bash ${clean_flag} \
79+
--name "${project_name}" \
80+
--sentry "$(echo "${variant}" | jq -r '.sentry')" \
81+
--async "$(echo "${variant}" | jq -r '.async')" \
82+
--cli "$(echo "${variant}" | jq -r '.cli')" \
83+
--web "$(echo "${variant}" | jq -r '.web')" \
84+
--api "$(echo "${variant}" | jq -r '.api')" \
85+
--api-auth "$(echo "${variant}" | jq -r '.api_auth')" \
86+
--api-lambda "$(echo "${variant}" | jq -r '.api_lambda')" \
87+
--api-lambda-tracing "$(echo "${variant}" | jq -r '.api_lambda_tracing')" \
88+
--api-lambda-metrics "$(echo "${variant}" | jq -r '.api_lambda_metrics')" \
89+
--api-pagination "$(echo "${variant}" | jq -r '.api_pagination')" \
90+
--api-versioning "$(echo "${variant}" | jq -r '.api_versioning')" \
91+
--docker "${docker_value}"
92+
93+
echo "project-path=.test-output/${project_name}" >> "${GITHUB_OUTPUT}"
94+
95+
- name: Install dependencies
96+
if: inputs.install == 'true'
97+
shell: bash
98+
run: ./scripts/install.bash "${{ steps.generate.outputs.project-path }}"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Setup Environment Action
2+
#
3+
# Sets up the development environment for cookiecutter template operations.
4+
# Installs Python, uv, and cookiecutter.
5+
#
6+
# Note: This action does NOT include checkout. The workflow must checkout first
7+
# before using this action.
8+
9+
name: Setup Environment
10+
description: Set up Python, uv, and cookiecutter for template operations
11+
12+
inputs:
13+
python-version:
14+
description: Python version to use
15+
required: false
16+
default: "3.12"
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- uses: actions/setup-python@v6
22+
with:
23+
python-version: ${{ inputs.python-version }}
24+
25+
- uses: astral-sh/setup-uv@v7
26+
27+
- name: Install cookiecutter
28+
shell: bash
29+
run: pipx install cookiecutter

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/reference"
5+
schedule:
6+
interval: "daily"
7+
commit-message:
8+
prefix: "chore(deps)"
9+
labels:
10+
- "dependencies"
11+
- "python"
12+
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: "daily"
17+
commit-message:
18+
prefix: "chore(deps)"
19+
labels:
20+
- "dependencies"
21+
- "github-actions"

.github/workflows/ci.yml

Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# CI Workflow
2+
#
3+
# Purpose: Tests all template variants on push to main.
4+
# Generates each variant defined in variants.json and runs lint + tests
5+
# to ensure all feature combinations work correctly.
6+
#
7+
# Trigger: Push to main branch
8+
19
name: CI
210

311
on:
@@ -16,7 +24,7 @@ jobs:
1624
matrix: ${{ steps.set-matrix.outputs.matrix }}
1725
names: ${{ steps.set-matrix.outputs.names }}
1826
steps:
19-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2028
- id: set-matrix
2129
run: |
2230
echo "matrix=$(jq -c '.variants' variants.json)" >> "${GITHUB_OUTPUT}"
@@ -31,63 +39,21 @@ jobs:
3139
matrix:
3240
include: ${{ fromJSON(needs.load-variants.outputs.matrix) }}
3341
steps:
34-
- uses: actions/checkout@v4
35-
36-
- uses: actions/setup-python@v5
37-
with:
38-
python-version: "3.12"
42+
- uses: actions/checkout@v6
3943

40-
- uses: astral-sh/setup-uv@v4
44+
- uses: ./.github/actions/setup-environment
4145

42-
- name: Install cookiecutter
43-
run: pipx install cookiecutter
44-
45-
- name: Restore uv cache
46-
uses: actions/cache@v4
46+
- uses: ./.github/actions/generate-variant
47+
id: generate
4748
with:
48-
path: ~/.cache/uv
49-
key: uv-${{ matrix.name }}-${{ hashFiles('variants.json') }}
50-
restore-keys: |
51-
uv-${{ matrix.name }}-
52-
53-
- name: Generate project
54-
env:
55-
VARIANT_NAME: ${{ matrix.name }}
56-
SENTRY: ${{ matrix.sentry }}
57-
ASYNC: ${{ matrix.async }}
58-
CLI: ${{ matrix.cli }}
59-
WEB: ${{ matrix.web }}
60-
API: ${{ matrix.api }}
61-
API_AUTH: ${{ matrix.api_auth }}
62-
API_LAMBDA: ${{ matrix.api_lambda }}
63-
API_LAMBDA_TRACING: ${{ matrix.api_lambda_tracing }}
64-
API_LAMBDA_METRICS: ${{ matrix.api_lambda_metrics }}
65-
API_PAGINATION: ${{ matrix.api_pagination }}
66-
API_VERSIONING: ${{ matrix.api_versioning }}
67-
run: |
68-
./scripts/generate.bash \
69-
--name "test-${VARIANT_NAME}" \
70-
--sentry "${SENTRY}" \
71-
--async "${ASYNC}" \
72-
--cli "${CLI}" \
73-
--web "${WEB}" \
74-
--api "${API}" \
75-
--api-auth "${API_AUTH}" \
76-
--api-lambda "${API_LAMBDA}" \
77-
--api-lambda-tracing "${API_LAMBDA_TRACING}" \
78-
--api-lambda-metrics "${API_LAMBDA_METRICS}" \
79-
--api-pagination "${API_PAGINATION}" \
80-
--api-versioning "${API_VERSIONING}" \
81-
--docker "true"
82-
83-
- name: Install dependencies
84-
run: ./scripts/install.bash ".test-output/test-${{ matrix.name }}"
49+
variant-name: ${{ matrix.name }}
50+
output-name: test-${{ matrix.name }}
8551

8652
- name: Upload project artifact
8753
uses: actions/upload-artifact@v4
8854
with:
8955
name: project-${{ matrix.name }}
90-
path: .test-output/test-${{ matrix.name }}
56+
path: ${{ steps.generate.outputs.project-path }}
9157
retention-days: 1
9258

9359
lint:
@@ -99,13 +65,9 @@ jobs:
9965
matrix:
10066
variant: ${{ fromJSON(needs.load-variants.outputs.names) }}
10167
steps:
102-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v6
10369

104-
- uses: actions/setup-python@v5
105-
with:
106-
python-version: "3.12"
107-
108-
- uses: astral-sh/setup-uv@v4
70+
- uses: ./.github/actions/setup-environment
10971

11072
- name: Restore uv cache
11173
uses: actions/cache@v4
@@ -136,13 +98,9 @@ jobs:
13698
matrix:
13799
variant: ${{ fromJSON(needs.load-variants.outputs.names) }}
138100
steps:
139-
- uses: actions/checkout@v4
140-
141-
- uses: actions/setup-python@v5
142-
with:
143-
python-version: "3.12"
101+
- uses: actions/checkout@v6
144102

145-
- uses: astral-sh/setup-uv@v4
103+
- uses: ./.github/actions/setup-environment
146104

147105
- name: Restore uv cache
148106
uses: actions/cache@v4
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Generate Requirements Workflow
2+
#
3+
# Purpose: Regenerates reference/requirements.txt when template dependencies change.
4+
# This keeps the requirements.txt in sync with the template's pyproject.toml and uv.lock,
5+
# allowing Dependabot to scan for outdated dependencies.
6+
#
7+
# Trigger: Push to main with changes to template's pyproject.toml or uv.lock
8+
9+
name: Generate Requirements
10+
11+
on:
12+
push:
13+
branches: [main]
14+
paths:
15+
- "\\{\\{cookiecutter.project_name\\}\\}/pyproject.toml"
16+
- "\\{\\{cookiecutter.project_name\\}\\}/**/uv.lock"
17+
workflow_dispatch:
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
generate-requirements:
28+
runs-on: ubuntu-22.04
29+
timeout-minutes: 15
30+
steps:
31+
- uses: actions/checkout@v6
32+
with:
33+
fetch-depth: 0
34+
35+
- uses: ./.github/actions/setup-environment
36+
37+
- uses: ./.github/actions/generate-variant
38+
id: generate
39+
with:
40+
variant-name: full
41+
clean: "true"
42+
43+
- name: Export requirements.txt
44+
run: |
45+
cd ${{ steps.generate.outputs.project-path }}
46+
uv export --frozen --no-hashes --no-emit-project > ../../reference/requirements.txt
47+
48+
- name: Check for changes
49+
id: check
50+
run: |
51+
if git diff --quiet reference/requirements.txt; then
52+
echo "changes=false" >> "${GITHUB_OUTPUT}"
53+
else
54+
echo "changes=true" >> "${GITHUB_OUTPUT}"
55+
fi
56+
57+
- name: Commit and push
58+
if: steps.check.outputs.changes == 'true'
59+
run: |
60+
git config user.name "github-actions[bot]"
61+
git config user.email "github-actions[bot]@users.noreply.github.com"
62+
git add reference/requirements.txt
63+
git commit -m "chore(deps): regenerate requirements.txt from template"
64+
git push

0 commit comments

Comments
 (0)