From 0befe05ed972a41cfae3ee14101685f7691cb64e Mon Sep 17 00:00:00 2001 From: iamtatsuki05 Date: Wed, 4 Nov 2026 02:08:37 +0900 Subject: [PATCH 1/4] ci: cache uv and Docker layers, cancel superseded runs test-uv installs uv with astral-sh/setup-uv and stores the uv cache in the GitHub Actions cache, keyed on uv.lock. It also gets a 5-minute timeout. test-docker builds the image with docker/build-push-action and stores the layers in the GitHub Actions cache. Compose then starts the loaded image with --no-build, so a tag mismatch fails the job. Both workflows cancel a PR run when a newer push to the same PR starts. --- .github/workflows/test_docker.yml | 26 ++++++++++++++++++-------- .github/workflows/test_poetry.yml | 12 +++++++++--- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 1c2206b..79462df 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -11,6 +11,10 @@ on: default: false type: boolean +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: rspec: runs-on: ubuntu-latest @@ -20,16 +24,22 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - # - uses: docker/setup-buildx-action@v2 - # - uses: docker/build-push-action@v4 - # with: - # context: ${{ matrix.service }}/docker/cpu - # cache-from: type=gha - # cache-to: type=gha,mode=max + - uses: docker/setup-buildx-action@v4 + - name: Resolve image name + id: image + run: echo "name=$(docker compose config --images python-cpu)" >> "$GITHUB_OUTPUT" + - uses: docker/build-push-action@v7 + with: + context: . + file: docker/cpu/Dockerfile + target: dev + load: true + tags: ${{ steps.image.outputs.name }} + cache-from: type=gha,scope=python-cpu + cache-to: type=gha,mode=max,scope=python-cpu - name: Setup docker shell: bash run: | - docker compose build --progress=plain - docker compose up -d + docker compose up -d --no-build - name: Test run: docker compose exec python-cpu uv run tox diff --git a/.github/workflows/test_poetry.yml b/.github/workflows/test_poetry.yml index 88a004e..2623c77 100644 --- a/.github/workflows/test_poetry.yml +++ b/.github/workflows/test_poetry.yml @@ -11,9 +11,14 @@ on: default: false type: boolean +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest + timeout-minutes: 5 strategy: matrix: @@ -34,9 +39,10 @@ jobs: sudo apt-get install -y mecab libmecab-dev mecab-ipadic-utf8 - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV + uses: astral-sh/setup-uv@v10.3.3 + with: + enable-cache: true + cache-dependency-glob: uv.lock - name: Install dependencies run: | From 04e22ce99e8cbf6a1d06056424821eb4c24703a1 Mon Sep 17 00:00:00 2001 From: iamtatsuki05 Date: Wed, 4 Nov 2026 02:23:16 +0900 Subject: [PATCH 2/4] ci: drop the uv and Docker layer caches The PR runs showed that neither cache saves time here. uv sync takes about 4 s, and the cold run spent 31 s saving a 318 MB uv cache. The warm test-docker run took 160 s against a 150 s baseline median, because pulling the cached layers and loading the image took as long as building it. Keep the concurrency groups and the test-uv timeout. --- .github/workflows/test_docker.yml | 22 ++++++++-------------- .github/workflows/test_poetry.yml | 7 +++---- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 79462df..99d3dad 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -24,22 +24,16 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - - uses: docker/setup-buildx-action@v4 - - name: Resolve image name - id: image - run: echo "name=$(docker compose config --images python-cpu)" >> "$GITHUB_OUTPUT" - - uses: docker/build-push-action@v7 - with: - context: . - file: docker/cpu/Dockerfile - target: dev - load: true - tags: ${{ steps.image.outputs.name }} - cache-from: type=gha,scope=python-cpu - cache-to: type=gha,mode=max,scope=python-cpu + # - uses: docker/setup-buildx-action@v2 + # - uses: docker/build-push-action@v4 + # with: + # context: ${{ matrix.service }}/docker/cpu + # cache-from: type=gha + # cache-to: type=gha,mode=max - name: Setup docker shell: bash run: | - docker compose up -d --no-build + docker compose build --progress=plain + docker compose up -d - name: Test run: docker compose exec python-cpu uv run tox diff --git a/.github/workflows/test_poetry.yml b/.github/workflows/test_poetry.yml index 2623c77..ec6e281 100644 --- a/.github/workflows/test_poetry.yml +++ b/.github/workflows/test_poetry.yml @@ -39,10 +39,9 @@ jobs: sudo apt-get install -y mecab libmecab-dev mecab-ipadic-utf8 - name: Install uv - uses: astral-sh/setup-uv@v10.3.3 - with: - enable-cache: true - cache-dependency-glob: uv.lock + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV - name: Install dependencies run: | From 69c21467cf0afbb1c8a7c00f3e16885378270b56 Mon Sep 17 00:00:00 2001 From: iamtatsuki05 Date: Wed, 4 Nov 2026 03:05:49 +0900 Subject: [PATCH 3/4] ci: raise the test-uv timeout to 12 minutes Repos made from this template add their own dependencies. In nlp-template, which has torch, the slowest test-uv run took 3.9 min, and a run on a slow apt mirror took 4.2 min. A 5-minute limit would fail those runs, while 12 minutes still stops a hung job. --- .github/workflows/test_poetry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_poetry.yml b/.github/workflows/test_poetry.yml index ec6e281..4dda502 100644 --- a/.github/workflows/test_poetry.yml +++ b/.github/workflows/test_poetry.yml @@ -18,7 +18,7 @@ concurrency: jobs: test: runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 12 strategy: matrix: From 0fc9ff8c4e51390bc1a909cf22d9ad1880f3d237 Mon Sep 17 00:00:00 2001 From: iamtatsuki05 Date: Wed, 4 Nov 2026 03:49:48 +0900 Subject: [PATCH 4/4] ci: make the concurrency group unique per workflow file --- .github/workflows/test_docker.yml | 2 +- .github/workflows/test_poetry.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 99d3dad..152776c 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -12,7 +12,7 @@ on: type: boolean concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-test-docker-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/test_poetry.yml b/.github/workflows/test_poetry.yml index 4dda502..29f33eb 100644 --- a/.github/workflows/test_poetry.yml +++ b/.github/workflows/test_poetry.yml @@ -12,7 +12,7 @@ on: type: boolean concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-test-uv-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: