diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..19106084 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--- +name: Pre-commit Checks + +on: + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Run pre-commit checks + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + uv tool install pre-commit + uv tool ensurepath + pre-commit run --all-files --color always --show-diff-on-failure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..346aa0bb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +--- +default_stages: [pre-commit] +default_language_version: + python: python3 +minimum_pre_commit_version: '3.2.0' +repos: + - repo: local + hooks: + - id: sort-actions-yml + name: Sort actions.yml + entry: ./scripts/sort_yml.py + language: python + additional_dependencies: ['rich>=12.4.4', 'ruamel.yaml'] + require_serial: true + files: ^actions\.yml$ \ No newline at end of file diff --git a/actions.yml b/actions.yml index 3140430d..d110d83d 100644 --- a/actions.yml +++ b/actions.yml @@ -6,111 +6,6 @@ 1Password/load-secrets-action: 581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0: expires_at: 2050-01-01 -ana06/get-changed-files: - 25f79e676e7ea1868813e21465014798211fad8c: - tag: v2.3.0 - expires_at: 2050-01-01 -apache/*: - '*': - expires_at: 2025-08-01 - keep: true -bytedeco/javacpp-presets/.github/actions/*: - '*': - expires_at: 2025-08-01 - keep: true -dtolnay/rust-toolchain: - stable: - expires_at: 2025-08-01 - keep: true -golangci/*: - '*': - expires_at: 2025-08-01 - keep: true -pypa/gh-action-pypi-publish: - release/v1*: - expires_at: 2025-08-01 - keep: true -pytooling/actions/with-post-step: - '*': - expires_at: 2025-08-01 - keep: true -quarto-dev/quarto-actions/*: - '*': - expires_at: 2025-08-01 - keep: true -r-lib/actions/*: - '*': - expires_at: 2025-08-01 - keep: true -readthedocs/actions/preview: - '*': - expires_at: 2025-08-01 - keep: true -rustsec/*: - '*': - expires_at: 2025-08-01 - keep: true -vhelm/chart-releaser-action: - '*': - expires_at: 2025-08-01 - keep: true -AdoptOpenJDK/install-jdk: - '*': - expires_at: 2025-08-01 - keep: true -BobAnkh/auto-generate-changelog: - '*': - expires_at: 2025-08-01 - keep: true -DavidAnson/markdownlint-cli2-action: - b4c9feab76d8025d1e83c653fa3990936df0e6c8: - expires_at: 2025-09-08 - tag: v16 - 992badcdf24e3b8eb7e87ff9287fe931bcb00c6e: - expires_at: 2050-01-01 - tag: v20.0.0 -EnricoMi/publish-unit-test-result-action: - '*': - expires_at: 2025-08-01 - keep: true -JamesIves/github-pages-deploy-action: - 881db5376404c5c8d621010bcbec0310b58d5e29: - expires_at: 2025-10-19 - tag: v4.6.8 - 6c2d9db40f9296374acc17b90404b6e8864128c8: - expires_at: 2050-01-01 - tag: v4.7.3 -JustinBeckwith/linkinator-action: - 3d5ba091319fa7b0ac14703761eebb7d100e6f6d: - expires_at: 2050-01-01 - tag: v1.11.0 -Kesin11/actions-timeline: - 427ee2cf860166e404d0d69b4f2b24012bb7af4f: - expires_at: 2025-10-19 - a7eaabf426cdae26c3582c3fa674b897170dec8f: - expires_at: 2050-01-01 - tag: v2.2.4 -PyO3/maturin-action: - '*': - expires_at: 2025-08-01 - keep: true -TobKed/label-when-approved-action: - '*': - expires_at: 2025-08-01 - keep: true -VirtusLab/scala-cli-setup: - 6fc878be89f1990f6599f4f6a2e52a252e54d9f9: - tag: v1.7.1 - expires_at: 2025-09-08 - ca54569bf13a29cd648721038a89c47c7921c060: - tag: v1.8.0 - expires_at: 2025-09-09 - 6b3ba0ee6968ad077b859cb12246deabd2f7cb78: - expires_at: 2025-10-19 - tag: v1.8.1 - fd47cd1667585511042cb0504fbae3c588d4dc0c: - expires_at: 2050-01-01 - tag: v1.8.4 actions-cool/check-user-permission: '*': expires_at: 2025-08-01 @@ -134,6 +29,10 @@ addnab/docker-run-action: 4f65fabd2431ebc8d299f8e5a018d79a769ae185: expires_at: 2050-01-01 tag: v3 +AdoptOpenJDK/install-jdk: + '*': + expires_at: 2025-08-01 + keep: true al-cheb/configure-pagefile-action: '*': expires_at: 2025-08-01 @@ -142,6 +41,14 @@ amannn/action-semantic-pull-request: '*': expires_at: 2025-08-01 keep: true +ana06/get-changed-files: + 25f79e676e7ea1868813e21465014798211fad8c: + tag: v2.3.0 + expires_at: 2050-01-01 +apache/*: + '*': + expires_at: 2025-08-01 + keep: true arduino/setup-protoc: '*': expires_at: 2025-08-01 @@ -175,6 +82,10 @@ bnjbvr/cargo-machete: b54422fa3319b3cac180f6030b663fe57af51635: expires_at: 2050-01-01 tag: v0.8.0 +BobAnkh/auto-generate-changelog: + '*': + expires_at: 2025-08-01 + keep: true browser-actions/setup-firefox: 5b19b18df8c293aae9e77f0a936e9fdc358f543a: expires_at: 2025-09-08 @@ -212,6 +123,10 @@ bytedeco/javacpp-presets: '*': expires_at: 2025-08-01 keep: true +bytedeco/javacpp-presets/.github/actions/*: + '*': + expires_at: 2025-08-01 + keep: true carloscastrojumo/github-cherry-pick-action: 503773289f4a459069c832dc628826685b75b4b3: expires_at: 2050-01-01 @@ -307,6 +222,13 @@ crazy-max/ghaction-setup-docker: damccorm/tag-ur-it: 6fa72bbf1a2ea157b533d7e7abeafdb5855dbea5: expires_at: 2050-01-01 +DavidAnson/markdownlint-cli2-action: + b4c9feab76d8025d1e83c653fa3990936df0e6c8: + expires_at: 2025-09-08 + tag: v16 + 992badcdf24e3b8eb7e87ff9287fe931bcb00c6e: + expires_at: 2050-01-01 + tag: v20.0.0 dawidd6/action-download-artifact: '*': expires_at: 2025-08-01 @@ -331,21 +253,29 @@ dlang-community/setup-dlang: '*': expires_at: 2025-08-01 keep: true -docker://jekyll/jekyll: - sha256:400b8d1569f118bca8a3a09a25f32803b00a55d1ea241feaf5f904d66ca9c625: - expires_at: 2050-01-01 docker/setup-qemu-action: 29109295f81e9208d7d86ff1c6c12d2833863392: expires_at: 2050-01-01 keep: true +docker://jekyll/jekyll: + sha256:400b8d1569f118bca8a3a09a25f32803b00a55d1ea241feaf5f904d66ca9c625: + expires_at: 2050-01-01 dorny/paths-filter: de90cc6fb38fc0963ad72b210f1f284cd68cea36: expires_at: 2050-01-01 tag: v3.0.2 +dtolnay/rust-toolchain: + stable: + expires_at: 2025-08-01 + keep: true easimon/maximize-build-space: '*': expires_at: 2025-08-01 keep: true +EnricoMi/publish-unit-test-result-action: + '*': + expires_at: 2025-08-01 + keep: true eps1lon/actions-label-merge-conflict: '*': expires_at: 2025-08-01 @@ -370,6 +300,17 @@ golang/govulncheck-action: '*': expires_at: 2025-08-01 keep: true +golangci/*: + '*': + expires_at: 2025-08-01 + keep: true +golangci/golangci-lint-action: + 1481404843c368bc19ca9406f87d6e0fc97bdcfd: + expires_at: 2050-08-01 + keep: true + 55c2c1448f86e01eaae002a5a3a9624417608d84: + expires_at: 2050-08-01 + keep: true google-github-actions/auth: ba79af03959ebeac9769e648f473a284504d9193: expires_at: 2025-10-19 @@ -446,6 +387,13 @@ ilammy/setup-nasm: 72793074d3c8cdda771dba85f6deafe00623038b: expires_at: 2050-01-01 tag: v1.5.2 +JamesIves/github-pages-deploy-action: + 881db5376404c5c8d621010bcbec0310b58d5e29: + expires_at: 2025-10-19 + tag: v4.6.8 + 6c2d9db40f9296374acc17b90404b6e8864128c8: + expires_at: 2050-01-01 + tag: v4.7.3 jarvusinnovations/background-action: '*': expires_at: 2025-08-01 @@ -493,6 +441,10 @@ juliaregistries/tagbot: '*': expires_at: 2025-08-01 keep: true +JustinBeckwith/linkinator-action: + 3d5ba091319fa7b0ac14703761eebb7d100e6f6d: + expires_at: 2050-01-01 + tag: v1.11.0 jwgmeligmeyling/checkstyle-github-action: '*': expires_at: 2025-08-01 @@ -504,6 +456,12 @@ jwgmeligmeyling/spotbugs-github-action: '*': expires_at: 2025-08-01 keep: true +Kesin11/actions-timeline: + 427ee2cf860166e404d0d69b4f2b24012bb7af4f: + expires_at: 2025-10-19 + a7eaabf426cdae26c3582c3fa674b897170dec8f: + expires_at: 2050-01-01 + tag: v2.2.4 kiegroup/github-action-build-chain: '*': expires_at: 2025-08-01 @@ -548,6 +506,13 @@ mikepenz/action-junit-report: '*': expires_at: 2025-08-01 keep: true +mlugg/setup-zig: + 7dccf5e6d09267c55f815f2db29495f30ba2ebca: + expires_at: 2025-10-19 + tag: v2.0.1 + 8d6198c65fb0feaa111df26e6b467fea8345e46f: + expires_at: 2050-01-01 + tag: v2.0.5 mozilla-actions/sccache-action: 2e7f9ec7921547d4b46598398ca573513895d0bd: expires_at: 2025-08-03 @@ -663,7 +628,7 @@ pre-commit/action: 2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd: expires_at: 2050-01-01 tag: v3.0.1 -pyTooling/Actions: +PyO3/maturin-action: '*': expires_at: 2025-08-01 keep: true @@ -680,14 +645,34 @@ pypa/cibuildwheel: 9e4e50bd76b3190f55304387e333f6234823ea9b: expires_at: 2050-01-01 tag: v3.1.2 +pypa/gh-action-pypi-publish: + release/v1*: + expires_at: 2025-08-01 + keep: true +pyTooling/Actions: + '*': + expires_at: 2025-08-01 + keep: true pytooling/actions: '*': expires_at: 2025-08-01 keep: true +pytooling/actions/with-post-step: + '*': + expires_at: 2025-08-01 + keep: true quarto-dev/quarto-actions: '*': expires_at: 2025-08-01 keep: true +quarto-dev/quarto-actions/*: + '*': + expires_at: 2025-08-01 + keep: true +r-lib/actions/*: + '*': + expires_at: 2025-08-01 + keep: true reactivecircus/android-emulator-runner: '*': expires_at: 2025-08-01 @@ -696,6 +681,10 @@ readthedocs/actions: '*': expires_at: 2025-08-01 keep: true +readthedocs/actions/preview: + '*': + expires_at: 2025-08-01 + keep: true release-drafter/release-drafter: '*': expires_at: 2025-08-01 @@ -704,6 +693,10 @@ ruby/setup-ruby: '*': expires_at: 2025-08-01 keep: true +rustsec/*: + '*': + expires_at: 2025-08-01 + keep: true sbt/setup-sbt: 26ab4b0fa1c47fa62fc1f6e51823a658fb6c760c: expires_at: 2025-09-08 @@ -761,6 +754,16 @@ shufo/auto-assign-reviewer-by-files: '*': expires_at: 2025-08-01 keep: true +slackapi/slack-github-action: + 485a9d42d3a73031f12ec201c457e2162c45d02d: + expires_at: 2025-09-09 + tag: v2.0.0 + b0fa283ad8fea605de13dc3f449259339835fc52: + expires_at: 2025-10-19 + tag: v2.1.0 + 91efab103c0de0a537f72a35f6b8cda0ee76bf0a: + expires_at: 2050-01-01 + tag: v2.1.1 snok/install-poetry: 76e04a911780d5b312d89783f7b1cd627778900a: expires_at: 2050-01-01 @@ -797,6 +800,10 @@ timonvs/pr-labeler-action: '*': expires_at: 2025-08-01 keep: true +TobKed/label-when-approved-action: + '*': + expires_at: 2025-08-01 + keep: true untitaker/hyperlink: d277930ba480c61cd3dd1a0caf0d18acfed294a6: expires_at: 2025-10-19 @@ -811,10 +818,27 @@ uraimo/run-on-arch-action: d94c13912ea685de38fccc1109385b83fd79427d: expires_at: 2050-01-01 tag: v3.0.1 +vhelm/chart-releaser-action: + '*': + expires_at: 2025-08-01 + keep: true vimtor/action-zip: 5f1c4aa587ea41db1110df6a99981dbe19cee310: expires_at: 2050-01-01 tag: v1 +VirtusLab/scala-cli-setup: + 6fc878be89f1990f6599f4f6a2e52a252e54d9f9: + tag: v1.7.1 + expires_at: 2025-09-08 + ca54569bf13a29cd648721038a89c47c7921c060: + tag: v1.8.0 + expires_at: 2025-09-09 + 6b3ba0ee6968ad077b859cb12246deabd2f7cb78: + expires_at: 2025-10-19 + tag: v1.8.1 + fd47cd1667585511042cb0504fbae3c588d4dc0c: + expires_at: 2050-01-01 + tag: v1.8.4 vishalsinha21/dynamic-checklist: '*': expires_at: 2025-08-01 @@ -827,27 +851,3 @@ xpol/setup-lua: '*': expires_at: 2025-08-01 keep: true -slackapi/slack-github-action: - 485a9d42d3a73031f12ec201c457e2162c45d02d: - expires_at: 2025-09-09 - tag: v2.0.0 - b0fa283ad8fea605de13dc3f449259339835fc52: - expires_at: 2025-10-19 - tag: v2.1.0 - 91efab103c0de0a537f72a35f6b8cda0ee76bf0a: - expires_at: 2050-01-01 - tag: v2.1.1 -golangci/golangci-lint-action: - 1481404843c368bc19ca9406f87d6e0fc97bdcfd: - expires_at: 2050-08-01 - keep: true - 55c2c1448f86e01eaae002a5a3a9624417608d84: - expires_at: 2050-08-01 - keep: true -mlugg/setup-zig: - 7dccf5e6d09267c55f815f2db29495f30ba2ebca: - expires_at: 2025-10-19 - tag: v2.0.1 - 8d6198c65fb0feaa111df26e6b467fea8345e46f: - expires_at: 2050-01-01 - tag: v2.0.5 diff --git a/scripts/sort_yml.py b/scripts/sort_yml.py new file mode 100755 index 00000000..307b8b8f --- /dev/null +++ b/scripts/sort_yml.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# "rich", +# "ruamel.yaml", +# ] +# /// + +from ruamel.yaml import YAML +from ruamel.yaml.comments import CommentedMap +import sys +from pathlib import Path +from rich.console import Console + +console = Console(width=400, color_system="standard") + + +def sort_yaml_file(input_file: str): + """Sorts the keys of a YAML file in alphabetical order""" + + yaml = YAML() + yaml.preserve_quotes = True + + input_path = Path(input_file) + + if not input_path.exists(): + raise FileNotFoundError(f"File '{input_file}' not found.") + + with open(input_path, 'r', encoding='utf-8') as f: + data = yaml.load(f) + + sorted_data = CommentedMap() + + sorted_keys: list[str] = sorted(data.keys(), key=str.lower) + + # Copy data in sorted order + for key in sorted_keys: + sorted_data[key] = data[key] + + # Preserve any comment at the beginning of the file + if hasattr(data, 'ca') and hasattr(data.ca, 'comment'): + if not hasattr(sorted_data, 'ca'): + sorted_data.ca = data.ca.__class__() + sorted_data.ca.comment = data.ca.comment + + with open(input_path, 'w', encoding='utf-8') as f: + yaml.dump(sorted_data, f) + + +errors = [] +def main(): + files = sys.argv[1:] + for file in files: + console.print(f"[blue]Sorting YAML file {file}") + try: + sort_yaml_file(file) + console.print(f"[blue]✅ YAML file sorted successfully {file}!") + except FileNotFoundError as e: + errors.append((file, str(e))) + except Exception as e: + errors.append((file, str(e))) + + if errors: + console.print("[red]Errors occurred while sorting YAML files:") + for file, error in errors: + console.print(f"[red]File: {file} - Error: {error}") + sys.exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file