Skip to content

Commit c82bd6a

Browse files
pedro-psbclaude
andauthored
chore: refactor CI workflows into reusable components (dynaconf#1359)
Restructure GitHub Actions workflows to improve modularity and maintainability: - Split main.yml into separate reusable workflow files (lint, build, test, docs, benchmark) - Rename workflows to follow consistent naming pattern (main__*, scheduled__*, smoke-test) - Update install-from-wheel action to install-from-artifact with parameterized artifact names - Remove deprecated netlify.yml workflow - Update Makefile docs command to use uv run - Add pip and uv caching to improve workflow performance Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent af50d05 commit c82bd6a

File tree

13 files changed

+204
-151
lines changed

13 files changed

+204
-151
lines changed

.github/actions/install-from-wheel/action.yml renamed to .github/actions/install-from-artifact/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
name: 'Install from wheel'
2-
description: 'Setup Python and install Dynaconf wheel with optional dependencies'
1+
name: 'Install from artifact'
2+
description: 'Setup Python and install Dynaconf wheel from artifact with optional dependencies'
33

44
inputs:
5+
artifact_in:
6+
description: 'Name of the artifact containing the distribution'
7+
required: true
58
dependencies:
69
description: 'Optional dependencies to install with the wheel'
710
required: false
@@ -21,9 +24,12 @@ runs:
2124
- uses: actions/setup-python@v5
2225
with:
2326
python-version: ${{ inputs.python-version }}
27+
cache: 'pip'
2428

2529
- name: Install uv
2630
uses: astral-sh/setup-uv@v6
31+
with:
32+
enable-cache: true
2733

2834
- name: Upgrade PIP
2935
if: inputs.os != 'Windows'
@@ -38,7 +44,7 @@ runs:
3844
- name: Download wheel
3945
uses: actions/download-artifact@v4
4046
with:
41-
name: dynaconf_dist
47+
name: ${{ inputs.artifact_in }}
4248
path: dist/
4349

4450
- name: Install from wheel (Unix)

.github/workflows/main.yml

Lines changed: 19 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the main branch
4+
# Triggers the workflow on push event for the master branch
85
push:
96
branches: [master]
107
paths-ignore: # run if anything different from these is modified
118
- "docs/**"
129
- "mkdocs.yml"
13-
10+
# Triggers the workflow on pull_request event for the master branch
1411
pull_request:
1512
branches: [master]
1613
paths-ignore:
1714
- "docs/**"
1815
- "mkdocs.yml"
19-
2016
# Allows you to run this workflow manually from the Actions tab
2117
workflow_dispatch:
2218

@@ -25,94 +21,43 @@ on:
2521
# let only the latest executing
2622
concurrency:
2723
group: ${{ github.workflow }}-${{ github.ref }}
28-
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
24+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
2925

3026
jobs:
31-
linter:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v4
35-
- uses: actions/setup-python@v5
36-
with:
37-
python-version: "3.13"
38-
- name: Install uv
39-
uses: astral-sh/setup-uv@v6
40-
- name: Install and lint
41-
run: make clean ciinstall run-pre-commit
27+
docs:
28+
uses: ./.github/workflows/main__build-docs.yml
29+
30+
lint:
31+
uses: ./.github/workflows/main__lint.yml
4232

4333
build:
44-
needs: linter
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: actions/checkout@v4
48-
- uses: actions/setup-python@v5
49-
with:
50-
# build requires the lowerbound python we support
51-
python-version: "3.9"
52-
- name: Install uv
53-
uses: astral-sh/setup-uv@v6
54-
- name: Install build dependencies
55-
run: |
56-
uv export --no-hashes --only-group release > requirements-release.txt
57-
pip install --user -r requirements-release.txt
58-
- name: Build wheel
59-
run: make dist
60-
- name: Upload wheel artifact
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: dynaconf_dist
64-
path: dist/
65-
if-no-files-found: "error"
66-
overwrite: true
67-
retention-days: 1
68-
34+
needs: lint
35+
uses: ./.github/workflows/main__build.yml
36+
with:
37+
python_version: "3.9"
38+
artifact_out: "dynaconf_dist"
39+
6940
tests:
7041
needs: build
71-
uses: ./.github/workflows/test.yml
42+
uses: ./.github/workflows/main__test.yml
7243
with:
44+
artifact_in: "dynaconf_dist"
7345
python_minimal: '["3.9", "3.13"]'
7446
python_full: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
7547
python_latest: '3.13'
7648
secrets: inherit
7749

7850
benchmark:
79-
runs-on: ubuntu-latest
8051
needs: build
8152
if: github.event_name == 'pull_request'
82-
steps:
83-
- uses: actions/checkout@v4
84-
with:
85-
fetch-depth: 0 # full history
86-
ref: ${{ github.event.pull_request.head.sha }} # get PR head instead of GH merge commit
87-
88-
- name: Setup upstream remote
89-
run: |
90-
git remote add upstream https://github.com/dynaconf/dynaconf.git
91-
git fetch upstream
92-
93-
- name: Install uv
94-
uses: astral-sh/setup-uv@v3
95-
with:
96-
version: "latest"
97-
98-
- name: Run benchmarks
99-
run: |
100-
make bench
101-
git log --oneline refs/remotes/upstream/master~..HEAD
102-
103-
- name: Upload benchmark results
104-
uses: actions/upload-artifact@v4
105-
with:
106-
name: benchmark-results
107-
path: tmp-bench/
108-
if-no-files-found: "warn"
109-
retention-days: 7
53+
uses: ./.github/workflows/main__benchmark.yml
11054

11155
checkpoint:
11256
runs-on: ubuntu-latest
11357
needs:
114-
- linter
58+
- lint
11559
- build
60+
- docs
11661
- tests
11762
steps:
11863
- name: All tests has passed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Benchmark
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
benchmark:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0 # full history
13+
ref: ${{ github.event.pull_request.head.sha }} # get PR head instead of GH merge commit
14+
15+
- name: Setup upstream remote
16+
run: |
17+
git remote add upstream https://github.com/dynaconf/dynaconf.git
18+
git fetch upstream
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v6
22+
with:
23+
version: "latest"
24+
25+
- name: Run benchmarks
26+
run: |
27+
make bench
28+
git log --oneline refs/remotes/upstream/master~..HEAD
29+
30+
- name: Upload benchmark results
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: benchmark-results
34+
path: tmp-bench/
35+
if-no-files-found: "warn"
36+
retention-days: 7
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Documentation
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dynaconf_ref:
7+
description: "Git ref to checkout (branch, tag, or commit)"
8+
required: false
9+
type: string
10+
default: ""
11+
artifact_out:
12+
description: "Name for the uploaded documentation artifact"
13+
required: false
14+
type: string
15+
default: "docs-site"
16+
17+
jobs:
18+
docs-build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v6
27+
28+
- name: Customize checkout to use
29+
if: ${{ inputs.dynaconf_ref != '' }}
30+
run: |
31+
git checkout ${{ inputs.dynaconf_ref }}
32+
33+
- name: Build documentation
34+
run: |
35+
make docs
36+
37+
- name: Upload documentation artifact
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: ${{ inputs.artifact_out }}
41+
path: site/
42+
retention-days: 1

.github/workflows/main__build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Distribution
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python_version:
7+
description: "Python version to use for building"
8+
required: false
9+
type: string
10+
default: "3.9"
11+
artifact_out:
12+
description: "Name for the uploaded artifact"
13+
required: true
14+
type: string
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
with:
23+
# build requires the lowerbound python we support
24+
python-version: ${{ inputs.python_version }}
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v6
27+
- name: Install build dependencies
28+
run: |
29+
uv export --no-hashes --only-group release > requirements-release.txt
30+
pip install --user -r requirements-release.txt
31+
- name: Build wheel
32+
run: make dist
33+
- name: Run health check
34+
run: .github/scripts/dist-health-check.sh
35+
- name: Upload wheel artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: ${{ inputs.artifact_out }}
39+
path: dist/
40+
if-no-files-found: "error"
41+
overwrite: true
42+
retention-days: 1

.github/workflows/main__lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: "3.13"
14+
cache: 'pip'
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
17+
with:
18+
enable-cache: true
19+
- name: Install and lint
20+
run: make clean ciinstall run-pre-commit

0 commit comments

Comments
 (0)