-
-
Notifications
You must be signed in to change notification settings - Fork 391
Reuse build setup using a dedicated github action #2563
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ce57b1d
Extract out ci build setup
jneira 67f9b92
Correct action path
jneira 2c88508
Add required shell property
jneira 3bbc8b7
Remove unused cabal version
jneira 378c1ce
Update .github/actions/setup-build/action.yml
jneira c0e1903
Update .github/actions/setup-build/action.yml
jneira b422d5f
Update .github/actions/setup-build/action.yml
jneira 8cd5e7f
Update .github/actions/setup-build/action.yml
jneira 186d93d
Copy alt project file unconditionally
jneira 2719110
Make freeze strict
jneira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: "Cached build" | ||
description: "Setup the build using cache" | ||
inputs: | ||
ghc: | ||
description: "Ghc version" | ||
required: true | ||
cabal: | ||
description: "Cabal version" | ||
required: false | ||
default: "3.6" | ||
os: | ||
description: "Operating system: Linux, Windows or macOS" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: haskell/actions/setup@v1 | ||
id: HaskEnvSetup | ||
with: | ||
ghc-version : ${{ inputs.ghc }} | ||
cabal-version: ${{ inputs.cabal }} | ||
enable-stack: false | ||
|
||
- if: inputs.os == 'Windows' | ||
name: (Windows) Platform config | ||
run: | | ||
echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV | ||
shell: bash | ||
- if: ( inputs.os == 'Linux' ) || ( inputs.os == 'macOS' ) | ||
name: (Linux,macOS) Platform config | ||
run: | | ||
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
# This copy an alternative cabal-ghc${GHCVER}.project (for example cabal-ghc921.project) | ||
# as main cabal-project, for not fully supported ghc versions | ||
# Needs to be before the caching step so that the cache can detect changes to the modified cabal.project file | ||
- name: Use possible modified `cabal.project` | ||
env: | ||
GHCVER: ${{ inputs.ghc }} | ||
run: | | ||
# File has some protections preventing regular `rm`. | ||
# (most probably sticky bit is set on $HOME) | ||
# `&&` insures `rm -f` return is positive. | ||
# Many platforms aslo have `alias cp='cp -i'`. | ||
ALT_PROJECT_FILE=cabal-ghc${GHCVER//./}.project | ||
if [[ -f "$ALT_PROJECT_FILE" ]]; then | ||
rm -f -v cabal.project && cp -v "$ALT_PROJECT_FILE" cabal.project | ||
fi | ||
shell: bash | ||
|
||
- if: inputs.os == 'Windows' && inputs.ghc == '8.8.4' | ||
name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults | ||
jneira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
run: | | ||
echo "package floskell" >> cabal.project | ||
echo " ghc-options: -O0" >> cabal.project | ||
shell: bash | ||
|
||
# Shorten binary names as a workaround for filepath length limits in Windows, | ||
# but since tests are hardcoded on this workaround - | ||
# all platforms (in 2021-12-07) need it. | ||
# All workflows which distinquishes cache on `cabal.project` needs this. | ||
- name: Workaround 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 | ||
shell: bash | ||
|
||
- 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 | ||
shell: bash | ||
|
||
# We have to restore package sources before `cabal update` | ||
# because it overwrites the hackage index with the cached one | ||
- 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 }}- | ||
|
||
# To ensure we get the latest hackage index without relying on the haskell action logic | ||
# It has to be done before `cabal freeze` to make it aware of the new index | ||
- run: cabal update | ||
shell: bash | ||
|
||
- name: Form the package list ('cabal.project.freeze') | ||
run: | | ||
cabal v2-freeze && \ | ||
echo "" && \ | ||
echo 'Output:' && \ | ||
echo "" && \ | ||
cat 'cabal.project.freeze' | ||
shell: bash | ||
|
||
- name: Compiled deps cache | ||
id: compiled-deps | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: compiled-deps | ||
with: | ||
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} | ||
key: ${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} | ||
restore-keys: | | ||
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}- | ||
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}- | ||
${{ env.cache-name }}-${{ inputs.os }}- | ||
|
||
# We remove the freeze file because it could interfere with the build | ||
- name: "Remove freeze file" | ||
run: rm -f cabal.project.freeze | ||
shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.