Skip to content

Commit 352bdf5

Browse files
committed
workflows: improve caching
1 parent ad40730 commit 352bdf5

4 files changed

Lines changed: 70 additions & 6 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build Cached Template
2+
3+
on:
4+
push:
5+
paths:
6+
- 'source/**'
7+
- 'premake5.lua'
8+
- '.github/workflows/compile.yml'
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build_cached:
14+
uses: RaphaelIT7/gmod-common-module-base/.github/workflows/compile.yml@workflow
15+
with:
16+
PROJECT_NAME: "template"
17+
BUILD_64x: "true"
18+
REALM: "sv"
19+
ARTIFACT_EXPIRE: "1"
20+
BUILD_CACHE: "true"

.github/workflows/compile.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,14 @@ jobs:
243243
uses: actions/cache@v4
244244
with:
245245
path: /github/home/.cache/ccache
246-
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x-ccache-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.hxx', '**/*.cxx', '**/*.c', '**/premake5.lua') }}
246+
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x-ccache-${{ hashFiles(
247+
format('{0}**/*.cpp', inputs.PROJECT_PATH),
248+
format('{0}**/*.h', inputs.PROJECT_PATH),
249+
format('{0}**/*.hxx', inputs.PROJECT_PATH),
250+
format('{0}**/*.cxx', inputs.PROJECT_PATH),
251+
format('{0}**/*.c', inputs.PROJECT_PATH),
252+
format('{0}**/premake5.lua', inputs.PROJECT_PATH)
253+
) }}
247254
restore-keys: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x-ccache
248255

249256
- name: Generate Project
@@ -263,6 +270,10 @@ jobs:
263270
export CXX="ccache g++"
264271
make ${{inputs.ADDITIONAL_ARGS_32x}}
265272
273+
- name: Show ccache stats
274+
if: inputs.BUILD_CACHE == 'true'
275+
run: ccache -s
276+
266277
- uses: actions/upload-artifact@v4
267278
name: Upload ${{env.PROJECT_NAME_LINUX32}}.${{inputs.LINUX_FILEEXTENTION}} (Artifact)
268279
if: inputs.UPLOAD == 'artifact'
@@ -363,7 +374,14 @@ jobs:
363374
uses: actions/cache@v4
364375
with:
365376
path: /github/home/.cache/ccache
366-
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x-ccache-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.hxx', '**/*.cxx', '**/*.c', '**/premake5.lua') }}
377+
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x-ccache-${{ hashFiles(
378+
format('{0}**/*.cpp', inputs.PROJECT_PATH),
379+
format('{0}**/*.h', inputs.PROJECT_PATH),
380+
format('{0}**/*.hxx', inputs.PROJECT_PATH),
381+
format('{0}**/*.cxx', inputs.PROJECT_PATH),
382+
format('{0}**/*.c', inputs.PROJECT_PATH),
383+
format('{0}**/premake5.lua', inputs.PROJECT_PATH)
384+
) }}
367385
restore-keys: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x-ccache
368386

369387
- name: Generate Project
@@ -383,6 +401,10 @@ jobs:
383401
export CXX="ccache g++"
384402
make config=releasewithsymbols_x86_64 ${{inputs.ADDITIONAL_ARGS_64x}}
385403
404+
- name: Show ccache stats
405+
if: inputs.BUILD_CACHE == 'true'
406+
run: ccache -s
407+
386408
- uses: actions/upload-artifact@v4
387409
name: Upload ${{env.PROJECT_NAME_LINUX64}}.${{inputs.LINUX_FILEEXTENTION}} (Artifact)
388410
if: inputs.UPLOAD == 'artifact'
@@ -487,7 +509,14 @@ jobs:
487509
uses: actions/cache@v4
488510
with:
489511
path: ${{ inputs.PROJECT_PATH }}projects/
490-
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x-ccache-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.hxx', '**/*.cxx', '**/*.c', '**/premake5.lua') }}
512+
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x-ccache-${{ hashFiles(
513+
format('{0}**/*.cpp', inputs.PROJECT_PATH),
514+
format('{0}**/*.h', inputs.PROJECT_PATH),
515+
format('{0}**/*.hxx', inputs.PROJECT_PATH),
516+
format('{0}**/*.cxx', inputs.PROJECT_PATH),
517+
format('{0}**/*.c', inputs.PROJECT_PATH),
518+
format('{0}**/premake5.lua', inputs.PROJECT_PATH)
519+
) }}
491520
restore-keys: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-32x
492521

493522
- name: Generate Project
@@ -579,7 +608,14 @@ jobs:
579608
uses: actions/cache@v4
580609
with:
581610
path: ${{ inputs.PROJECT_PATH }}projects/
582-
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x-ccache-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.hxx', '**/*.cxx', '**/*.c', '**/premake5.lua') }}
611+
key: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x-ccache-${{ hashFiles(
612+
format('{0}**/*.cpp', inputs.PROJECT_PATH),
613+
format('{0}**/*.h', inputs.PROJECT_PATH),
614+
format('{0}**/*.hxx', inputs.PROJECT_PATH),
615+
format('{0}**/*.cxx', inputs.PROJECT_PATH),
616+
format('{0}**/*.c', inputs.PROJECT_PATH),
617+
format('{0}**/premake5.lua', inputs.PROJECT_PATH)
618+
) }}
583619
restore-keys: ${{ runner.os }}-${{ inputs.PROJECT_NAME }}-64x
584620

585621
- name: Generate Project

docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ RUN echo "path-exclude /usr/share/man/*" >> /etc/dpkg/dpkg.cfg.d/excludes && \
2323
ENV CC="ccache gcc"
2424
ENV CXX="ccache g++"
2525
ENV PATH="/usr/lib/ccache:$PATH"
26-
27-
RUN ccache -M 200M
26+
ENV CCACHE_COMPILERCHECK=content
27+
ENV CCACHE_SLOPPINESS=time_macros
28+
RUN ccache -M 1G && ccache -z
2829

2930
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
3031
RUN chmod +x /usr/local/bin/entrypoint.sh

docker/Dockerfile_64

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ RUN echo "path-exclude /usr/share/man/*" >> /etc/dpkg/dpkg.cfg.d/excludes && \
1919
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX && \
2020
rm -rf /var/lib/apt/lists/* /usr/share/* /usr/sbin/* /var/cache/* /var/log/* /var/tmp/* /var/lib/dpkg/info/*
2121

22+
ENV CC="ccache gcc"
23+
ENV CXX="ccache g++"
24+
ENV PATH="/usr/lib/ccache:$PATH"
25+
ENV CCACHE_COMPILERCHECK=content
26+
ENV CCACHE_SLOPPINESS=time_macros
27+
RUN ccache -M 1G && ccache -z
28+
2229
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
2330
RUN chmod +x /usr/local/bin/entrypoint.sh
2431

0 commit comments

Comments
 (0)