forked from MochiLibraries/ClangSharp.Pathogen
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (92 loc) · 4.69 KB
/
keep-cache-warm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Normally GitHub automatically evicts cache entires which have not been accessed in over a week.
# This can be pretty annoying for this repo because it takes around 2 hours to build LLVM from scratch.
# This periodic workflow keeps the cache from expiring.
#
# Note that this workflow uses a fork of the GitHub Actions Cache action.
# 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.
# Also note that internally the cache key depends on the paths used, so we need those to match the main workflow as well.
name: Keep cache warm
on:
schedule:
# The general intent here is that this workflow runs every 5 days.
# 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.
# As such it actually runs on the 1st of the month and every day-of-month which is a multiple of 5.
# 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
# time between February 25th and March 5th.
# https://crontab.guru/#0_8_1,*/5_*_*
- cron: '0 8 1,*/5 * *'
workflow_dispatch:
jobs:
warm-cache:
# This entire strategy is copy+pasted from the main build workflow
# 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
# Additionally, the paths used for the cache are internally considered part of the key and as such must match and some are OS-depndent.
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
name: Windows x64
rid: win-x64
libclang-subpath: bin/libclang.dll
build-command: ./build-native.cmd
# We use Ubuntu 18.04 so that the binary is usable on systems using glibc 2.27 and later
# If we want to support even older versions we should explore building libclang with https://github.com/wheybags/glibc_version_header
- os: ubuntu-18.04
name: Linux x64
rid: linux-x64
libclang-subpath: lib/libclang.so
build-command: ./build-native.sh
- os: ubuntu-arm64-latest
name: Linux ARM64
rid: linux-arm64
libclang-subpath: lib/libclang.so
build-command: ./build-native.sh
skip-python-install: true
- os: macos-12
name: macOS x64
rid: osx-x64
libclang-subpath: lib/libclang.dylib
build-command: ./build-native.sh
name: Warm cache - ${{matrix.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
# We intentionally don't checkout submodules here
# They will be restored as needed only if we need to build LLVM.
uses: actions/checkout@v2
# ----------------------------------------------------------------------- Setup Python
- name: Setup Python 3.8
if: matrix.skip-python-install != true
uses: actions/setup-python@v2
with:
python-version: '3.8'
# ----------------------------------------------------------------------- Get LLVM Revision
- name: Get LLVM Revision
id: llvm
run: python .github/workflows/get-llvm-revision.py
# ----------------------------------------------------------------------- Install sccache
# (This is necessary because we need the location used for the cache root later on)
- name: Install sccache
id: sccache
run: python .github/workflows/install-sccache.py
# ----------------------------------------------------------------------- Warm LLVM build outputs
- name: Load cached LLVM build outputs
id: cached-llvm
uses: PathogenDavid/cache@no-save-v2
with:
key: llvm-output-${{matrix.rid}}-${{steps.llvm.outputs.revision}}
path: |
bin/llvm/${{matrix.rid}}/${{matrix.libclang-subpath}}
bin/llvm/${{matrix.rid}}/lib/clang/
external/llvm-project/clang/LICENSE.TXT
external/llvm-project/clang/tools/libclang/libClangSharp/LICENSE.md
# ----------------------------------------------------------------------- Warm sccache cache
- name: Load LLVM sccache
id: cached-sccache
uses: PathogenDavid/cache@no-save-v2
with:
path: ${{steps.sccache.outputs.root-directory}}
key: sccache-cache-${{matrix.rid}}-${{steps.llvm.outputs.revision}}
restore-keys: sccache-cache-${{matrix.rid}}-