Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 81 additions & 7 deletions .github/CI.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CI Workflows

Three workflows gate changes to this repository. All are triggered by pull requests to `main`, scoped to their relevant paths.
Six workflows gate changes to this repository. All are triggered by pull requests to `main`, scoped to their relevant paths.

---

Expand Down Expand Up @@ -77,7 +77,7 @@ Checkov results are posted as a PR comment on failure and uploaded to the GitHub

---

## `gitops-ci.yaml` — GitOps / Kubernetes CI
## `gitops-ci.yaml` - GitOps / Kubernetes CI

**Triggers:** pull requests to `main` with changes under `gitops/**`, `k8s/**`, or `charts/**`.

Expand All @@ -90,19 +90,19 @@ Protects the GitOps repo from broken YAML, invalid manifests, and broken Helm te
| `helm lint` | Chart structure and values for all three charts (`simple-time-service`, `namespaces`, `raw`) |
| `helm template \| kubeconform` | Rendered manifests from `simple-time-service` and `namespaces` are valid Kubernetes resources against the 1.34 schema |

`charts/raw` is only linted, not templated — it is a passthrough chart that requires caller-supplied `Values.resources` to produce output.
`charts/raw` is only linted, not templated - it is a passthrough chart that requires caller-supplied `Values.resources` to produce output.

### Job: `manifests`

| Step | What it checks |
|------|----------------|
| `kubeconform` on `k8s/` | Strict schema validation against Kubernetes 1.34 |
| `kubeconform` on `gitops/` | Schema validation with `--ignore-missing-schemas` — standard K8s resources are validated; ArgoCD and Prometheus CRDs are skipped |
| `kubeconform` on `gitops/` | Schema validation with `--ignore-missing-schemas` - standard K8s resources are validated; ArgoCD and Prometheus CRDs are skipped |
| ApplicationSet Go template options | Every `kind: ApplicationSet` file must have `goTemplate: true` and `goTemplateOptions: ["missingkey=error"]` |

**Why the ApplicationSet check matters:**
- `goTemplate: true` — enables Go template syntax in the ApplicationSet generator; without it, template expressions are rendered literally
- `missingkey=error` — makes ArgoCD fail at sync time if a template variable is undefined, instead of silently rendering an empty string which can produce broken manifests that pass validation but misbehave at runtime
- `goTemplate: true` - enables Go template syntax in the ApplicationSet generator; without it, template expressions are rendered literally
- `missingkey=error` - makes ArgoCD fail at sync time if a template variable is undefined, instead of silently rendering an empty string which can produce broken manifests that pass validation but misbehave at runtime

### Job: `yaml-lint`

Expand All @@ -128,8 +128,82 @@ All three jobs post results as a PR comment on failure.

---

## `actions-check.yaml` - GitHub Actions Check

**Triggers:** pull requests to `main` with changes under `.github/workflows/**`.

### Job: `Lint Workflows`

