Skip to content

Commit 0dc123e

Browse files
committed
Improve GH build workflow
- Cache build files - Use output of `git describe` in output filename
1 parent c2419b3 commit 0dc123e

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ${{ matrix.runner }}
2020
name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }}
2121
env:
22-
ARTIFACT_NAME: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }}
22+
BUILD_ID: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }}
2323
strategy:
2424
fail-fast: false
2525
matrix:
@@ -128,11 +128,17 @@ jobs:
128128
# ${{ matrix.platform }}-${{ github.ref }}
129129
# ${{ matrix.platform }}
130130

131+
- name: Scons Cache
132+
id: scons-cache
133+
uses: actions/cache@v4
134+
with:
135+
path: .scons-cache
136+
key: ${{ env.BUILD_ID }}
137+
131138
- name: Compile extension
132139
shell: sh
133-
# env:
134-
# SCONS_CACHE: '${{ github.workspace }}/.scons-cache/'
135-
# SCONS_CACHE_LIMIT: 8192
140+
env:
141+
SCONS_CACHE: .scons-cache
136142
run: |
137143
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2
138144
ls -l demo/addons/*/bin/
@@ -147,15 +153,18 @@ jobs:
147153
- name: Upload artifact
148154
uses: actions/upload-artifact@v4
149155
with:
150-
name: build-${{ env.ARTIFACT_NAME }}
156+
name: build-${{ env.BUILD_ID }}
151157
path: |
152158
${{ github.workspace }}/demo/
153159
merge:
154160
runs-on: ubuntu-latest
155161
needs: build
156162
steps:
163+
- name: Git describe
164+
id: ghd
165+
uses: proudust/gh-describe@v2
157166
- name: Merge Artifacts
158167
uses: actions/upload-artifact/merge@v4
159168
with:
160-
name: ${{ github.event.repository.name }}
169+
name: ${{ github.event.repository.name }}-${{ steps.ghd.outputs.describe }}
161170
pattern: build-*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.scons_cache_debug
12
.vim
23
*.pyc
34
*.idx

SConstruct

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ opts.Update(env)
2929
env.Append(CCFLAGS="-fdiagnostics-color")
3030

3131

32+
scons_cache_path = os.environ.get("SCONS_CACHE")
33+
if scons_cache_path:
34+
os.makedirs(scons_cache_path, exist_ok=True)
35+
CacheDir(scons_cache_path)
36+
print("Using cache dir:", scons_cache_path)
37+
38+
3239
# Sources
3340
env.Append(CPPPATH=["src/"])
3441
sources = Glob("src/*.cpp")

compile_debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
scons compiledb=yes optimize=debug use_llvm=yes
3+
SCONS_CACHE="$PWD/.scons_cache_debug" scons compiledb=yes optimize=debug use_llvm=yes "$@"

compile_release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
scons optimize=speed target=template_release
3+
scons optimize=speed target=template_release "$@"

0 commit comments

Comments
 (0)