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
18 changes: 18 additions & 0 deletions .betterleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Betterleaks: secret scanning in CI's lint job and the pre-commit hook. The default rules, minus this repository's
# placeholders. Add an exception only for something that is not a secret, with the reason.
[extend]
useDefault = true

[[allowlists]]
description = "Example and reference files hold placeholders (REPLACE_ME, changeme, dckr_pat_example), never real values"
paths = [
'''\.example$''',
'''\.example\.ya?ml$''',
'''^reference/deployment\.yml$''',
'''^kubernetes/docspring-enterprise/ci/check-values\.yaml$''',
]

[[allowlists]]
description = "The connection URL's shape in docs and error messages: postgres://USER:PASSWORD@HOST"
regexTarget = "line"
regexes = ['''postgres://USER:PASSWORD@''', '''random_password\.db''']
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# GitHub Actions updates, a week after each release (the cooldown), so a bad or hijacked release has time to be
# pulled first. Dependabot keeps the commit SHA pins and their version comments.
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
groups:
actions:
patterns: ['*']
33 changes: 30 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ permissions:
contents: read

jobs:
# The workflows themselves (actionlint, zizmor: actions must be pinned to commit SHAs), spelling and secrets.
# The same versions as mise.toml.
lint:
name: Workflows, spelling and secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3.6.3
- run: actionlint
- run: zizmor .github/workflows
- run: typos
- run: betterleaks dir --redact --no-banner -c .betterleaks.toml .

contract:
name: Every folder matches reference/deployment.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0
- run: scripts/check_deployments

Expand All @@ -24,10 +41,12 @@ jobs:
working-directory: docker-compose
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Compose file
run: ./setup.sh > /dev/null && docker compose config --quiet && rm .env
- name: Shell scripts
run: shellcheck *.sh
run: shellcheck ./*.sh

kubernetes:
runs-on: ubuntu-latest
Expand All @@ -36,6 +55,8 @@ jobs:
working-directory: kubernetes
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0
- name: Install kubeconform
run: |
Expand All @@ -52,9 +73,11 @@ jobs:
working-directory: aws-ecs
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
- uses: terraform-linters/setup-tflint@6ffdbaa3be476b3431f7275c26966ef32ff60337 # v6.3.2
- run: terraform fmt -check -recursive
# No format check: the pre-commit hook (lefthook.yml) runs terraform fmt and stages the result
- working-directory: aws-ecs/example
run: terraform init -backend=false -input=false && terraform validate
# tflint --init downloads its rulesets from GitHub, which rate-limits a runner's anonymous requests
Expand All @@ -70,11 +93,13 @@ jobs:
working-directory: convox
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@4e97ecde5048e1e0816923020652678063ffbf65 # v1.339.0
with:
ruby-version: '3.4'
- run: ruby -c install.rb
- run: shellcheck *.sh
- run: shellcheck ./*.sh

aptible:
runs-on: ubuntu-latest
Expand All @@ -83,6 +108,8 @@ jobs:
working-directory: aptible
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: The crontab parses
run: |
docker run --rm -v "$PWD/crontab:/crontab:ro" --entrypoint sh alpine:3.22 -c \
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0
- name: Push the chart unless its version is already published
env:
GH_TOKEN: ${{ github.token }}
ACTOR: ${{ github.actor }}
run: |
set -euo pipefail
version="$(sed -n 's/^version: *//p' kubernetes/docspring-enterprise/Chart.yaml | tr -d '"')"
echo "$GH_TOKEN" | helm registry login ghcr.io --username "${{ github.actor }}" --password-stdin
echo "$GH_TOKEN" | helm registry login ghcr.io --username "$ACTOR" --password-stdin
if helm show chart oci://ghcr.io/docspring/charts/docspring-enterprise --version "$version" > /dev/null 2>&1; then
echo "Chart $version is already published"
exit 0
Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ runs all of them (`.github/workflows/ci.yml`).
- Plain English in READMEs and comments. Say what a thing does and why, not that it's powerful or easy.
- No customer names, hostnames or secrets anywhere. Example domain: `docspring.example.com`.
- Shell scripts: `set -euo pipefail`, shellcheck clean. Terraform: `terraform fmt`. YAML: two spaces.
- `mise install && lefthook install` sets up the pre-commit hook: it runs `terraform fmt` and stages the result (CI
has no format check), shellcheck, actionlint and zizmor on the workflows, typos and Betterleaks. CI's `lint` job
runs the same linters. zizmor fails on an action that isn't pinned to a commit SHA. Exceptions live in
`_typos.toml` and `.betterleaks.toml`, each with its reason.
4 changes: 4 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# typos: the spelling check in CI's lint job and the pre-commit hook.
[default.extend-words]
# Azure Kubernetes Service
AKS = "AKS"
19 changes: 19 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Git hooks that mirror CI. Install with: mise install && lefthook install
pre-commit:
commands:
terraform-fmt:
glob: '*.{tf,tfvars}'
run: terraform fmt {staged_files}
stage_fixed: true
shellcheck:
glob: '*.sh'
run: shellcheck {staged_files}
workflows:
glob: '.github/workflows/*.yml'
run: actionlint && zizmor .github/workflows
# Fixes a misspelling with one correction and stages it; fails on one with several
typos:
run: typos -w {staged_files}
stage_fixed: true
betterleaks:
run: betterleaks git --staged --redact --no-banner -c .betterleaks.toml .
8 changes: 8 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The linters CI's lint job and the pre-commit hook run. Install with: mise install
[tools]
actionlint = "1.7.12"
zizmor = "1.33.1"
shellcheck = "0.11.0"
typos = "1.52.2"
betterleaks = "1.10.1"
lefthook = "2.1.14"
Loading