Runs [`actionlint`](https://github.com/rhysd/actionlint) across all workflow files in `.github/workflows/`. Catches issues before they reach GitHub Actions runners:

- Invalid expression syntax (`${{ }}`)
- References to undefined contexts or outputs
- Type mismatches (e.g. passing a string where a boolean is expected)
- Invalid `if:` conditionals
- Incorrect `needs:` job references
- Missing required inputs on `workflow_call`

Results are posted as a PR comment on failure.

---

## `codeowners-check.yaml` - CODEOWNERS Check

**Triggers:** pull requests to `main` with changes to `.github/CODEOWNERS`.

### Job: `validate`

Runs [`codeowners-validator`](https://github.com/mszostok/codeowners-validator) against `.github/CODEOWNERS` with three checks:

| Check | What it validates |
|-------|-------------------|
| `syntax` | File follows the valid CODEOWNERS pattern format |
| `duppatterns` | No two entries match the same glob pattern |

The `owners` check is excluded - it requires `read:org` OAuth scope which the default `GITHUB_TOKEN` does not have.

Results are posted as a PR comment on failure.

---

## `pr-title-check.yaml` - PR Title Check

**Triggers:** all pull requests to `main` (no path filter) on `opened`, `edited`, `synchronize`, and `reopened` events.

### Job: `validate`

Validates that the PR title follows [Conventional Commits](https://www.conventionalcommits.org/) format using [`amannn/action-semantic-pull-request`](https://github.com/amannn/action-semantic-pull-request).

**Format:** `<type>[optional scope]: <description>`

**Valid types:**

| Type | Use for |
|------|---------|
| `feat` | New feature or capability |
| `fix` | Bug fix |
| `chore` | Maintenance, dependency updates |
| `docs` | Documentation only |
| `ci` | CI/CD pipeline changes |
| `refactor` | Code restructuring without behaviour change |
| `test` | Adding or updating tests |
| `perf` | Performance improvements |
| `style` | Formatting, whitespace (no logic change) |
| `revert` | Reverting a previous commit |

**Examples:**
- `feat: add velero backup schedule`
- `fix(app): correct health check endpoint`
- `ci: add pr title check workflow`

The `synchronize` trigger ensures branch protection always sees a current status on the latest commit, even when only the branch is updated without editing the title. On failure, a PR comment is posted with the current title, the expected format, and examples. The comment is updated in place if the title is edited and still fails.

---

## Branch protection

To enforce that all checks must pass before a PR can be merged, configure branch protection on `main`:

**Settings → Branches → Add rule → Require status checks to pass → add `build-and-scan`, `validate`, `security`, `helm`, `manifests`, `yaml-lint`**
**Settings → Branches → Add rule → Require status checks to pass → add `Build and Trivy Scan`, `Validate Terraform`, `Checkov Scan`, `Helm Lint`, `Validate Manifests`, `YAML Lint`, `Lint Workflows`, `Validate CODEOWNERS`, `Validate PR Title`**

> `validate` appears in both `terraform-ci` and `codeowners-check`. GitHub treats status checks by job name - both must pass when both are triggered.
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Default owner for everything not matched below
* @Beem0807

# CI workflows - any change to pipelines requires review
.github/ @Beem0807

# Infrastructure - Terraform changes require review
terraform/ @Beem0807

# Application - image and source code changes require review
app/ @Beem0807

# GitOps - manifest changes require review before ArgoCD picks them up
gitops/ @Beem0807
k8s/ @Beem0807
charts/ @Beem0807
36 changes: 36 additions & 0 deletions .github/branch-protection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Branch Protection - `main`

Documents the branch protection rules configured on `main`. These settings enforce that all CI checks pass before any PR can be merged.

## Rules

| Rule | Setting |
|------|---------|
| Require pull request before merging | ✅ Enabled - Required approvals: **0** |
| Require status checks to pass | ✅ Enabled - see checks below |
| Require branches to be up to date | ✅ Enabled |
| Require conversation resolution | ✅ Enabled |
| Require linear history | ✅ Enabled |
| Restrict direct pushes to `main` | ✅ Enabled |
| Require review from Code Owners | ❌ Disabled |

## Required status checks

| Check | Workflow |
|-------|----------|
| `App Image CI` | `.github/workflows/app-image.yaml` |
| `Terraform CI` | `.github/workflows/terraform-ci.yaml` |
| `GitOps CI` | `.github/workflows/gitops-ci.yaml` |
| `CODEOWNERS Check` | `.github/workflows/codeowners-check.yaml` |
| `GitHub Actions Check` | `.github/workflows/actions-check.yaml` |
| `PR Title Check` | `.github/workflows/pr-title-check.yaml` |

Each check only triggers when its relevant paths change. A check that was not triggered by a PR is treated as passing - only triggered checks must succeed.

## Notes

**Required approvals: 0** - PRs can self-merge once all required status checks pass. Suitable for a solo project; increase to 1 when collaborators are added.

**CODEOWNERS disabled** - `.github/CODEOWNERS` is present but "Require review from Code Owners" is off. The file is ready to enforce reviews if a second owner is added to the project.

See [CI.md](CI.md) for full documentation on what each workflow validates.
66 changes: 66 additions & 0 deletions .github/workflows/actions-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: GitHub Actions Check

on:
pull_request:
branches:
- main
paths:
- '.github/workflows/**'
workflow_dispatch:

jobs:
actionlint:
name: Lint Workflows
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install actionlint
run: |
curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash | bash
sudo mv ./actionlint /usr/local/bin/

- name: Run actionlint
id: actionlint
run: |
set -o pipefail
actionlint \
2>&1 | tee "$GITHUB_WORKSPACE/actionlint-report.txt"

- name: Post results as PR comment
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.existsSync('actionlint-report.txt')
? fs.readFileSync('actionlint-report.txt', 'utf8').trim()
: 'No report generated.';
const body = `## actionlint Results\n\`\`\`\n${report}\n\`\`\``;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.startsWith('## actionlint Results'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
3 changes: 2 additions & 1 deletion .github/workflows/app-image.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push app image
name: App Image CI

on:
push:
Expand All @@ -17,6 +17,7 @@ on:

jobs:
build-and-scan:
name: Build and Trivy Scan
runs-on: ubuntu-latest

permissions:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/codeowners-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CODEOWNERS Check

on:
pull_request:
branches:
- main
paths:
- '.github/CODEOWNERS'
- '.github/workflows/codeowners-check.yaml'
workflow_dispatch:

jobs:
validate:
name: Validate CODEOWNERS
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install codeowners-validator
run: go install github.com/mszostok/codeowners-validator@v0.7.4

- name: Validate CODEOWNERS
id: codeowners
env:
REPOSITORY_PATH: ${{ github.workspace }}
CHECKS: "syntax,duppatterns"
run: |
set -o pipefail
"$(go env GOPATH)/bin/codeowners-validator" \
2>&1 | tee "$GITHUB_WORKSPACE/codeowners-report.txt"

- name: Post results as PR comment
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.existsSync('codeowners-report.txt')
? fs.readFileSync('codeowners-report.txt', 'utf8').trim()
: 'No report generated.';
const body = `## CODEOWNERS Validation Results\n\`\`\`\n${report}\n\`\`\``;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.startsWith('## CODEOWNERS Validation Results'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
Loading
Loading