on master help sign in
Give up and use cachix
commit5b6f93bd974dc2544c6d028f0c4937cf9f63c7b2 authoriko <ilyakooo0@gmail.com> dateFri 24 Dec 2021, 12:07 (5 years ago) parente587b2f
4 files changed+34−127
.github/actions/common_setup/action.yaml+30−9 .github/actions/nix_cache/action.yaml−47 .github/actions/nix_cache_post/action.yaml−11 .github/workflows/github-actions-image.yaml+4−60
.github/actions/common_setup/action.yaml+30−9
@@ -1,15 +1,37 @@
11name: "Common setup"
22description: "Common setup steps"
33inputs:
4− key:
5− description: "Caching key"
4+ authToken:
5+ description: "Cachix auth token"
66 required: true
7− restore-keys:
8− description: "Restore keys"
9− required: false
107runs:
118 using: "composite"
129 steps:
10+ - name: Increase swap if linux
11+ shell: bash
12+ run: |
13+ if [ "$RUNNER_OS" == "Linux" ]; then
14+
15+ echo "Is Linux"
16+
17+ free -h
18+
19+ sudo swapoff /mnt/swapfile
20+ sudo fallocate -l 12G /mnt/swapfile
21+ sudo mkswap /mnt/swapfile
22+ sudo swapon /mnt/swapfile
23+
24+ free -h
25+
26+ else
27+
28+ echo "Not Linux"
29+
30+ fi
31+
32+ - uses: actions/checkout@v2
33+ with:
34+ submodules: recursive
1335 - name: Install Nix
1436 uses: cachix/install-nix-action@v16
1537 with:
@@ -17,8 +39,7 @@ runs:
1739 system-features = kvm
1840 trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
1941 substituters = https://hydra.iohk.io https://cache.nixos.org/
20− - name: Cache Nix
21− uses: ./.github/actions/nix_cache
42+ - uses: cachix/cachix-action@v10
2243 with:
23− key: ${{ inputs.key }}
24− restore-keys: ${{ inputs.restore-keys }}
44+ name: typeable
45+ authToken: "${{ inputs.authToken }}"
.github/actions/nix_cache/action.yamldeleted−47
@@ -1,47 +0,0 @@
1−name: "Nix cache"
2−description: "Cache nix build"
3−inputs:
4− key:
5− description: "Caching key"
6− required: true
7− restore-keys:
8− description: "Restore keys"
9− required: false
10− default: ""
11−runs:
12− using: "composite"
13− steps:
14− # - name: Install Nix
15− # uses: cachix/install-nix-action@v16
16− # with:
17− # extra_nix_config: |
18− # system-features = kvm
19− # trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
20− # substituters = https://hydra.iohk.io https://cache.nixos.org/
21− - name: Install Nix
22− uses: cachix/install-nix-action@v16
23− with:
24− extra_nix_config: |
25− system-features = kvm
26− trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
27− substituters = https://hydra.iohk.io https://cache.nixos.org/
28− - name: Cache Nix
29− id: cache-nix
30− uses: actions/cache@v2.1.7
31− with:
32− path: |
33− ~/nix/store/
34− ~/nix/var/nix/db/db.sqlite
35− key: ${{ inputs.key }}
36− restore-keys: ${{ inputs.restore-keys }}
37− - name: make nix store writable
38− shell: bash
39− run: |
40− ls ~
41− echo
42− if [[ -d ~/nix ]]; then
43− echo "in"
44− ls ~/nix
45− sudo mv -f ~/nix/store /nix/store
46− sudo mv -f ~/nix/var/nix/db/db.sqlite /nix/var/nix/db/db.sqlite
47− fi
.github/actions/nix_cache_post/action.yamldeleted−11
@@ -1,11 +0,0 @@
1−name: "Nix cache post"
2−description: "Cache nix build post"
3−runs:
4− using: "composite"
5− steps:
6− - name: Move nix store
7− shell: bash
8− run: |
9− mkdir -p ~/nix ~/nix/var/nix/db/
10− mv -f /nix/store ~/nix/store
11− sudo mv -f /nix/var/nix/db/db.sqlite ~/nix/var/nix/db/db.sqlite
.github/workflows/github-actions-image.yaml+4−60
@@ -12,30 +12,11 @@ jobs:
1212 Linux:
1313 runs-on: ubuntu-latest
1414 steps:
15− - name: Increase swap
16− shell: bash
17− run: |
18− free -h
19−
20− sudo swapoff /mnt/swapfile
21− sudo fallocate -l 12G /mnt/swapfile
22− sudo mkswap /mnt/swapfile
23− sudo swapon /mnt/swapfile
24−
25− free -h
26−
27− - uses: actions/checkout@v2
28− with:
29− submodules: recursive
30−
3115 - name: Common setup
3216 uses: ./.github/actions/common_setup
3317 with:
34− key: Linux-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
35− restore-keys: |
36− Linux-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}
37− Linux-${{ hashFiles('**.nix') }}
38− Linux
18+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
19+
3920 - name: Build Linux static binary
4021 shell: bash
4122 run: |
@@ -113,24 +94,13 @@ jobs:
11394 asset_name: compaREST binary – Linux – x86
11495 tag: ${{ github.ref }}
11596
116− - name: Cahce post
117− uses: ./.github/actions/nix_cache_post
118−
11997 macOS:
12098 runs-on: macos-latest
12199 steps:
122− - uses: actions/checkout@v2
123− with:
124− submodules: recursive
125−
126100 - name: Common setup
127101 uses: ./.github/actions/common_setup
128102 with:
129− key: macOS-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
130− restore-keys: |
131− macOS-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}
132− macOS-${{ hashFiles('**.nix') }}
133− macOS
103+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
134104
135105 - name: Build macOS binary bundle
136106 run: |
@@ -151,36 +121,13 @@ jobs:
151121 asset_name: compaREST binary – macOS – x86
152122 tag: ${{ github.ref }}
153123
154− - name: Cahce post
155− uses: ./.github/actions/nix_cache_post
156−
157124 Linux-Windows:
158125 runs-on: ubuntu-latest
159126 steps:
160− - name: Increase swap
161− shell: bash
162− run: |
163− free -h
164−
165− sudo swapoff /mnt/swapfile
166− sudo fallocate -l 12G /mnt/swapfile
167− sudo mkswap /mnt/swapfile
168− sudo swapon /mnt/swapfile
169−
170− free -h
171−
172− - uses: actions/checkout@v2
173− with:
174− submodules: recursive
175−
176127 - name: Common setup
177128 uses: ./.github/actions/common_setup
178129 with:
179− key: Linux-Windows-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
180− restore-keys: |
181− Linux-Windows-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}
182− Linux-Windows-${{ hashFiles('**.nix') }}
183− Linux-Windows
130+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
184131
185132 - name: Build Windows binary
186133 run: |
@@ -200,6 +147,3 @@ jobs:
200147 file: compaREST
201148 asset_name: compaREST binary – Windows
202149 tag: ${{ github.ref }}
203−
204− - name: Cahce post
205− uses: ./.github/actions/nix_cache_post