Skip to content

Commit 60e89d9

Browse files
committed
Added periodic workflow to keep LLVM build cache warm.
1 parent 36efa34 commit 60e89d9

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

.github/workflows/ClangSharp.Pathogen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- name: Load cached LLVM build outputs
6363
id: cached-llvm
6464
uses: actions/cache@v2
65+
# If you change this configuration make sure to update keep-cache-warm.yml as well.
6566
with:
6667
key: llvm-output-${{runner.os}}-${{steps.llvm.outputs.revision}}
6768
# These are the paths of the external files required in ClangSharp.Pathogen.Runtime.csproj
@@ -83,6 +84,7 @@ jobs:
8384
id: cached-sccache
8485
if: steps.cached-llvm.outputs.cache-hit != 'true'
8586
uses: actions/cache@v2
87+
# If you change this configuration make sure to update keep-cache-warm.yml as well.
8688
with:
8789
path: ${{steps.sccache.outputs.root-directory}}
8890
key: sccache-cache-${{runner.os}}-${{steps.llvm.outputs.revision}}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Normally GitHub automatically evicts cache entires which have not been accessed in over a week.
2+
# This can be pretty annoying for this repo because it takes around 2 hours to build LLVM from scratch.
3+
# This periodic workflow keeps the cache from expiring.
4+
#
5+
# Note that this workflow uses a fork of the GitHub Actions Cache action.
6+
# This fork disables the action's logic for saving the cache at the end of the workflow, which is important here since we just want to restore it to keep it alive.
7+
# Also note that internally the cache key depends on the paths used, so we need those to match the main workflow as well.
8+
name: Keep cache warm
9+
on:
10+
schedule:
11+
# The general intent here is that this workflow runs every 5 days.
12+
# However this can't actually be expressed with cron syntax since it operates on a calendar and has no knowledge of when the last run was.
13+
# As such it actually runs on the 1st of the month and every day-of-month which is a multiple of 5.
14+
# The reason we run it on the 1st of the month is because we'd end up letting the cache expire between February and March since there would be too much
15+
# time between February 25th and March 5th.
16+
# https://crontab.guru/#0_8_1,*/5_*_*
17+
- cron: '0 8 1,*/5 * *'
18+
workflow_dispatch:
19+
jobs:
20+
warm-cache:
21+
# This entire strategy is copy+pasted from the main build workflow
22+
# Ideally we wouldn't need a build matirx for this, but it makes it easier to share the configuration between this file and the main workflow
23+
# Additionally, the paths used for the cache are internally considered part of the key and as such must match and some are OS-depndent.
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- os: windows-latest
29+
name: Windows
30+
lib-path: build/bin/libclang.dll
31+
build-command: ./build-native.cmd
32+
artifact-name: LlvmBuildOutputs-Windows
33+
# We use Ubuntu 18.04 so that the binary is usable on systems using glibc 2.27 and later
34+
# If we want to support even older versions we should explore building libclang with https://github.com/wheybags/glibc_version_header
35+
- os: ubuntu-18.04
36+
name: Linux
37+
lib-path: build-linux/lib/libclang.so
38+
clang-resource-dir: build-linux/lib/clang/
39+
build-command: ./build-native.sh
40+
artifact-name: LlvmBuildOutputs-Linux
41+
name: Warm cache - ${{matrix.name}}
42+
runs-on: ${{matrix.os}}
43+
steps:
44+
# ----------------------------------------------------------------------- Checkout
45+
- name: Checkout
46+
# We intentionally don't checkout submodules here
47+
# They will be restored as needed only if we need to build LLVM.
48+
uses: actions/checkout@v2
49+
50+
# ----------------------------------------------------------------------- Setup Python
51+
- name: Setup Python 3.8
52+
uses: actions/setup-python@v2
53+
with:
54+
python-version: '3.8'
55+
56+
# ----------------------------------------------------------------------- Get LLVM Revision
57+
- name: Get LLVM Revision
58+
id: llvm
59+
run: python .github/workflows/get-llvm-revision.py
60+
61+
# ----------------------------------------------------------------------- Install sccache
62+
# (This is necessary because we need the location used for the cache root later on)
63+
- name: Install sccache
64+
id: sccache
65+
run: python .github/workflows/install-sccache.py
66+
67+
# ----------------------------------------------------------------------- Warm LLVM build outputs
68+
- name: Load cached LLVM build outputs
69+
id: cached-llvm
70+
uses: PathogenDavid/cache@no-save-v2
71+
with:
72+
key: llvm-output-${{runner.os}}-${{steps.llvm.outputs.revision}}
73+
path: |
74+
${{matrix.lib-path}}
75+
${{matrix.clang-resource-dir}}
76+
77+
# ----------------------------------------------------------------------- Warm sccache cache
78+
- name: Load LLVM sccache
79+
id: cached-sccache
80+
uses: PathogenDavid/cache@no-save-v2
81+
with:
82+
path: ${{steps.sccache.outputs.root-directory}}
83+
key: sccache-cache-${{runner.os}}-${{steps.llvm.outputs.revision}}
84+
restore-keys: sccache-cache-${{runner.os}}-

ClangSharp.Pathogen.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31612.314
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClangSharp.Pathogen", "ClangSharp.Pathogen\ClangSharp.Pathogen.csproj", "{ADCA9D07-0CAB-4D1F-92DD-69189D520EFB}"
77
EndProject

0 commit comments

Comments
 (0)