Skip to content

Commit 9cddfbc

Browse files
authored
Merge remote-tracking branch 'origin/main' into worktree-docs-contributing-tools
2 parents d854060 + 68f576a commit 9cddfbc

52 files changed

Lines changed: 3973 additions & 125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-push.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Build and Push
22

33
on:
44
workflow_call:
5+
inputs:
6+
version:
7+
description: "Version tag for the image (e.g. v1.2.3)"
8+
required: false
9+
type: string
10+
outputs:
11+
digest:
12+
description: "The published image manifest digest (sha256:...)"
13+
value: ${{ jobs.merge.outputs.digest }}
514

615
env:
716
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
@@ -33,7 +42,11 @@ jobs:
3342
- name: Get Build timestamp and branch name
3443
run: |
3544
echo "BUILD_TIMESTAMP=$(date +'%s')" >> $GITHUB_ENV
36-
echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV
45+
if [[ -n "${{ inputs.version }}" ]]; then
46+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
47+
else
48+
echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV
49+
fi
3750
3851
- name: Docker tags & labels
3952
id: meta
@@ -46,6 +59,7 @@ jobs:
4659
# - type=sha,format=long,prefix= -> commit sha
4760
tags: |
4861
type=raw,${{ env.VERSION }}
62+
type=raw,latest,enable=${{ github.ref == 'refs/heads/main' }}
4963
type=ref,event=tag
5064
type=sha,format=long,prefix=
5165
@@ -94,6 +108,8 @@ jobs:
94108
runs-on: ubuntu-latest
95109
needs:
96110
- build
111+
outputs:
112+
digest: ${{ steps.inspect.outputs.digest }}
97113
steps:
98114
- name: Download digests
99115
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
@@ -107,7 +123,11 @@ jobs:
107123

108124
- name: Get branch name
109125
run: |
110-
echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV
126+
if [[ -n "${{ inputs.version }}" ]]; then
127+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
128+
else
129+
echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV
130+
fi
111131
112132
- name: Docker tags & labels
113133
id: meta
@@ -120,6 +140,7 @@ jobs:
120140
# - type=sha,format=long,prefix= -> commit sha
121141
tags: |
122142
type=raw,${{ env.VERSION }}
143+
type=raw,latest,enable=${{ github.ref == 'refs/heads/main' }}
123144
type=ref,event=tag
124145
type=sha,format=long,prefix=
125146
@@ -138,6 +159,9 @@ jobs:
138159
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
139160
140161
- name: Inspect image
162+
id: inspect
141163
if: env.REGISTRY_PUSH == 'true'
142164
run: |
143165
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
166+
DIGEST=$(docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | grep -m1 '^Digest:' | awk '{print $2}')
167+
echo "digest=$DIGEST" >> $GITHUB_OUTPUT

.github/workflows/docs.yaml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
name: Documentation
22
on:
3+
workflow_call:
4+
inputs:
5+
version:
6+
description: 'Version to deploy (e.g. v1.2.3)'
7+
type: string
8+
required: true
39
push:
410
branches:
511
- main
6-
tags:
7-
- v*
812
pull_request:
913
branches:
1014
- main
@@ -22,18 +26,12 @@ jobs:
2226
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2327
with:
2428
fetch-depth: 0 # Fetch all branches to include 'gh-pages' branch
25-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
29+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990
2630
with:
27-
python-version: 3.x
28-
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
29-
with:
30-
key: mkdocs-material-${{ github.ref }}
31-
path: .cache
32-
restore-keys: |
33-
mkdocs-material-
31+
enable-cache: true
3432

3533
- name: Install dependencies
36-
run: pip install mkdocs-material mike
34+
run: uv sync --frozen
3735

3836
- name: Lint Markdown files
3937
uses: DavidAnson/markdownlint-cli2-action@ce4853d43830c74c1753b39f3cf40f71c2031eb9 # v23
@@ -42,7 +40,7 @@ jobs:
4240
globs: 'docs/**/*.md'
4341

4442
- name: Build pages
45-
run: mkdocs build --strict
43+
run: uv run mkdocs build --strict
4644

4745
- name: Configure Git user
4846
run: |
@@ -51,10 +49,10 @@ jobs:
5149
5250
- name: Deploy pages (unstable)
5351
if: github.ref == 'refs/heads/main'
54-
run: mike deploy --push --update-aliases unstable
52+
run: uv run mike deploy --push --update-aliases unstable
5553

5654
- name: Deploy pages (new release)
57-
if: startsWith(github.ref, 'refs/tags/')
55+
if: github.event_name == 'workflow_call'
5856
run: |
59-
mike deploy --push --update-aliases ${{ github.ref_name }} latest
60-
echo "Deployed version ${{ github.ref_name }} to GitHub Pages"
57+
uv run mike deploy --push --update-aliases ${{ inputs.version }} latest
58+
echo "Deployed version ${{ inputs.version }} to GitHub Pages"

