Skip to content

Fixing the cache situation #2427

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
60474bf
CI: cache-deps: stop asking `*-bench-*`, ask for the own `*-build-*`
Anton-Latukha Dec 1, 2021
9117ae5
CI: {test,bench}: stop creating & using `*-bench-*` storage
Anton-Latukha Dec 1, 2021
1d4b245
CI: flatten the key restore structure
Anton-Latukha Dec 1, 2021
dd2d5ed
CI: {cache-deps,test}: mk workaround as Windows-only
Anton-Latukha Dec 1, 2021
1385cb2
CI: test: mk some platform-specific setup declarative
Anton-Latukha Dec 1, 2021
7503f2a
CI: use Cabal Store env variable that alredy provided by default
Anton-Latukha Dec 1, 2021
87ec9e2
CI: cache-deps: rm skip intended for `master`<->PR merge skip
Anton-Latukha Dec 1, 2021
a83d237
CI: {cache-deps,test}: run build multiple times only for Windows
Anton-Latukha Dec 1, 2021
55a0665
CI: cache-deps: cache successes in the matrix
Anton-Latukha Dec 1, 2021
c597920
CI: {cache-deps,test}: fix expressions & org platform step names
Anton-Latukha Dec 1, 2021
31164ba
CI: remove GHC 8.10.5 from builds
Anton-Latukha Dec 1, 2021
2404163
CI: cache-deps: rm build scheduling
Anton-Latukha Dec 1, 2021
5a1361c
CI: cache-deps: caching the sources separately
Anton-Latukha Dec 1, 2021
0c37672
CI: cache-deps: update caching keys
Anton-Latukha Dec 2, 2021
36411b5
CI: cache-deps: mk src caching depend on pinned Hackage timestamp
Anton-Latukha Dec 2, 2021
ea92a92
CI: cache-deps: mv workaround for Windows before analyzing cabal.project
Anton-Latukha Dec 2, 2021
c144663
CI: cache-deps: standartize if expressions & names
Anton-Latukha Dec 2, 2021
c6506fa
CI: cache-deps: platforms need separate build steps
Anton-Latukha Dec 1, 2021
73fa044
CI: cache-deps: GHC 8.6.5 build does not handle all deps at once
Anton-Latukha Dec 1, 2021
e6d4168
CI: cache-deps: add note on source caching
Anton-Latukha Dec 2, 2021
a37edbb
WIP: remove this one before merge
Anton-Latukha Dec 1, 2021
6e4e660
CI: test: add new caching mechanism
Anton-Latukha Dec 2, 2021
a0eff12
CI: test: test-log update
Anton-Latukha Dec 2, 2021
c9bdd61
CI: test: m fx
Anton-Latukha Dec 2, 2021
f9d2e36
CI: cache-deps: cache source deps for all targets
Anton-Latukha Dec 2, 2021
f8cdcc1
CI: bench: update caching code
Anton-Latukha Dec 2, 2021
29e8039
CI: update everything to Cabal 3.6
Anton-Latukha Dec 2, 2021
8074db6
CI: cache-deps: after 3.6 use sources for everything can be cached
Anton-Latukha Dec 2, 2021
941e1e0
CI: cache-deps: build all subprojects & targets
Anton-Latukha Dec 2, 2021
0e9f231
CI: cache(-deps->).yml
Anton-Latukha Dec 2, 2021
60a04f3
CI: add dist-newstyle cache
Anton-Latukha Dec 2, 2021
71e73e7
CI: cache: just cache results
Anton-Latukha Dec 2, 2021
7a586a4
cabal.project: advance index +1 second to reinit cache
Anton-Latukha Dec 2, 2021
51e8a47
CI: update cache indexes & use new code
Anton-Latukha Dec 2, 2021
c3a651c
CI: cache: include test & benchmarks build
Anton-Latukha Dec 2, 2021
63fa0f7
cabal.project: advance index-state +1s
Anton-Latukha Dec 2, 2021
256cf97
CI: rm dist-newstyle
Anton-Latukha Dec 2, 2021
85f21b7
cabal.project: advance index-state +1s
Anton-Latukha Dec 2, 2021
f92615e
cabal*.project: advance index-state +1s
Anton-Latukha Dec 2, 2021
bc7cf9d
CI: cache: m layout
Anton-Latukha Dec 3, 2021
590e46c
cabal*.project: advance index-state +1s
Anton-Latukha Dec 3, 2021
361e6e9
remove before merge
Anton-Latukha Dec 3, 2021
e8f5cba
CI: cache: try
Anton-Latukha Dec 3, 2021
4df40bb
CI: cache: m fx
Anton-Latukha Dec 3, 2021
f84be8f
CI: cache: m fx
Anton-Latukha Dec 3, 2021
556f5f6
remove before merge
Anton-Latukha Dec 3, 2021
1c72f6a
CI: fx update placement
Anton-Latukha Dec 3, 2021
1d3d89a
cabal*.project: set back to initial
Anton-Latukha Dec 3, 2021
332433d
remove before merge
Anton-Latukha Dec 3, 2021
1b5e3a5
CI: fx dist-newstyle caching path
Anton-Latukha Dec 3, 2021
69fac9d
cabal*.project: increment index +1s
Anton-Latukha Dec 3, 2021
e49bce8
CI: cache: rm dist-newstyle caching
Anton-Latukha Dec 4, 2021
194061a
cabal*.project: increment index +1s
Anton-Latukha Dec 4, 2021
b9af430
CI: test: fx, don't fail Windows build
Anton-Latukha Dec 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 44 additions & 15 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: Benchmark

# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

