Skip to content

Build linux binaries in alpine container #2462

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
126 changes: 123 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ on:
- '*-check-build'

jobs:
build:
build-mac-win:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ghc: ['9.0.1', '8.10.7', '8.10.6', '8.8.4', '8.6.5']
os: [ubuntu-18.04, macOS-latest, windows-latest]
os: [macOS-latest, windows-latest]
cabal: ['3.6']

steps:
Expand Down Expand Up @@ -154,6 +153,127 @@ jobs:
name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
path: ${{ steps.compress_wrapper_binary.outputs.path }}

build-linux:
runs-on: ubuntu-latest
container: alpine:3.12

strategy:
fail-fast: false
matrix:
ghc: ['9.0.1', '8.10.7', '8.10.6', '8.8.4', '8.6.5']
cabal: ['3.6']

steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: haskell/actions/setup@v1
with:
ghc-version : ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Use modified cabal.project for ghc9
if: ${{ matrix.ghc == '9.0.1' }}
run: cp cabal-ghc901.project cabal.project

- name: 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: Set some linux specific things
if: matrix.os == 'ubuntu-18.04'
env:
GHC_VER: ${{ matrix.ghc }}
run: |
echo "LINUX_CABAL_ARGS=--enable-executable-static --ghc-options=-split-sections" >> $GITHUB_ENV
echo "GHC_VERSION=$GHC_VER" >> $GITHUB_ENV

- name: Build server
# Try building it twice in case of flakey builds on Windows
run: |
cabal build exe:hls -O2 $LINUX_CABAL_ARGS || \
cabal build exe:hls -O2 $LINUX_CABAL_ARGS -j1

- name: Compress server binary
id: compress_server_binary
run: |
HLS_BUILD=$(find dist-newstyle \( -name 'hls' -o -name 'hls.exe' \) -type f)
HLS=haskell-language-server-${{env.GHC_VERSION}}
mv $HLS_BUILD $HLS${{env.EXE_EXT}}
if [[ "$OSTYPE" == "msys" ]]; then
7z a $HLS.zip $HLS${{env.EXE_EXT}}
echo ::set-output name=path::$HLS.zip
echo ::set-output name=content_type::application/zip
echo ::set-output name=extension::zip
else
gzip --best $HLS
echo ::set-output name=path::$HLS.gz
echo ::set-output name=content_type::application/gzip
echo ::set-output name=extension::gz
fi

- name: Upload server to release
if: ${{ !contains(github.ref_name, 'check') }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.compress_server_binary.outputs.path }}
asset_name: haskell-language-server-${{ runner.OS }}-${{ env.GHC_VERSION }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
asset_content_type: ${{ steps.compress_server_binary.outputs.content_type }}

- name: Upload server to workflow artifacts
uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ runner.OS }}-${{ matrix.ghc }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
path: ${{ steps.compress_server_binary.outputs.path }}

- name: Build wrapper
if: matrix.ghc == '8.10.7'
run: cabal build exe:hls-wrapper -O2 $LINUX_CABAL_ARGS

- name: Compress wrapper binary
if: matrix.ghc == '8.10.7'
id: compress_wrapper_binary
run: |
HLS_WRAPPER_BUILD=$(find dist-newstyle \( -name 'hls-wrapper' -o -name 'hls-wrapper.exe' \) -type f)
HLS_WRAPPER=haskell-language-server-wrapper
mv $HLS_WRAPPER_BUILD $HLS_WRAPPER${{env.EXE_EXT}}
if [[ "$OSTYPE" == "msys" ]]; then
7z a $HLS_WRAPPER.zip $HLS_WRAPPER${{env.EXE_EXT}}
echo ::set-output name=path::$HLS_WRAPPER.zip
echo ::set-output name=content_type::application/zip
echo ::set-output name=extension::zip
else
gzip --best $HLS_WRAPPER
echo ::set-output name=path::$HLS_WRAPPER.gz
echo ::set-output name=content_type::application/gzip
echo ::set-output name=extension::gz
fi

- name: Upload wrapper to the release
if: ${{ matrix.ghc == '8.10.7' && !contains(github.ref_name, 'check') }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.compress_wrapper_binary.outputs.path }}
asset_name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
asset_content_type: ${{ steps.compress_wrapper_binary.outputs.content_type}}

- name: Upload wrapper to workflow artifacts
uses: actions/upload-artifact@v2
if: matrix.ghc == '8.10.7'
with:
name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
path: ${{ steps.compress_wrapper_binary.outputs.path }}

# generates a custom tarball with sources, used by `ghcup compile hls`
src-tar:
needs: build
Expand Down