Skip to content

Commit ecac7f4

Browse files
committed
Use cabal-cache
1 parent 7e3097f commit ecac7f4

File tree

2 files changed

+80
-73
lines changed

2 files changed

+80
-73
lines changed

Diff for: .github/workflows/github-page.yml

+43-35
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,41 @@ jobs:
2121
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
2222

2323
steps:
24-
- uses: actions/checkout@v1
24+
# this seems to break something. It _must_ come after the pacman setup
25+
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
26+
# as such we'd need pacman.exe instead.
27+
- name: Setup Haskell
28+
run: |
29+
# Use GHCUP to manage ghc/cabal
30+
ghcup install ghc --set ${{ matrix.ghc }}
31+
ghcup install cabal --set 3.8.1.0
2532
26-
- name: Set cache version
27-
run: echo "CACHE_VERSION=UN37rUo" >> $GITHUB_ENV
33+
ghc --version
34+
cabal --version
2835
29-
- name: Add build script path
30-
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
36+
- name: "Setup cabal-store"
37+
id: cabal-store
38+
shell: bash
39+
run: |
40+
cabal help user-config
41+
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)"
3142
32-
- uses: haskell/actions/setup@v1
33-
id: setup-haskell
34-
with:
35-
ghc-version: ${{ matrix.ghc }}
36-
cabal-version: 3.6.2.0
43+
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
3744
38-
- name: Haskell versions
39-
run: |
40-
ghc --version
41-
cabal --version
45+
- uses: actions/checkout@v2
46+
47+
- name: Add build script path
48+
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
4249

4350
- name: Install build environment
44-
if: matrix.os == 'ubuntu-latest'
4551
run: |
4652
sudo apt-get update
4753
sudo apt-get -y install libsodium23 libsodium-dev
4854
sudo apt-get -y install libsystemd0 libsystemd-dev
4955
sudo apt-get -y remove --purge software-properties-common
5056
sudo apt-get -y autoremove
5157
52-
- name: "LINUX: Install secp256k1"
53-
if: runner.os != 'Windows'
58+
- name: "Install secp256k1"
5459
shell: bash
5560
env:
5661
CI_SECP_FLAGS: "--prefix=/usr"
@@ -60,13 +65,6 @@ jobs:
6065
- name: Cabal update
6166
run: cabal update
6267

63-
- name: Disable reorder goals on MacOS and Linux
64-
# Avoid reorder goals for platforms that don't need it because re-order goals can take up to 10 minutes
65-
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
66-
run: |
67-
cat cabal.project | sed 's|reorder-goals: True|reorder-goals: False|g' > cabal.project.tmp
68-
mv cabal.project.tmp cabal.project
69-
7068
- name: combine github-pages, and machine local project files.
7169
run: |
7270
cat .github/workflows/cabal.project.local.github-pages \
@@ -79,18 +77,28 @@ jobs:
7977
mkdir ./haddocks
8078
DRY_RUN=1 ./scripts/haddocs.sh ./haddocks true
8179
82-
- name: Record dependencies
83-
run: |
84-
cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
85-
86-
- uses: actions/cache@v2
87-
name: Cache cabal store
80+
- name: Cabal cache over S3
81+
uses: action-works/cabal-cache-s3@v1
82+
env:
83+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
84+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
85+
with:
86+
region: us-west-2
87+
dist-dir: dist-newstyle
88+
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
89+
threads: 16
90+
archive-uri: ${{ secrets.BINARY_CACHE_URI }}
91+
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"
92+
93+
- name: Cabal cache over HTTPS
94+
uses: action-works/cabal-cache-s3@v1
8895
with:
89-
path: ${{ steps.setup-haskell.outputs.cabal-store }}
90-
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
91-
restore-keys: |
92-
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
93-
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-
96+
dist-dir: dist-newstyle
97+
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
98+
threads: 16
99+
archive-uri: https://iohk.cache.haskellworks.io
100+
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"
101+
enable-save: false
94102

95103
- name: Install dependencies
96104
run: cabal build all

Diff for: .github/workflows/haskell.yml

+37-38
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ jobs:
6161
automake `
6262
libtool `
6363
make
64-
64+
6565
# this seems to break something. It _must_ come after the pacman setup
6666
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
6767
# as such we'd need pacman.exe instead.
6868
- name: Setup Haskell
69-
run: |
69+
run: |
7070
# Use GHCUP to manage ghc/cabal
7171
ghcup install ghc --set ${{ matrix.ghc }}
72-
ghcup install cabal --set 3.6.2.0
72+
ghcup install cabal --set 3.8.1.0
7373
7474
ghc --version
7575
cabal --version
@@ -96,19 +96,18 @@ jobs:
9696
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
9797
-f init
9898
99-
- name: "OUTPUT Record cabal-store (Linux)"
100-
id: lin-setup-haskell
101-
if: runner.os != 'Windows'
102-
run: echo "cabal-store=/home/runner/.cabal/store" >> $GITHUB_OUTPUT
103-
104-
- name: "OUTPUT Record cabal-store (Windows)"
105-
id: win-setup-haskell
106-
if: runner.os == 'Windows'
99+
- name: "Setup cabal-store"
100+
id: cabal-store
107101
shell: bash
108-
run: echo "cabal-store=C:\\cabal\\store" >> $GITHUB_OUTPUT
102+
run: |
103+
cabal help user-config
104+
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)"
109105
110-
- name: Set cache version
111-
run: echo "CACHE_VERSION=grFfw7r" >> $GITHUB_ENV
106+
if [[ '${{ runner.os }}' != 'Windows' ]]; then
107+
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
108+
else
109+
echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT"
110+
fi
112111
113112
- uses: actions/checkout@v2
114113

@@ -180,33 +179,31 @@ jobs:
180179
echo "# cabal.project.local"
181180
cat cabal.project.local
182181
183-
- name: Record dependencies
184-
id: record-deps
185-
run: |
186-
cabal build all --dry-run
187-
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
182+
- name: Build dry run
183+
run: cabal build all --dry-run
188184

189-
- name: "OUTPUT Record weeknum"
190-
shell: bash
191-
run: echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT
192-
193-
- name: Cache Cabal store
194-
uses: actions/cache@v2
185+
- name: Cabal cache over S3
186+
uses: action-works/cabal-cache-s3@v1
187+
env:
188+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
189+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
195190
with:
196-
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.lin-setup-haskell.outputs.cabal-store }}
197-
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
198-
restore-keys: |
199-
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
200-
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
201-
202-
- uses: actions/cache@v2
203-
name: "Cache `dist-newstyle`"
191+
region: us-west-2
192+
dist-dir: dist-newstyle
193+
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
194+
threads: 16
195+
archive-uri: ${{ secrets.BINARY_CACHE_URI }}
196+
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"
197+
198+
- name: Cabal cache over HTTPS
199+
uses: action-works/cabal-cache-s3@v1
204200
with:
205-
path: |
206-
dist-newstyle
207-
!dist-newstyle/**/.git
208-
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
209-
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
201+
dist-dir: dist-newstyle
202+
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
203+
threads: 16
204+
archive-uri: https://iohk.cache.haskellworks.io
205+
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"
206+
enable-save: false
210207

211208
- name: Build
212209
run: cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api
@@ -288,6 +285,8 @@ jobs:
288285
# - name: Setup tmate session
289286
# if: ${{ failure() }}
290287
# uses: mxschmitt/action-tmate@v3
288+
# with:
289+
# limit-access-to-actor: true
291290

292291
release:
293292
needs: [build]

0 commit comments

Comments
 (0)