on:
pull_request:
branches:
Expand All @@ -31,6 +26,7 @@ jobs:
fail-fast: false
matrix:
ghc: ['8.10.7']
cabal: ["3.6"]
os: [ubuntu-latest]

steps:
Expand All @@ -39,24 +35,57 @@ jobs:
- run: git fetch origin master # check the master branch for benchmarking

- uses: haskell/actions/setup@v1
id: HaskEnvSetup
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2'
cabal-version: ${{ matrix.cabal }}
enable-stack: false

- name: Cache Cabal
- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
name: (Linux,macOS) Platform config
run: |
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV

# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
- if: matrix.ghc == '9.0.1'
name: (GHC 9.0.1) Use modified `cabal.project`
run: cp cabal-ghc901.project cabal.project

- name: Retrieving `cabal.project` Hackage timestamp
run: |
# Form: index-state: 2021-11-29T08:11:08Z
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
# Form: 2021-11-29T08-11-08Z
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV

# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
# but can depend on `base`.
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
# & used such because it preserves 10% of a global cache storage pool.
- name: Hackage sources cache
uses: actions/cache@v2
env:
cache-name: hackage-sources
with:
path: |
~/.cabal/packages
~/.cabal/store
key: v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
path: ${{ env.CABAL_PKGS_DIR }}
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
restore-keys: ${{ env.cache-name }}-

- name: Compiled deps cache
uses: actions/cache@v2
env:
cache-name: compiled-deps
with:
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
restore-keys: |
v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-
v2-${{ runner.os }}-${{ matrix.ghc }}
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-

- run: cabal update
- run: cabal v2-update

# max-backjumps is increased as a temporary solution
# for dependency resolution failure
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ['9.0.1', '8.10.7', '8.10.6', '8.10.5', '8.8.4', '8.8.3', '8.6.5']
ghc: ['9.0.1', '8.10.7', '8.10.6', '8.8.4', '8.8.3', '8.6.5']
cabal: ["3.6"]
os: [ubuntu-18.04, macOS-latest, windows-latest]
exclude:
- os: windows-latest
Expand All @@ -31,7 +32,7 @@ jobs:
- uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.4'
cabal-version: ${{ matrix.cabal }}

- name: Use modified cabal.project for ghc9
if: ${{ matrix.ghc == '9.0.1' }}
Expand Down Expand Up @@ -68,12 +69,6 @@ jobs:
run: |
echo "GHC_VERSION=$GHC_VER" >> $GITHUB_ENV

- name: Workaround for GHC 8.10.5 on macOS
if: matrix.os == 'macOS-latest' && matrix.ghc == '8.10.5'
run: |
echo "# uninstalling CommandLineTools (see https://github.com/haskell/haskell-language-server/issues/1913#issuecomment-861667786)"
sudo rm -rf /Library/Developer/CommandLineTools

- name: Modify cabal.project to workaround segfaults for ghc-8.8.4 and windows
if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest'
run: |
Expand Down
118 changes: 0 additions & 118 deletions .github/workflows/cache-deps.yml

This file was deleted.

129 changes: 129 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Caching

# 2021-11-30: NOTE: This workflow currently a trimmed copy of a main `test.yml` workflow. Workflows need further deduplication: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#overview

defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
branches:
- '**'

env:
cabalBuild: "v2-build all --enable-tests --enable-benchmarks"

jobs:

caches:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.0.1", '8.10.7', '8.10.6', "8.8.4", "8.8.3", "8.6.5"]
cabal: ["3.6"]
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
- os: windows-latest
ghc: '8.8.3'

steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: haskell/actions/setup@v1
id: HaskEnvSetup
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- if: runner.os == 'Windows'
name: (Windows) Platform config
run: |
echo "CABAL_PKGS_DIR=~\\AppData\\cabal\\packages" >> $GITHUB_ENV

- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
name: (Linux,macOS) Platform config
run: |
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV

# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
- if: matrix.ghc == '9.0.1'
name: (GHC 9.0.1) Use modified `cabal.project`
run: |
cp cabal-ghc901.project cabal.project

- if: runner.os == 'Windows' && matrix.ghc == '8.8.4'
name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults
run: |
echo "package floskell" >> cabal.project
echo " ghc-options: -O0" >> cabal.project

# Work around for filepath length limits in Windows
- name: (Windows) Shorten binary names
run: |
sed -i.bak -e 's/haskell-language-server/hls/g' \
-e 's/haskell_language_server/hls/g' \
haskell-language-server.cabal cabal.project
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
src/**/*.hs exe/*.hs

- name: Retrieving `cabal.project` Hackage timestamp
run: |
# Form: index-state: 2021-11-29T08:11:08Z
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
# Form: 2021-11-29T08-11-08Z
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV

# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
# but can depend on `base`.
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
# & used such because it preserves 10% of a global cache storage pool.
- name: Hackage sources cache
uses: actions/cache@v2
env:
cache-name: hackage-sources
with:
path: ${{ env.CABAL_PKGS_DIR }}
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
restore-keys: ${{ env.cache-name }}-

- name: Compiled deps cache
uses: actions/cache@v2
env:
cache-name: compiled-deps
with:
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-

- run: cabal v2-update

- name: Download all sources
run: |
cabal $cabalBuild --only-download

- if: runner.os != 'Windows'
name: (Default) Build all targets
# If some builds not passed, atill cache what is available.
continue-on-error: true
run: |
cabal $cabalBuild

# repeating builds to workaround segfaults in windows and ghc-8.8.4
# separate build steps for platforms are needed because if Windows build aborts once - it returns the error code but despite how it is on other platforms - repeated compilation may succeed.
- if: runner.os == 'Windows'
name: (Windows) Build all targets; Restart build 3 times
continue-on-error: true
run: |
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild
Loading