From 451400415ebf143c25e380f631e905286e281415 Mon Sep 17 00:00:00 2001 From: Ryota Ikezawa Date: Sat, 17 Jan 2026 12:51:45 +0900 Subject: [PATCH] ci: optimize workflow with concurrency and paths filter Reduce CI minutes by skipping unnecessary jobs when unrelated files change. Uses dorny/paths-filter to detect changes and conditionally run jobs. - Add concurrency to cancel outdated runs on force-push - Add changes job to detect modified file categories - Skip format/lint/chezmoi/devbox/neovim jobs when their files unchanged - Always run all jobs when workflow files change Co-Authored-By: Claude Opus 4.5 --- .github/workflows/test.yml | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0f9a53..3124726 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,9 +6,52 @@ on: pull_request: branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + shell: ${{ steps.filter.outputs.shell }} + lua: ${{ steps.filter.outputs.lua }} + nvim: ${{ steps.filter.outputs.nvim }} + devbox: ${{ steps.filter.outputs.devbox }} + chezmoi: ${{ steps.filter.outputs.chezmoi }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + shell: + - 'dot_zshrc.tmpl' + - 'dot_zshenv.tmpl' + - 'install.sh' + - '.chezmoiscripts/**' + - '.github/workflows/**' + lua: + - 'dot_config/nvim/**/*.lua' + - '.github/workflows/**' + nvim: + - 'dot_config/nvim/**' + - '.github/workflows/**' + devbox: + - 'dot_local/share/devbox/global/default/devbox.json' + - '.github/workflows/**' + chezmoi: + - '**/*.tmpl' + - '.chezmoi*' + - 'dot_config/**' + - 'private_dot_ssh/**' + - '.github/workflows/**' + format: name: Format Check + needs: changes + if: needs.changes.outputs.shell == 'true' || needs.changes.outputs.lua == 'true' || needs.changes.outputs.devbox == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -62,6 +105,8 @@ jobs: lint: name: Lint + needs: changes + if: needs.changes.outputs.shell == 'true' || needs.changes.outputs.lua == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -100,6 +145,8 @@ jobs: chezmoi-linux: name: Chezmoi (Linux, ${{ matrix.env_name }}) + needs: changes + if: needs.changes.outputs.chezmoi == 'true' runs-on: ubuntu-latest strategy: matrix: @@ -141,6 +188,8 @@ jobs: chezmoi-macos: name: Chezmoi (macOS, ${{ matrix.env_name }}) + needs: changes + if: needs.changes.outputs.chezmoi == 'true' runs-on: macos-latest strategy: matrix: @@ -181,6 +230,8 @@ jobs: devbox: name: Devbox Validation + needs: changes + if: needs.changes.outputs.devbox == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -204,6 +255,8 @@ jobs: neovim: name: Neovim Config + needs: changes + if: needs.changes.outputs.nvim == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4