-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use cabal-cache #4717
Use cabal-cache #4717
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,12 +40,6 @@ jobs: | |
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }} | ||
|
||
steps: | ||
- name: Setup tmate session | ||
if: ${{ failure() }} | ||
uses: mxschmitt/action-tmate@v3 | ||
with: | ||
limit-access-to-actor: true | ||
|
||
- name: "WIN: Install System Dependencies via pacman (msys2)" | ||
if: runner.os == 'Windows' | ||
run: | | ||
|
@@ -61,15 +55,15 @@ jobs: | |
automake ` | ||
libtool ` | ||
make | ||
|
||
# this seems to break something. It _must_ come after the pacman setup | ||
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and | ||
# as such we'd need pacman.exe instead. | ||
- name: Setup Haskell | ||
run: | | ||
run: | | ||
# Use GHCUP to manage ghc/cabal | ||
ghcup install ghc --set ${{ matrix.ghc }} | ||
ghcup install cabal --set 3.6.2.0 | ||
ghcup install cabal --set 3.8.1.0 | ||
|
||
ghc --version | ||
cabal --version | ||
|
@@ -96,19 +90,28 @@ jobs: | |
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) ` | ||
-f init | ||
|
||
- name: "OUTPUT Record cabal-store (Linux)" | ||
id: lin-setup-haskell | ||
if: runner.os != 'Windows' | ||
run: echo "cabal-store=/home/runner/.cabal/store" >> $GITHUB_OUTPUT | ||
|
||
- name: "OUTPUT Record cabal-store (Windows)" | ||
id: win-setup-haskell | ||
if: runner.os == 'Windows' | ||
# Unify the computation of the cabal store directory to a single step. This makes referencing the cabal | ||
# store in later steps easier. | ||
# | ||
# We know on cabal store is located in the following locations by OS: | ||
# | ||
# Linux: /home/runner/.cabal/store | ||
# MacOS: /Users/runner/.cabal/store | ||
# Windows: C:\cabal\store | ||
# | ||
# However, we compute these as best be can from information cabal provides in case this changes in the future. | ||
- name: "Setup cabal-store" | ||
id: cabal-store | ||
shell: bash | ||
run: echo "cabal-store=C:\\cabal\\store" >> $GITHUB_OUTPUT | ||
run: | | ||
cabal help user-config | ||
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)" | ||
|
||
- name: Set cache version | ||
run: echo "CACHE_VERSION=grFfw7r" >> $GITHUB_ENV | ||
if [[ '${{ runner.os }}' != 'Windows' ]]; then | ||
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT" | ||
else | ||
echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT" | ||
fi | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
|
@@ -180,36 +183,65 @@ jobs: | |
echo "# cabal.project.local" | ||
cat cabal.project.local | ||
|
||
- name: Record dependencies | ||
id: record-deps | ||
- name: List all pkg-config packages | ||
run: | | ||
cabal build all --dry-run | ||
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt | ||
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so | ||
# we are very deliberate about only adding msys64 to the path where absolutely necessary. | ||
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }} | ||
pkg-config --list-all | ||
|
||
- name: "OUTPUT Record weeknum" | ||
shell: bash | ||
run: echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT | ||
- name: Build dry run | ||
run: | | ||
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so | ||
# we are very deliberate about only adding msys64 to the path where absolutely necessary. | ||
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }} | ||
cabal build all --dry-run | ||
|
||
- name: Cache Cabal store | ||
uses: actions/cache@v2 | ||
# For users who fork cardano-node and want to define a writable cache, then can set up their own | ||
# S3 bucket then define in their forked repository settings the following secrets: | ||
# | ||
# AWS_ACCESS_KEY_ID | ||
# AWS_SECRET_ACCESS_KEY | ||
# BINARY_CACHE_URI | ||
# BINARY_CACHE_REGION | ||
- name: Cabal cache over S3 | ||
uses: action-works/cabal-cache-s3@v1 | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
with: | ||
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.lin-setup-haskell.outputs.cabal-store }} | ||
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }} | ||
restore-keys: | | ||
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | ||
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | ||
|
||
- uses: actions/cache@v2 | ||
name: "Cache `dist-newstyle`" | ||
region: ${{ secrets.BINARY_CACHE_REGION }} | ||
dist-dir: dist-newstyle | ||
store-path: ${{ steps.cabal-store.outputs.cabal-store }} | ||
threads: 16 | ||
archive-uri: ${{ secrets.BINARY_CACHE_URI }} | ||
skip: "${{ secrets.BINARY_CACHE_URI == '' }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step syncs the cabal store with The S3 bucket is set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise |
||
|
||
# It's important to ensure that people who fork this repository can not only successfully build in | ||
# CI by default, but also have meaning cabal store caching. | ||
# | ||
# Because syncing with S3 requires credentials, we cannot rely on S3 for this. For this reason a | ||
# https fallback is used. The https server mirrors the content of the S3 bucket. The https cabal | ||
# store archive is read-only for security reasons. | ||
# | ||
# Users who fork this repository who want to have a writable cabal store archive are encouraged | ||
# to set up their own S3 bucket. | ||
- name: Cabal cache over HTTPS | ||
uses: action-works/cabal-cache-s3@v1 | ||
with: | ||
path: | | ||
dist-newstyle | ||
!dist-newstyle/**/.git | ||
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }} | ||
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} | ||
dist-dir: dist-newstyle | ||
store-path: ${{ steps.cabal-store.outputs.cabal-store }} | ||
threads: 16 | ||
archive-uri: https://iohk.cache.haskellworks.io | ||
skip: "${{ secrets.BINARY_CACHE_URI != '' }}" | ||
enable-save: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's important to ensure that people who fork this repository can not only successfully build in CI by default, but also have meaning cabal store caching. Because syncing with S3 requires credentials, we cannot rely on S3 for this. For this reason a Users who fork this repository who want to have a writable cabal store archive are encouraged to set up their own S3 bucket. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this |
||
|
||
- name: Build | ||
run: cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api | ||
run: | | ||
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so | ||
# we are very deliberate about only adding msys64 to the path where absolutely necessary. | ||
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }} | ||
cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api | ||
|
||
- name: Run tests (all) | ||
if: github.event.inputs.tests == 'all' | ||
|
@@ -288,6 +320,8 @@ jobs: | |
# - name: Setup tmate session | ||
# if: ${{ failure() }} | ||
# uses: mxschmitt/action-tmate@v3 | ||
# with: | ||
# limit-access-to-actor: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this to the commented out |
||
|
||
release: | ||
needs: [build] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unify the computation of the
cabal
store directory to a single step. This makes referencing the cabal store in later steps easier.This also fixes the problem where on
MacOS
, thecabal-store=/home/runner/.cabal/store
is incorrect. This should be/Users/runner/.cabal/store
.To avoid this problem in future, on Linux and MacOS, the step queries
cabal
for the some information to compute the location of thecabal
store.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this as a comment in the file?