From f38c514498a7020b6d618be3d3147ca33a09652e Mon Sep 17 00:00:00 2001 From: Aashish Radhakrishnan Date: Mon, 12 Aug 2024 18:34:21 -0400 Subject: [PATCH] Add pre-commit hook for validating release notes - This is a pre-commit hook using `pre-commit` framework to validate release notes YAML files. - The hook checks for correct structure, formatting and required fields in the `release-notes` directory. - This ensures consistency in release notes before committing changes. - Added release notes validation to the `make syntax-check` target Ref: https://github.com/coreos/fedora-coreos-streams/pull/934#issuecomment-2260059748 --- .github/workflows/validate-release-notes.yml | 17 ----------------- .pre-commit-config.yaml | 9 +++++++++ Makefile | 5 +++-- 3 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/validate-release-notes.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/validate-release-notes.yml b/.github/workflows/validate-release-notes.yml deleted file mode 100644 index 842ff74f..00000000 --- a/.github/workflows/validate-release-notes.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Validate Release Notes - -on: - pull_request: - branches: [main] - paths: ["release-notes/*.yml"] - -jobs: - validate: - name: Validate Release Notes - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Validate Release Notes - run: python ci/check-release-notes.py release-notes/next.yml release-notes/stable.yml release-notes/testing.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a5243042 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: local + hooks: + - id: syntax-check + name: Syntax Check + entry: make syntax-check + language: system + types: [yaml, json] + files: ^(release-notes/.*\.yml$|streams/.*\.json$|updates/.*\.json$) diff --git a/Makefile b/Makefile index 90b2d769..84248130 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -.PHONY: syntax-check +.PHONY: syntax-check print-rollouts + syntax-check: @find streams updates -iname '*.json' | sort | xargs -n 1 python3 -c 'import json, sys; json.load(open(sys.argv[1]))' + @find release-notes -iname '*.yml' | sort | xargs -n1 python3 ci/check-release-notes.py -.PHONY: print-rollouts print-rollouts: @find updates -iname '*.json' -printf '%f\n' | cut -f1 -d. | sort | xargs ./rollout.py print