Skip to content

Commit d8e10c7

Browse files
thisthatbeeme1mr
andauthored
ci: introduce Release Please and PR linting workflows (#38)
Signed-off-by: Michael Beemer <[email protected]> Signed-off-by: Giovanni Liva <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent 85661ff commit d8e10c7

File tree

7 files changed

+189
-15
lines changed

7 files changed

+189
-15
lines changed

.github/workflows/lint-pr.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,38 @@ on:
1313
- synchronize
1414

1515
permissions:
16-
pull-requests: read
16+
pull-requests: write
1717

1818
jobs:
1919
main:
2020
name: Validate PR title
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: amannn/action-semantic-pull-request@v5
24+
id: lint_pr_title
2425
env:
2526
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- uses: marocchino/sticky-pull-request-comment@v2
29+
# When the previous steps fails, the workflow would stop. By adding this
30+
# condition you can continue the execution with the populated error message.
31+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
32+
with:
33+
header: pr-title-lint-error
34+
message: |
35+
Hey there and thank you for opening this pull request! 👋🏼
36+
37+
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
38+
39+
Details:
40+
41+
```
42+
${{ steps.lint_pr_title.outputs.error_message }}
43+
```
44+
45+
# Delete a previous comment when the issue has been resolved
46+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
47+
uses: marocchino/sticky-pull-request-comment@v2
48+
with:
49+
header: pr-title-lint-error
50+
delete: true

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Run Release Please
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
15+
# Release-please creates a PR that tracks all changes
16+
steps:
17+
- uses: google-github-actions/release-please-action@v3
18+
id: release
19+
with:
20+
command: manifest
21+
token: ${{secrets.GITHUB_TOKEN}}
22+
default-branch: main
23+
signoff: "OpenFeature Bot <[email protected]>"
24+
- name: Dump Release Please Output
25+
env:
26+
RELEASE_PLEASE_OUTPUT: ${{ toJson(steps.release.outputs) }}
27+
run: |
28+
echo "$RELEASE_PLEASE_OUTPUT"
29+
outputs:
30+
release_created: ${{ steps.release.outputs.releases_created }}
31+
all: ${{ toJSON(steps.release.outputs) }}
32+
paths_released: ${{ steps.release.outputs.paths_released }}
33+
34+
pypi-release:
35+
needs: release-please
36+
runs-on: ubuntu-latest
37+
if: ${{ needs.release-please.outputs.release_created }}
38+
strategy:
39+
matrix:
40+
path: ${{ fromJSON(needs.release-please.outputs.paths_released) }}
41+
environment: release
42+
permissions:
43+
# IMPORTANT: this permission is mandatory for trusted publishing to pypi
44+
id-token: write
45+
container:
46+
image: "python:3.12"
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
submodules: recursive
52+
53+
- name: Upgrade pip
54+
run: pip install --upgrade pip
55+
56+
- name: Install hatch
57+
run: pip install hatch
58+
59+
- name: Build a binary wheel and a source tarball
60+
run: hatch build
61+
working-directory: ${{ matrix.path }}
62+
63+
- name: Publish a Python distribution to PyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
packages-dir: ${{ matrix.path }}

.release-please-manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"hooks/openfeature-hooks-opentelemetry": "0.1.0",
3+
"providers/openfeature-provider-flagd": "0.1.0"
4+
}

CONTRIBUTING.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ We use `pytest` for our unit testing, making use of `parametrized` to inject cas
2828

2929
These are planned once the SDK has been stabilized and a Flagd provider implemented. At that point, we will utilize the [gherkin integration tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) to validate against a live, seeded Flagd instance.
3030

