Skip to content

Commit 973741e

Browse files
committed
ci: harden generated-artifact checks and pre-commit flow
1 parent 9fba9de commit 973741e

File tree

6 files changed

+74
-23
lines changed

6 files changed

+74
-23
lines changed

.github/workflows/prerequisites.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,21 @@ jobs:
9090
env:
9191
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9292
- name: Generate schema
93-
run: make schema
93+
run: make schema PULUMI_CONVERT=0
94+
- name: Check schema worktree clean
95+
uses: pulumi/git-status-check-action@v1
96+
- name: Regenerate SDKs
97+
run: make generate_sdks PULUMI_CONVERT=0
98+
- name: Check SDK worktree clean
99+
uses: pulumi/git-status-check-action@v1
100+
with:
101+
# Keep these in sync with build_sdk.yml to avoid false positives on
102+
# provider-version derived files.
103+
allowed-changes: |
104+
sdk/**/pulumi-plugin.json
105+
sdk/go/**/pulumiUtilities.go
106+
sdk/nodejs/package.json
107+
sdk/python/pyproject.toml
94108
- name: Build provider binary
95109
run: make provider
96110
- name: Unit-test provider code

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
minimum_pre_commit_version: "3.0.0"
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: generated-artifacts
6+
name: Ensure generated artifacts are in sync
7+
entry: ./scripts/precommit-check-generated.sh
8+
language: system
9+
pass_filenames: false
10+
files: ^(provider/|schema/|sdk/|Makefile|\.ci-mgmt\.yaml|README\.md|examples/)

CONTRIBUTING.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md#developing) for det
2020

2121
## Committing Generated Code
2222

23-
You must generate and check in the SDKs on each pull request containing a code change, e.g. adding a new resource to `resources.go`.
23+
You must generate and check in the schema and SDKs on each pull request containing provider changes.
2424

25-
1. Run `make build_sdks` from the root of this repository
26-
1. Open a pull request containing all changes
27-
1. *Note:* If a large number of seemingly-unrelated diffs are produced by `make build_sdks` (for example, lots of changes to comments unrelated to the change you are making), ensure that the latest dependencies for the provider are installed by running `go mod tidy` in the `provider/` directory of this repository.
25+
1. Install [pre-commit](https://pre-commit.com/) and run: `pre-commit install`
26+
1. Regenerate committed artifacts before opening a PR:
27+
- `make schema PULUMI_CONVERT=0`
28+
- `make generate_sdks PULUMI_CONVERT=0`
29+
1. Open a pull request containing all generated changes.
30+
1. If a large number of unrelated diffs are produced, run `go mod tidy` in `provider/` and regenerate.
31+
32+
The local pre-commit hook runs generation checks only when relevant files are staged. Use `SKIP=generated-artifacts git commit ...` to bypass it for one commit.
2833

2934
## Running Integration Tests
3035

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO_ROOT="$(git rev-parse --show-toplevel)"
5+
cd "$REPO_ROOT"
6+
7+
echo "[pre-commit] Regenerating schema and SDKs to verify generated files are in sync..."
8+
make schema PULUMI_CONVERT=0
9+
make generate_sdks PULUMI_CONVERT=0
10+
11+
if ! git diff --quiet -- provider/cmd/pulumi-resource-logfire/schema.json provider/cmd/pulumi-resource-logfire/schema-embed.json sdk; then
12+
echo "[pre-commit] Generated artifacts changed after regeneration."
13+
echo "[pre-commit] Run the following and re-commit:"
14+
echo " git add provider/cmd/pulumi-resource-logfire/schema.json provider/cmd/pulumi-resource-logfire/schema-embed.json sdk"
15+
exit 1
16+
fi

sdk/python/README.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/python/pulumi_logfire/_inputs.py

Lines changed: 22 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)