.github/workflows/helm.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
name: Helm CI/CD
22

33
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Version to deploy (e.g. v1.2.3)'
8+
type: string
9+
required: true
410
push:
511
branches:
612
- main
7-
tags:
8-
- v*
913
pull_request:
1014
branches:
1115
- main
1216
paths:
1317
- ".github/workflows/helm.yaml"
1418
- "deploy/charts/**"
15-
1619
env:
1720
CHART_NAME: burrito
1821
CHART_PATH: ./deploy/charts/burrito
@@ -47,9 +50,9 @@ jobs:
4750
if [[ ${{ github.event_name }} == 'pull_request' || ${{ github.event_name }} == 'push' && ${{ github.ref_type }} == 'branch' ]]; then
4851
echo "VERSION=$(echo $CURRENT_VERSION-${{ github.sha }})" >> $GITHUB_ENV
4952
echo "APP_VERSION=${{ github.sha }}" >> $GITHUB_ENV
50-
elif [[ ${{ github.event_name }} == 'push' && ${{ github.ref_type }} == 'tag' ]]; then
51-
echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/v//')" >> $GITHUB_ENV
52-
echo "APP_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
53+
elif [[ ${{ github.event_name }} == 'workflow_call' ]]; then
54+
echo "VERSION=$(echo ${{ inputs.version }} | sed 's/v//')" >> $GITHUB_ENV
55+
echo "APP_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
5356
else
5457
echo "Unsupported event type"
5558
exit 1

.github/workflows/release.yaml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (e.g. v1.2.3)"
8+
required: true
9+
type: string
710

811
permissions:
912
contents: write
1013
packages: write
1114
pull-requests: write
1215

1316
jobs:
17+
build-and-push:
18+
uses: ./.github/workflows/build-and-push.yaml
19+
with:
20+
version: ${{ inputs.version }}
21+
permissions:
22+
packages: write
23+
1424
version:
1525
runs-on: ubuntu-latest
1626
environment: production
27+
needs: build-and-push
1728
env:
1829
CHART_PATH: ./deploy/charts/burrito
1930
steps:
@@ -24,28 +35,30 @@ jobs:
2435
ref: main
2536

2637
- name: Bump VERSION file
27-
run: |
28-
echo ${{ github.ref_name }} > VERSION
38+
run: echo "${{ inputs.version }}" > VERSION
2939

