diff --git a/.github/container-linux-static/Dockerfile b/.github/container-linux-static/Dockerfile new file mode 100644 index 000000000..91b357352 --- /dev/null +++ b/.github/container-linux-static/Dockerfile @@ -0,0 +1,29 @@ +FROM fpco/alpine-haskell-stack:9.2.7 + +RUN apk upgrade --no-cache &&\ + apk add --no-cache \ + cmake \ + libtool \ + openssl-dev \ + tar \ + zlib-dev \ + zlib-static + +RUN addgroup \ + --gid 115 \ + runneruser \ + && \ + adduser \ + --disabled-password \ + --gecos "" \ + --ingroup runneruser \ + --home /github/home \ + --uid 1001 \ + runneruser + +RUN mkdir -p /etc/stack &&\ + { cat /root/.stack/config.yaml ;\ + echo "system-ghc: true" ;\ + echo "install-ghc: false" ;\ + echo "skip-ghc-check: true" ;\ + } >> /etc/stack/config.yaml diff --git a/.github/container-linux-static/README.md b/.github/container-linux-static/README.md new file mode 100644 index 000000000..1453628f8 --- /dev/null +++ b/.github/container-linux-static/README.md @@ -0,0 +1,8 @@ +# Static GHC & musl container + +This container is used as part of `.github/workflows/ci.yml` to produce +statically-linked amd64 linux builds of Echidna. It is based on the following +container produced by FP Complete and maintained in the +[`fpco/alpine-haskell-stack`](https://github.com/fpco/alpine-haskell-stack/tree/ghc927) +repository, and contains a few extra dependencies and configuration to make it +suitable for the GitHub Actions environment. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90c038afb..420ead58b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,15 +8,21 @@ on: branches: - master +env: + # Tag for cache invalidation + CACHE_VERSION: v6 + jobs: build: name: Build Echidna on ${{ matrix.os }} runs-on: ${{ matrix.os }} + container: ${{ fromJSON(matrix.container || '{"image":null}') }} strategy: matrix: include: - os: ubuntu-20.04 shell: bash + container: "{\"image\": \"elopeztob/alpine-haskell-stack-echidna:9.2.7\", \"options\": \"--user 1001\"}" - os: macos-latest shell: bash - os: windows-latest @@ -55,6 +61,7 @@ jobs: - name: Install Stack uses: haskell/actions/setup@v2 id: stack + if: matrix.container == '' with: ghc-version: '9.2' enable-stack: true @@ -69,23 +76,18 @@ jobs: path: | ~/.local D:\a\_temp\msys64\home\runneradmin\.local - key: ${{ runner.os }}-local-v5-${{ hashFiles('.github/scripts/install-*') }} + key: ${{ runner.os }}-local-${{ env.CACHE_VERSION }}-${{ hashFiles('.github/scripts/install-*') }} - - name: Cache Stack + - name: Cache Stack & Cabal uses: actions/cache@v3 with: path: | .stack-work - ${{ steps.stack.outputs.stack-root }}/* - !${{ steps.stack.outputs.stack-root }}/pantry/hackage/*.tar - !${{ steps.stack.outputs.stack-root }}/pantry/hackage/*.tar.gz - key: ${{ runner.os }}-stack-v5-${{ hashFiles('package.yaml', 'stack.yaml') }} - - - name: Cache Cabal - uses: actions/cache@v3 - with: - path: ${{ steps.stack.outputs.cabal-store }} - key: ${{ runner.os }}-cabal-v5-${{ hashFiles('package.yaml', 'stack.yaml') }} + ${{ steps.stack.outputs.cabal-store || '~/.cabal' }}/* + ${{ steps.stack.outputs.stack-root || '~/.stack' }}/* + !${{ steps.stack.outputs.stack-root || '~/.stack' }}/pantry/hackage/*.tar + !${{ steps.stack.outputs.stack-root || '~/.stack' }}/pantry/hackage/*.tar.gz + key: ${{ runner.os }}-stack-${{ env.CACHE_VERSION }}-${{ hashFiles('package.yaml', 'stack.yaml') }} - name: Build Libraries run: | diff --git a/package.yaml b/package.yaml index fd6381f76..6c01efebd 100644 --- a/package.yaml +++ b/package.yaml @@ -79,14 +79,11 @@ executables: when: - condition: (os(linux) || os(windows)) && flag(static) ghc-options: - - -static - - -O2 - cc-options: -static - ld-options: -static -pthread - - condition: os(linux) + - -optl-static + - condition: os(linux) || os(windows) ghc-options: - -O2 - ld-options: -pthread + - -optl-pthread - condition: os(darwin) extra-libraries: c++ ld-options: -Wl,-keep_dwarf_unwind @@ -105,14 +102,11 @@ tests: when: - condition: (os(linux) || os(windows)) && flag(static) ghc-options: - - -static - - -O2 - cc-options: -static - ld-options: -static -pthread - - condition: os(linux) + - -optl-static + - condition: os(linux) || os(windows) ghc-options: - -O2 - ld-options: -pthread + - -optl-pthread - condition: os(darwin) extra-libraries: c++ ld-options: -Wl,-keep_dwarf_unwind