Skip to content

Commit b57f3bf

Browse files
committed
Improve ccache key
1 parent 5bbc5b3 commit b57f3bf

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

.github/actions/ccache/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: ccache
2+
inputs:
3+
name:
4+
required: true
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Get PHP version
9+
shell: bash
10+
id: php_version
11+
run: |
12+
echo "major=$(cat main/php_version.h | sed -n 's/^#define PHP_MAJOR_VERSION \([0-9]\+\)/\1/p')" >> $GITHUB_OUTPUT
13+
echo "minor=$(cat main/php_version.h | sed -n 's/^#define PHP_MINOR_VERSION \([0-9]\+\)/\1/p')" >> $GITHUB_OUTPUT
14+
- name: ccache
15+
uses: hendrikmuhs/ccache-action@v1.2
16+
with:
17+
key: "${{ inputs.name }}-${{ steps.php_version.outputs.major }}.${{ steps.php_version.outputs.minor }}"
18+
append-timestamp: false
19+
save: ${{ github.event_name != 'pull_request' }}

.github/workflows/nightly.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,12 @@ jobs:
148148
- name: Setup Caddy server
149149
uses: ./.github/actions/setup-caddy
150150
- name: ccache
151-
uses: hendrikmuhs/ccache-action@v1.2
151+
uses: ./.github/actions/ccache
152152
with:
153153
# This duplicates the "job.name" expression above because
154154
# GitHub has no way to query the job name (github.job is the
155155
# job id, not the job name)
156-
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}"
157-
append-timestamp: false
158-
save: ${{ github.event_name != 'pull_request' }}
156+
name: "LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
159157
- name: ./configure
160158
uses: ./.github/actions/configure-x64
161159
with:
@@ -257,11 +255,9 @@ jobs:
257255
- name: apt
258256
uses: ./.github/actions/apt-x32
259257
- name: ccache
260-
uses: hendrikmuhs/ccache-action@v1.2
258+
uses: ./.github/actions/ccache
261259
with:
262-
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
263-
append-timestamp: false
264-
save: ${{ github.event_name != 'pull_request' }}
260+
name: "LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
265261
- name: System info
266262
run: |
267263
echo "::group::Show host CPU info"
@@ -322,11 +318,9 @@ jobs:
322318
timeout-minutes: 10
323319
uses: ./.github/actions/brew
324320
- name: ccache
325-
uses: hendrikmuhs/ccache-action@v1.2
321+
uses: ./.github/actions/ccache
326322
with:
327-
key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}"
328-
append-timestamp: false
329-
save: ${{ github.event_name != 'pull_request' }}
323+
name: "MACOS_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
330324
- name: ./configure
331325
uses: ./.github/actions/configure-macos
332326
with:
@@ -869,11 +863,9 @@ jobs:
869863
bison \
870864
re2c
871865
- name: ccache
872-
uses: hendrikmuhs/ccache-action@v1.2
866+
uses: ./.github/actions/ccache
873867
with:
874-
key: "${{github.job}}-${{hashFiles('php/main/php_version.h')}}"
875-
append-timestamp: false
876-
save: ${{ github.event_name != 'pull_request' }}
868+
name: "${{ github.job }}"
877869
- name: build PHP
878870
run: |
879871
cd php

.github/workflows/push.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ jobs:
8282
re2c \
8383
valgrind
8484
- name: ccache
85-
uses: hendrikmuhs/ccache-action@v1.2
85+
uses: ./.github/actions/ccache
8686
with:
87-
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
88-
append-timestamp: false
89-
save: ${{ github.event_name != 'pull_request' }}
87+
name: "${{ github.job }}"
9088
- name: ./configure
9189
run: |
9290
set -x

.github/workflows/unit-tests.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
steps:
3737
- name: git checkout
3838
uses: actions/checkout@v6
39-
39+
4040
- name: Install dependencies
4141
run: |
4242
set -x
@@ -53,23 +53,20 @@ jobs:
5353
ccache
5454
5555
- name: ccache
56-
uses: hendrikmuhs/ccache-action@v1.2
56+
uses: ./.github/actions/ccache
5757
with:
58-
key: "unit-tests-${{hashFiles('main/php_version.h')}}"
59-
append-timestamp: false
60-
save: ${{ github.event_name != 'pull_request' }}
61-
58+
name: "${{ github.job }}"
59+
6260
- name: ./configure (minimal build)
6361
uses: ./.github/actions/configure-unit-tests
64-
62+
6563
- name: make libphp.a
6664
run: |
6765
set -x
6866
make -j$(/usr/bin/nproc) >/dev/null
69-
67+
7068
- name: Run unit tests
7169
run: |
7270
set -x
7371
cd tests/unit
7472
make test
75-

0 commit comments

Comments
 (0)