31-
### Packaging
32-
33-
We publish to the PyPI repository, where you can find each individual package:
34-
35-
- [openfeature-provider-flagd](https://pypi.org/project/openfeature-provider-flagd/)
36-
- [openfeature-hooks-opentelemetry](https://pypi.org/project/openfeature-hooks-opentelemetry/)
37-
3831
## Pull Request
3932

4033
All contributions to the OpenFeature project are welcome via GitHub pull requests.
@@ -48,7 +41,7 @@ git clone https://github.com/open-feature/python-sdk-contrib.git openfeature-pyt
4841
Navigate to the repository folder
4942

5043
```bash
51-
cd openfeature-python-sdk-contrib
44+
cd python-sdk-contrib
5245
```
5346

5447
Add your fork as an origin

hooks/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# OpenFeature Python Hooks
2+
23
Hooks are a mechanism whereby application developers can add arbitrary behavior to flag evaluation.
3-
They operate similarly to middleware in many web frameworks. Please see the
4-
[spec](https://openfeature.dev/specification/sections/hooks) for more details.
4+
They operate similarly to middleware in many web frameworks.
5+
Please see the [spec](https://openfeature.dev/specification/sections/hooks) for more details.

providers/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# OpenFeature Python Providers
2-
Providers are responsible for performing flag evaluation. They provide an abstraction between the underlying
3-
flag management system and OpenFeature itself. This allows providers to be changed without requiring a major
4-
code refactor. Please see the [spec]("https://github.com/open-feature/spec/blob/main/specification/sections/02-providers.md")
5-
for more details.
2+
3+
Providers are responsible for performing flag evaluation.
4+
They provide an abstraction between the underlying flag management system and OpenFeature itself.
5+
This allows providers to be changed without requiring a major code refactor.
6+
Please see the [spec](https://openfeature.dev/specification/sections/providers) for more details.

release-please-config.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"bootstrap-sha": "1cef37c5d8c7d97ee52a8e6b71f12150063b8503",
3+
"separate-pull-requests": true,
4+
"release-type": "python",
5+
"bump-minor-pre-major": true,
6+
"bump-patch-for-minor-pre-major": true,
7+
"include-component-in-tag": true,
8+
"tag-separator": "/",
9+
"packages": {
10+
"providers/openfeature-provider-flagd": {
11+
"package-name": "providers/flagd",
12+
"bump-minor-pre-major": true,
13+
"bump-patch-for-minor-pre-major": true,
14+
"versioning": "default",
15+
"extra-files": [
16+
"README.md"
17+
]
18+
},
19+
"hooks/openfeature-hooks-opentelemetry": {
20+
"package-name": "hooks/opentelemetry",
21+
"bump-minor-pre-major": true,
22+
"bump-patch-for-minor-pre-major": true,
23+
"versioning": "default",
24+
"extra-files": [
25+
"README.md"
26+
]
27+
}
28+
},
29+
"changelog-sections": [
30+
{
31+
"type": "fix",
32+
"section": "🐛 Bug Fixes"
33+
},
34+
{
35+
"type": "feat",
36+
"section": "✨ New Features"
37+
},
38+
{
39+
"type": "chore",
40+
"section": "🧹 Chore"
41+
},
42+
{
43+
"type": "docs",
44+
"section": "📚 Documentation"
45+
},
46+
{
47+
"type": "perf",
48+
"section": "🚀 Performance"
49+
},
50+
{
51+
"type": "build",
52+
"hidden": true,
53+
"section": "🛠️ Build"
54+
},
55+
{
56+
"type": "deps",
57+
"section": "📦 Dependencies"
58+
},
59+
{
60+
"type": "ci",
61+
"hidden": true,
62+
"section": "🚦 CI"
63+
},
64+
{
65+
"type": "refactor",
66+
"section": "🔄 Refactoring"
67+
},
68+
{
69+
"type": "revert",
70+
"section": "🔙 Reverts"
71+
},
72+
{
73+
"type": "style",
74+
"hidden": true,
75+
"section": "🎨 Styling"
76+
},
77+
{
78+
"type": "test",
79+
"hidden": true,
80+
"section": "🧪 Tests"
81+
}
82+
],
83+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
84+
}

0 commit comments

Comments
 (0)