mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-03 18:47:04 +09:00
v1.6.0 adds the date-time string-format alias and the @example annotation. Both are additive, opt-in directives: charts that do not use them regenerate byte-identical schema, README and Go type output, so the pre-commit check stays green without touching any committed artifact. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
68 lines
2.1 KiB
YAML
68 lines
2.1 KiB
YAML
name: Pre-Commit Checks
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
concurrency:
|
|
group: pre-commit-${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
pre-commit:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install pre-commit
|
|
run: pip install pre-commit
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Pre-fetch k8s.io/code-generator module
|
|
# The repo-root pre-commit hook (run-make-generate-root) shells out to
|
|
# hack/update-codegen.sh, which sources kube_codegen.sh from the Go
|
|
# module cache. The module is not declared in go.mod, so fetch it
|
|
# explicitly at the version pinned in the script - mirrors the
|
|
# equivalent step in codegen-drift.yml.
|
|
run: |
|
|
version=$(grep -oP 'code-generator@\Kv[0-9.]+' hack/update-codegen.sh)
|
|
tmpdir=$(mktemp -d)
|
|
cd "$tmpdir"
|
|
go mod init codegen-fetch
|
|
go get "k8s.io/code-generator@${version}"
|
|
|
|
- name: Install generate
|
|
run: |
|
|
curl -sSL https://github.com/cozystack/cozyvalues-gen/releases/download/v1.6.0/cozyvalues-gen-linux-amd64.tar.gz | tar -xzvf- -C /usr/local/bin/ cozyvalues-gen
|
|
|
|
- name: Run pre-commit hooks
|
|
run: |
|
|
git fetch origin main || git fetch origin master
|
|
base_commit=$(git rev-parse --verify origin/main || git rev-parse --verify origin/master || echo "")
|
|
|
|
if [ -z "$base_commit" ]; then
|
|
files=$(git ls-files '*.yaml' '*.md')
|
|
else
|
|
files=$(git diff --name-only "$base_commit" -- '*.yaml' '*.md')
|
|
fi
|
|
|
|
if [ -n "$files" ]; then
|
|
echo "$files" | xargs pre-commit run --files
|
|
else
|
|
echo "No YAML or Markdown files to lint"
|
|
fi
|