Skip to content

Commit 6b1cf14

Browse files
committed
ci: persist ccache across ephemeral runner pods via actions/cache
1 parent 1e4c1c6 commit 6b1cf14

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

.github/workflows/cuda.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
name: Test on CUDA Build
1818
runs-on: gpu
1919
if: github.repository_owner == 'deepmodeling'
20+
env:
21+
CCACHE_BASEDIR: ${{ github.workspace }}
22+
CCACHE_MAXSIZE: 5G
2023
container:
2124
image: ghcr.io/deepmodeling/abacus-cuda
2225
volumes:
@@ -29,10 +32,18 @@ jobs:
2932
with:
3033
submodules: recursive
3134

35+
- name: Report runner info
36+
run: |
37+
echo "runner_name=$RUNNER_NAME"
38+
case "$RUNNER_NAME" in
39+
gpu-runner-*) echo "runner_type=pod" ;;
40+
*) echo "runner_type=vm" ;;
41+
esac
42+
3243
- name: Install CI tools
3344
run: |
3445
sudo apt-get update
35-
sudo apt-get install -y ccache xz-utils ninja-build pkg-config
46+
sudo apt-get install -y ccache xz-utils ninja-build pkg-config zstd
3647
3748
- name: Install external tools from toolchain
3849
run: |
@@ -41,6 +52,28 @@ jobs:
4152
./scripts/stage4/install_stage4.sh
4253
cd ..
4354
55+
- name: Restore ccache
56+
id: ccache
57+
uses: actions/cache/restore@v4
58+
with:
59+
path: /tmp/ccache.tar.zst
60+
key: ccache-cuda-${{ github.sha }}
61+
restore-keys: |
62+
ccache-cuda-
63+
64+
- name: Unpack ccache
65+
run: |
66+
if [ -f /tmp/ccache.tar.zst ]; then
67+
sudo mkdir -p /github/home/.ccache
68+
sudo tar -I zstd -xf /tmp/ccache.tar.zst -C /github/home
69+
sudo chown -R $(whoami) /github/home/.ccache
70+
fi
71+
72+
- name: ccache stats (before build)
73+
run: |
74+
ccache --zero-stats || true
75+
ccache -s
76+
4477
- name: Configure & Build
4578
run: |
4679
nvidia-smi
@@ -51,6 +84,21 @@ jobs:
5184
cmake --build build -j "$(nproc)"
5285
cmake --install build
5386
87+
- name: ccache stats (after build)
88+
if: always()
89+
run: ccache -s
90+
91+
- name: Pack ccache
92+
if: always()
93+
run: tar -I 'zstd -T0' -cf /tmp/ccache.tar.zst -C /github/home .ccache
94+
95+
- name: Save ccache
96+
if: always()
97+
uses: actions/cache/save@v4
98+
with:
99+
path: /tmp/ccache.tar.zst
100+
key: ccache-cuda-${{ github.sha }}
101+
54102
- name: Module_LCAO CUDA Unittests
55103
env:
56104
GTEST_COLOR: 'yes'

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
name: Test
1717
runs-on: X64
1818
if: github.repository_owner == 'deepmodeling'
19+
env:
20+
CCACHE_BASEDIR: ${{ github.workspace }}
21+
CCACHE_MAXSIZE: 5G
1922
container:
2023
image: ghcr.io/deepmodeling/abacus-gnu
2124
volumes:
@@ -33,12 +36,21 @@ jobs:
3336
sudo chown -R $(whoami) .
3437
git submodule update --init --recursive
3538
39+
- name: Report runner info
40+
run: |
41+
echo "runner_name=$RUNNER_NAME"
42+
case "$RUNNER_NAME" in
43+
gpu-runner-*) echo "runner_type=pod" ;;
44+
*) echo "runner_type=vm" ;;
45+
esac
46+
3647
- name: Install CI tools
3748
run: |
3849
sudo apt-get update
3950
sudo apt-get install -y \
4051
gfortran \
4152
ccache \
53+
zstd \
4254
ca-certificates \
4355
pkg-config \
4456
python-is-python3 \
@@ -54,6 +66,28 @@ jobs:
5466
./scripts/stage4/install_stage4.sh
5567
cd ..
5668
69+
- name: Restore ccache
70+
id: ccache
71+
uses: actions/cache/restore@v4
72+
with:
73+
path: /tmp/ccache.tar.zst
74+
key: ccache-gnu-${{ github.sha }}
75+
restore-keys: |
76+
ccache-gnu-
77+
78+
- name: Unpack ccache
79+
run: |
80+
if [ -f /tmp/ccache.tar.zst ]; then
81+
sudo mkdir -p /github/home/.ccache
82+
sudo tar -I zstd -xf /tmp/ccache.tar.zst -C /github/home
83+
sudo chown -R $(whoami) /github/home/.ccache
84+
fi
85+
86+
- name: ccache stats (before build)
87+
run: |
88+
ccache --zero-stats || true
89+
ccache -s
90+
5791
- name: Configure
5892
run: |
5993
source toolchain/install/setup
@@ -85,6 +119,21 @@ jobs:
85119
cmake --build build -j8
86120
cmake --install build
87121
122+
- name: ccache stats (after build)
123+
if: always()
124+
run: ccache -s
125+
126+
- name: Pack ccache
127+
if: always()
128+
run: tar -I 'zstd -T0' -cf /tmp/ccache.tar.zst -C /github/home .ccache
129+
130+
- name: Save ccache
131+
if: always()
132+
uses: actions/cache/save@v4
133+
with:
134+
path: /tmp/ccache.tar.zst
135+
key: ccache-gnu-${{ github.sha }}
136+
88137
- name: Check documentation consistency
89138
run: |
90139
ABACUS_BIN=$(find build -name "abacus_*" -type f -executable | head -1)

0 commit comments

Comments
 (0)