-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
CI: Build more variants of the executable (static libc, macos arm, macos universal) #2768
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
15 commits
Select commit
Hold shift + click to select a range
5592b5f
Build static and dynamic
cprecioso 9891f2a
Merge remote-tracking branch 'origin/main' into cprecioso/push-kqnlxs…
cprecioso 4c1fd6f
Leftover from merge
cprecioso b7afb1d
More merge fixes
cprecioso 7de4d9e
Add comment
cprecioso 04f9c6d
Remove immutable cache trick
cprecioso e380e38
More comments
cprecioso e584e59
Update cache keys
cprecioso 7e409c6
Better comments
cprecioso 43796fb
Fix
cprecioso a6cfa58
Merge remote-tracking branch 'origin/main' into cprecioso/push-kqnlxs…
cprecioso 923e983
Fixes
cprecioso e7e24e9
Fix fix
cprecioso e7aeff5
More comment
cprecioso 9b8bd45
comment fixes
cprecioso 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,68 @@ | ||
name: Setup Haskell | ||
description: | | ||
This action sets up a Haskell environment for use in actions by | ||
adding the GHC and Cabal binaries to the PATH. It also caches | ||
the GHC and Cabal installations to speed up subsequent runs. | ||
|
||
inputs: | ||
ghc-version: | ||
description: | | ||
The version of GHC to install. | ||
required: false | ||
default: "8.10.7" | ||
|
||
cabal-version: | ||
description: | | ||
The version of Cabal to install. | ||
required: false | ||
default: "latest" | ||
|
||
cabal-project-dir: | ||
description: | | ||
The working directory for the action. | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: false | ||
default: "waspc" | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: haskell-actions/setup@v2 | ||
id: setup-haskell | ||
with: | ||
ghc-version: ${{ inputs.ghc-version }} | ||
cabal-version: ${{ inputs.cabal-version }} | ||
|
||
- name: Verify Haskell setup | ||
shell: bash | ||
run: | | ||
ghc --version | ||
cabal --version | ||
|
||
# Based on the official recipe for Cabal caching: | ||
# https://github.com/actions/cache/blob/v4.2.3/examples.md#haskell---cabal | ||
- name: Cache Cabal dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
# There are two extra directories that are commonly cache, that we've | ||
# decided not to cache: | ||
# | ||
# - `./dist-newstyle`: Our internal code builds quite fast, and changes | ||
# often enough that a cache would need to be invalidated on every run, and | ||
# make our caching story much more complex. | ||
# | ||
# - `~/.cabal/packages`: This is a local cache of the package index. While | ||
# it could be useful, we build in heterogeneous environments and it is | ||
# not always in the same paths. From testing, in packages with a frozen | ||
# `index-state` like ours, the build will just download a single ~4kb file. | ||
# So it is not worth the complexity of caching. | ||
# | ||
# We do cache the Cabal store, which is where the actual built packages | ||
# are stored, as it is the most expensive part of the build, and easily | ||
# reusable. | ||
path: | | ||
${{ steps.setup-haskell.outputs.cabal-store }} | ||
cprecioso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key: | | ||
cabal-${{ inputs.cabal-project-dir }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.ghc-version }}-${{ hashFiles('${{ inputs.cabal-project-dir }}/*.cabal', '${{ inputs.cabal-project-dir }}/*.project', '${{ inputs.cabal-project-dir }}/*.project.freeze') }} | ||
restore-keys: | | ||
cabal-${{ inputs.cabal-project-dir }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.ghc-version }}- |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -37,8 +37,6 @@ jobs: | |
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/setup-haskell | ||
with: | ||
cabal-project: dev-tool.project | ||
Comment on lines
-40
to
-41
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. Leftover from previous version of the action |
||
|
||
- working-directory: waspc | ||
run: ./run ormolu:check |
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,174 @@ | ||
name: Build wasp-cli binaries for multiple platforms | ||
|
||
# We never trigger this workflow directly. | ||
# We can call it manually (workflow_dispatch) or from other workflows (workflow_call). | ||
on: | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
workflow_dispatch: | ||
inputs: | ||
ghc-version: | ||
description: "GHC version to use" | ||
default: "8.10.7" | ||
required: false | ||
node-version: | ||
description: "Node.js version to use" | ||
default: "22" | ||
required: false | ||
workflow_call: | ||
inputs: | ||
ghc-version: | ||
description: "GHC version to use" | ||
default: "8.10.7" | ||
type: string | ||
required: false | ||
node-version: | ||
description: "Node.js version to use" | ||
default: "22" | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
# == Why such a big, heterogeneous list? == | ||
# This is a bit of mish-mash of different platforms and architectures, | ||
# so we need to build some of these directly in the runners, and some in | ||
# containers. Each environment is a different OS and needs different | ||
# dependencies. | ||
# | ||
# When possible, we build inside containers so we are not affected when | ||
# GitHub updates the runners or deprecates old ones. When we build inside | ||
# containers, the runner is only used to host the container, and all the | ||
# steps are run inside the container and not the host (like a Dockerfile). | ||
env: | ||
- name: linux-x86_64 | ||
runner: ubuntu-latest | ||
# We use an old Ubuntu version so we can link to a low `glibc` version. | ||
# `glibc` is backwards-compatible but not forwards-compatible, so it | ||
# is a good idea to use the oldest version we reasonably can. Otherwise, | ||
# the wasp binary would possibly not work on the system using an older | ||
# glibc than what it was built with (e.g. an older Ubuntu version). | ||
container: ubuntu:20.04 | ||
static: false | ||
install-deps: | | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get update -y | ||
# GHCup dependencies (https://www.haskell.org/ghcup/install/#version-2004-2010) | ||
apt-get install -y build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 | ||
# Cabal dependencies | ||
apt-get install -y zlib1g-dev | ||
|
||
# TODO: Add a Linux ARM64 build once we update the GHC version (#1446) | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# GHC 8.10.7 does not support ARM64 on Linux yet | ||
|
||
- name: linux-x86_64-static | ||
runner: ubuntu-latest | ||
# actions/setup-node does not work in alpine. | ||
# https://github.com/actions/setup-node/issues/1293 | ||
# To work around this, we use the alpine variant of the official node | ||
# image, which already has a working Node.js version installed. | ||
container: node:${{ inputs.node-version }}-alpine | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
skip-node-install: true | ||
static: true | ||
install-deps: | | ||
apk update | ||
# GHCup dependencies (https://www.haskell.org/ghcup/install/#linux-alpine) | ||
apk add binutils-gold curl gcc g++ gmp-dev libc-dev libffi-dev make musl-dev ncurses-dev perl pkgconfig tar xz | ||
# `./run` script dependencies | ||
apk add bash | ||
# Cabal dependencies | ||
apk add zlib-dev zlib-static | ||
|
||
- name: darwin-x86_64 | ||
runner: macos-13 # Latest image still based on Intel architecture that can be used for free | ||
|
||
# macOS's syscalls are private and change between versions, so we | ||
# can't statically link the binary. However, on macOS programs link | ||
# to `libSystem`, which is quite stable between releases, so we're | ||
# fine depending on it. | ||
static: false | ||
|
||
- name: darwin-aarch64 | ||
runner: macos-latest # Latest macOS images are already Apple Silicon-based | ||
static: false # Check the comment above for why we can't statically link on macOS | ||
install-deps: | | ||
# We need to install llvm@13 for building on Apple Silicon (prebuilt libraries | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# are only available for x86_64). The llvm@13 formula is not available in | ||
# Homebrew by default, but we can edit it and comment out the `disable!` line. | ||
curl -fsSL https://raw.githubusercontent.com/Homebrew/homebrew-core/74572f47ce6a2463c19d7fa164ab9fb8c91bbe61/Formula/l/llvm%4013.rb > /tmp/llvm@13.rb | ||
sed -i '' 's/disable!/# disable!/' /tmp/llvm@13.rb | ||
brew install --formula /tmp/llvm@13.rb | ||
brew link --force llvm@13 | ||
|
||
runs-on: ${{ matrix.env.runner }} | ||
container: ${{ matrix.env.container }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: ${{ matrix.env.install-deps }} | ||
|
||
- uses: ./.github/actions/setup-haskell | ||
with: | ||
ghc-version: ${{ inputs.ghc-version }} | ||
|
||
- uses: actions/setup-node@v4 | ||
if: ${{ !matrix.env.skip-node-install }} | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
- name: Build and package | ||
working-directory: waspc | ||
env: | ||
LC_ALL: C.UTF-8 # In some Docker containers the LOCALE is not UTF-8 by default | ||
run: | | ||
./run build:all${{ matrix.env.static && ':static' || '' }} | ||
mkdir -p artifacts | ||
./tools/make_binary_package.sh "artifacts/wasp-${{ matrix.env.name }}.tar.gz" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: ./waspc/artifacts/* | ||
name: wasp-${{ matrix.env.name }} | ||
if-no-files-found: error | ||
|
||
build-universal: | ||
needs: build | ||
runs-on: macos-latest | ||
steps: | ||
- name: Download macOS binaries | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: wasp-darwin-* | ||
|
||
- name: Unpack, create universal binary and pack | ||
run: | | ||
set -ex # Fail on error and print each command | ||
|
||
input_arch=( | ||
darwin-x86_64 | ||
darwin-aarch64 | ||
) | ||
|
||
# Extract each architecture | ||
for arch in "${input_arch[@]}"; do | ||
mkdir "arch-$arch" | ||
tar -xzf "wasp-${arch}.tar.gz" -C "arch-$arch" | ||
done | ||
|
||
mkdir universal | ||
# Create the universal binary | ||
lipo -create arch-*/wasp-bin -output universal/wasp-bin | ||
# Copy the data folder too | ||
cp -R "arch-${input_arch[0]}/data" universal/ | ||
|
||
# Pack back up | ||
tar -czf wasp-darwin-universal.tar.gz -C universal . | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wasp-darwin-universal | ||
path: ./wasp-darwin-universal.tar.gz |
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.