-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (119 loc) · 4.18 KB
/
holonix-cache.yaml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: "Holonix cache"
on:
# Assume pushes to these branches imply changes that should be cached. If not then the workflow run will be
# idempotent, so it won't do any harm.
push:
branches:
- main
- main-0.4
- main-0.3
workflow_call:
inputs:
branch:
required: true
type: string
# Allow the cache update to be run manually.
workflow_dispatch:
inputs:
branch:
description: "The branch to update the cache for"
required: true
default: "main"
type: choice
options:
- main
- main-0.4
- main-0.3
concurrency:
group: ${{ github.workflow }}-${{ inputs.branch }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
# ensures the cache is regularly updated for the supported versions on multiple platforms
cache-update:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, macos-13 ]
runs-on: ${{ matrix.os }}
steps:
- uses: cachix/install-nix-action@v30
with:
install_url: https://releases.nixos.org/nix/nix-2.24.9/install
extra_nix_config: |
accept-flake-config = true
- uses: cachix/cachix-action@v15
with:
name: holochain-ci
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Maximize build space (Linux)
if: runner.os == 'Linux'
uses: AdityaGarg8/remove-unwanted-software@v4
with:
remove-dotnet: 'true'
remove-android: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Maximise build space (Mac OS)
if: runner.os == 'macOS'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Check disk space before
run: df -h /
- name: Extract branch name
id: select_branch
shell: bash
run: |
# Figure out what branch was used to trigger the workflow (i.e. the `push` trigger)
changed_branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# Get the input branch override if it exists. This will be set if the workflow is triggered manually or by a
# workflow call.
input_branch='${{ inputs.branch }}'
# Pick a branch to work with, preferring the input branch if it exists.
echo "branch=${input_branch:-$changed_branch}" >> $GITHUB_OUTPUT
- name: Cache default Holonix flake on [${{ steps.select_branch.outputs.branch }}]
env:
# NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}"
CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_AUTH_TOKEN }}"
run: |
# See https://docs.cachix.org/pushing#id1
nix develop --build -L --profile result-develop "github:holochain/holonix?ref=${{ steps.select_branch.outputs.branch }}"
# Push both results to the cache
for i in result-*; do
cachix push holochain-ci $i
done
outputs:
branch: ${{ steps.select_branch.outputs.branch }}
cache-check:
needs:
- cache-update
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, macos-13 ]
include:
- os: ubuntu-latest
platform: x86_64-linux
- os: macos-latest
platform: aarch64-darwin
- os: macos-13
platform: x86_64-darwin
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v30
with:
install_url: https://releases.nixos.org/nix/nix-2.24.9/install
extra_nix_config: |
accept-flake-config = true
- uses: cachix/cachix-action@v15
with:
name: holochain-ci
- name: Check the Holonix cache
uses: holochain/nix-cache-check@v1
# env:
# NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}"
with:
# The default shell in the Holonix flake
derivation: "github:holochain/holonix?ref=${{ needs.cache-update.outputs.branch }}#devShells.${{ matrix.platform }}.default"