3040
- name: Bump Helm Chart versions
3141
run: |
32-
export CHART_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//g')
33-
export APP_VERSION=${{ github.ref_name }}
42+
export CHART_VERSION=$(echo "${{ inputs.version }}" | sed 's/v//g')
43+
export APP_VERSION="${{ inputs.version }}"
3444
yq -i '.version = env(CHART_VERSION)' $CHART_PATH/Chart.yaml
3545
yq -i '.appVersion = env(APP_VERSION)' $CHART_PATH/Chart.yaml
3646
37-
- name: Commit version to repository and open PR
47+
- name: Pin image tag and digest in values.yaml
48+
run: |
49+
export IMAGE_TAG="${{ inputs.version }}@${{ needs.build-and-push.outputs.digest }}"
50+
yq -i '.global.deployment.image.tag = env(IMAGE_TAG)' $CHART_PATH/values.yaml
51+
yq -i '.config.burrito.runner.image.tag = env(IMAGE_TAG)' $CHART_PATH/values.yaml
52+
53+
- name: Commit and open PR
3854
env:
3955
GH_TOKEN: ${{ github.token }}
4056
run: |
41-
BRANCH_NAME="bump-version-${{ github.ref_name }}"
57+
BRANCH_NAME="bump-version-${{ inputs.version }}"
4258
git config user.name "github-actions[bot]"
4359
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
4460
git add .
4561
git switch -c $BRANCH_NAME
46-
git commit -m "chore(release): bump version to ${{ github.ref_name }}"
62+
git commit -m "chore(release): bump version to ${{ inputs.version }}"
4763
git push origin $BRANCH_NAME
4864
gh pr create --fill --base main --head $BRANCH_NAME
49-
50-
build-and-push:
51-
uses: ./.github/workflows/build-and-push.yaml
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Tag on Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- VERSION
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
14+
env:
15+
CHART_NAME: burrito
16+
CHART_PATH: ./deploy/charts/burrito
17+
CHART_REPO: ghcr.io/${{ github.repository_owner }}/charts
18+
19+
jobs:
20+
tag:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
version: ${{ steps.version.outputs.value }}
24+
already_exists: ${{ steps.check.outputs.exists }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
28+
29+
- name: Read version
30+
id: version
31+
run: echo "value=$(cat VERSION)" >> $GITHUB_OUTPUT
32+
33+
- name: Check tag does not already exist
34+
id: check
35+
run: |
36+
if git ls-remote --tags origin "${{ steps.version.outputs.value }}" | grep -q "${{ steps.version.outputs.value }}"; then
37+
echo "exists=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "exists=false" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Create and push tag
43+
if: steps.check.outputs.exists == 'false'
44+
run: |
45+
git config user.name "github-actions[bot]"
46+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git tag "${{ steps.version.outputs.value }}"
48+
git push origin "${{ steps.version.outputs.value }}"
49+
50+
helm-push:
51+
uses: ./.github/workflows/helm.yaml
52+
needs: tag
53+
with:
54+
version: ${{ needs.tag.outputs.version }}
55+
56+
docs-deploy:
57+
uses: ./.github/workflows/docs.yaml
58+
needs: tag
59+
with:
60+
version: ${{ needs.tag.outputs.version }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ credentials/
5050
.aws/
5151

5252
test-repo/
53-
TIltfile
53+
TIltfile

AGENTS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Nested `AGENTS.md` files add directory-specific rules — read them when working
1515

1616
- `api/v1alpha1/` — CRD Go types (see nested AGENTS.md). **Codegen-sensitive.**
1717
- `internal/controllers/` — reconciliation logic, one package per resource (see nested AGENTS.md).
18+
- `internal/repository/` — git provider access (see nested AGENTS.md). `internal/runner/` — the Terraform runner binary (see nested AGENTS.md). `internal/datastore/` — artifact storage service (see nested AGENTS.md). `internal/server/` — dashboard server + API (see nested AGENTS.md). `internal/webhook/` — VCS webhook receiver (see nested AGENTS.md).
1819
- `ui/` — React/Vite/TS dashboard (see nested AGENTS.md).
1920
- `deploy/charts/burrito/` — Helm chart (see nested AGENTS.md).
2021
- `cmd/` — binary entrypoints. `hack/` — dev/build scripts. `manifests/` & `config/crd/bases/` — generated manifests. `testdata/` — fixtures. `docs/` — documentation.
@@ -40,10 +41,12 @@ To change CRDs: edit `api/v1alpha1/*_types.go`, then run `make manifests` (and `
4041

4142
- Always check errors explicitly. Never `_ = err` or silently ignored returns.
4243
- No `panic()` in reconcilers — see `internal/controllers/AGENTS.md`.
44+
- **Tests:** add new cases to the existing test suite for a package rather than creating a new suite from scratch. Controllers use BDD (ginkgo/gomega): each `controller_test.go` reads `Describe("When X …")``It("should Y …")` (run via `RunSpecs`) — add cases to that suite.
4345

4446
## Commits — Conventional Commits
4547

4648
Format: `<type>(<scope>): <description>`.
4749

4850
- **Types:** `feat`, `fix`, `chore`, `docs`, `test`, `refactor`.
49-
- **Scopes** (use the closest fit): `controller`, `api`, `ui`, `helm`, `ci`, `deps`, `docker`. Scope is optional when none applies.
51+
- **Scopes** — suggested, not enforced. Prefer the closest fit (`controller`, `api`, `ui`, `helm`, `ci`, `deps`, `docker`); otherwise use another short, relevant scope or omit it.
52+
- CI gates each commit with commitlint (`@commitlint/config-conventional`) — self-check a message with `npx commitlint`.

api/v1alpha1/terraformrepository_types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,20 @@ type TerraformRepositoryList struct {
113113
func init() {
114114
SchemeBuilder.Register(&TerraformRepository{}, &TerraformRepositoryList{})
115115
}
116+
117+
// Workaround needed for envtest which does not populate the TypeMeta structure
118+
// See https://github.com/kubernetes-sigs/controller-runtime/issues/1870
119+
func (repository *TerraformRepository) GetAPIVersion() string {
120+
if repository.APIVersion == "" {
121+
return "config.terraform.padok.cloud/v1alpha1"
122+
}
123+
return repository.APIVersion
124+
}
125+
126+
// Same as above
127+
func (repository *TerraformRepository) GetKind() string {
128+
if repository.Kind == "" {
129+
return "TerraformRepository"
130+
}
131+
return repository.Kind
132+
}

deploy/charts/burrito/values-dev.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ config:
33
runner:
44
image:
55
repository: burrito
6-
tag: DEV_TAG
6+
tag: "1783089222"
77
pullPolicy: Never
88
datastore:
99
storage:
1010
mock: true
11+
controller:
12+
timers:
13+
driftDetection: 10m
14+
repositorySync: 2m
1115
global:
1216
deployment:
1317
image:
1418
repository: burrito
15-
tag: DEV_TAG
19+
tag: "1783089222"
1620
pullPolicy: Never
1721
tenants:
1822
- namespace:

deploy/charts/burrito/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ hermitcrab:
189189
image:
190190
pullPolicy: Always
191191
repository: sealio/hermitcrab
192-
tag: main
192+
tag: v0.1.7@sha256:2201a99d97d5f1c8071cc19aca631e3f90a92b3f246dc3a0cfb6d4b3a09d9ffd
193193
# -- Hermitcrab environment variables
194194
env:
195195
- name: SERVER_TLS_CERT_FILE

0 commit comments

Comments
 (0)