From f14a048091a13530398202269054f62f7dcd46f6 Mon Sep 17 00:00:00 2001 From: nkoji21 <133028205+nkoji21@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:59:58 +0900 Subject: [PATCH] ci: run format / build / lint in CI Run the same scripts as pre-commit inside the flake devShell so that commits bypassed with --no-verify are still caught on push/PR. --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c25e92b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +# CI: pre-commit と同じ format / build / lint を flake の devShell 内で走らせる。 +# pre-commit は --no-verify でバイパスできるため、push/PR では CI で再チェックする。 +# 対象は差分ではなく追跡中の全 C++ ファイル。各スクリプトが対象を自前で絞り込む。 +name: ci + +on: + push: + branches: [main] + pull_request: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: cachix/install-nix-action@v27 + with: + extra_nix_config: | + experimental-features = nix-command flakes + + # 追跡中の C++ ファイル一覧を ci.files に集める。 + - name: Collect C++ files + id: files + run: | + files="$(git ls-files '*.cpp' '*.hpp' '*.tpp' '*.h')" + { + echo 'list<> "$GITHUB_OUTPUT" + + - name: format (check) + if: steps.files.outputs.list != '' + run: nix develop --command bash scripts/format.sh --check ${{ steps.files.outputs.list }} + + - name: build + if: steps.files.outputs.list != '' + run: nix develop --command bash scripts/check-build.sh ${{ steps.files.outputs.list }} + + - name: lint + if: steps.files.outputs.list != '' + run: nix develop --command bash scripts/lint.sh ${{ steps.files.outputs.list }}