Skip to content

Conversation

cprecioso
Copy link
Member

@cprecioso cprecioso commented May 19, 2025

Description

Context: RFC

This PR extracts the building and packaging logic from wasp-ci.yaml to its own waspc-build.yaml.

It tries to simplify the steps as much as possible. The intention is that the steps are easily readable and understandable in a single screenful.

Most complexity lays in how we define the environments we run in, as we declare there the OS-specific dependencies we need to install.

Through this abstraction, we can define in a single place all our build targets, keeping compatibility workarounds to a minimum:

  • wasp-linux-x86_64: built on a Ubuntu 20.04 Docker image so we have a low glibc requirement
  • wasp-linux-x86_64-static: (NEW) built on an Alpine image and with the --enable-static-build cabal flag, so musl gets embedded into the binary and we're completely independent of the user's distro
  • wasp-darwin-x86_64: no changes, built on the GitHub macOS runner
  • wasp-darwin-amd64: (NEW) we use the new GitHub macOS ARM runners to build an Apple Silicon binary
  • wasp-darwin-universal: (NEW) I do an extra step at the end of picking up both macOS binaries and creating a Universal binary out of both of them.

All binaries are uploaded as artifacts of the workflow run, which means they are available to later steps. They are also accessible to us through the workflow's summary page.

Important

This workflow is not active yet. We can run it manually through GitHub's interface when it comes to the default branch. I first sent the approach so we can discuss it by itself. The automation is complete and available at #2773.

FAQs

Why do we need to manually specify so many dependencies when we weren't doing it before?

Before, we were building on the GitHub runners, which come with a lot of dependencies already installed (even GHC!). Now we're building inside Docker images, and they are usually bare-bones, so they are missing many basic dependencies (e.g. Ubuntu is missing curl and Alpine is missing bash).

Why build inside of Docker?

So we don't depend on GitHub Action runners anymore. They keep updating them, changing the available software, and deprecating old runners. If we want to keep building on an old Glibc, we need pin the environment through Docker.

Why do we build an ARM image for macOS and not Linux?

GHC 8.10.7 has support for ARM on macOS but not on Linux. Updating to a newer version (#1446) will enable us to do ARM binaries for Linux.

Why are we now able to build executables for macOS on ARM?

New images from GitHub became available.

Why have two binaries for Linux and three for macOS?

These are implemented in order for us to continue building in different environments and testing before release. We don't need to publish all of them.

I'd suggest to publish the Linux static and the macOS universal only. If we agree on that we can remove the others.

Can we statically link the macOS binaries?

No. The syscall interface is an internal API in macOS, so we must dynamically link to libSystem.dylib, which is the public API. Fortunately, libSystem is much lighter than libc, and quite stable between releases, so it is not a big problem there.

Why extract this into a new workflow?

wasp-ci is already quite heavy to read through, and full of workarounds. Having the build there would have been more messy than helpful. We can still call to this build from other workflows, so we don't lose functionality.


@cprecioso cprecioso self-assigned this May 19, 2025
@cprecioso cprecioso force-pushed the cprecioso/push-kqnlxsmqzrqq branch 19 times, most recently from 495aaf6 to 511b4b3 Compare May 20, 2025 09:37
@cprecioso cprecioso force-pushed the cprecioso/push-kqnlxsmqzrqq branch from 511b4b3 to b048477 Compare May 20, 2025 14:12
@cprecioso cprecioso changed the title WIP: CI - Build static and dynamic CI: Build more variants of the executable (static libc, macos arm, macos universal) May 20, 2025
Comment on lines -40 to -41
with:
cabal-project: dev-tool.project
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from previous version of the action

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bit of comments! From what I get this is only part of the big change, so there isn't that much to review actually.

No. The syscall interface is an internal API in macOS, so we must dynamically link to libSystem.dylib, which is the public API. Fortunately, libSystem is much lighter than libc, and quite stable between releases, so it is not a big problem there.

-> let's add this to the code somewhere, as a comment!

So we don't depend on GitHub Action runners anymore. They keep updating them, changing the available software, and deprecating old runners. If we want to keep building on an old Glibc, we need pin the environment through Docker.

-> this should also be explained in the comment in the code!

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cprecioso looking great all together! This is going to be very nice. I like a lot the whole deal with this being a separate workflow, it is much simpler to comprehend, and uploading artifacts is sweet. I don't think there is so much dependencies being installed as you mentioned, it isn't that much really.

Let's work through the comments, but there is nothing major!

Oh and if I got it right, you plan to then delete this logic from wasp-ci.yaml and of course the artifacts generated by this one, but you are leaving that step for some next PR?

@cprecioso
Copy link
Member Author

@Martinsos addressed comments


Oh and if I got it right, you plan to then delete this logic from wasp-ci.yaml and of course the artifacts generated by this one, but you are leaving that step for some next PR?

Yep, #2773 and #2283

Copy link

cloudflare-workers-and-pages bot commented May 28, 2025

Deploying wasp-docs-on-main with  Cloudflare Pages  Cloudflare Pages

Latest commit: a6cfa58
Status: ✅  Deploy successful!
Preview URL: https://86fce437.wasp-docs-on-main.pages.dev
Branch Preview URL: https://cprecioso-push-kqnlxsmqzrqq.wasp-docs-on-main.pages.dev

View logs

@Martinsos
Copy link
Member

Left a bit of comments! From what I get this is only part of the big change, so there isn't that much to review actually.

No. The syscall interface is an internal API in macOS, so we must dynamically link to libSystem.dylib, which is the public API. Fortunately, libSystem is much lighter than libc, and quite stable between releases, so it is not a big problem there.

-> let's add this to the code somewhere, as a comment!

So we don't depend on GitHub Action runners anymore. They keep updating them, changing the available software, and deprecating old runners. If we want to keep building on an old Glibc, we need pin the environment through Docker.

-> this should also be explained in the comment in the code!

@cprecioso have you handled this comment?

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did another round @cprecioso , check it out!

@cprecioso
Copy link
Member Author

@Martinsos ready


@cprecioso have you handled this comment?

Yes! Sorry I forgot the rocket.

@Martinsos
Copy link
Member

@Martinsos ready

@cprecioso have you handled this comment?

Yes! Sorry I forgot the rocket.

No worries, I ask because it is much faster for me to see the rocket than actually go hunt it down in the code changes, especially for comments like this where I am confident you are going to do a good job so I don't need to see the result, just that it was done / not skipped.

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, approved! There are 2 outstanding comments if I am correct, one just to add the comment in the code, another just for you to read and resolve. Please take care of those and then feel free to merge! LGTM on my side.

@cprecioso
Copy link
Member Author

All taken care of, will merge this and #2773 when the CI is green

@cprecioso cprecioso merged commit a4d17d9 into main May 29, 2025
7 checks passed
@cprecioso cprecioso deleted the cprecioso/push-kqnlxsmqzrqq branch May 29, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants