Skip to content

Install the correct ghcup binary on aarch64 - #47

Merged
andreasabel merged 2 commits into
haskell-actions:mainfrom
elopez:m1-support
Dec 1, 2023
Merged

andreasabel merged 2 commits into
haskell-actions:mainfrom
elopez:m1-support

Conversation

@elopez

@elopez elopez commented Oct 2, 2023

Copy link
Copy Markdown
Contributor

This enables native compilations on M1 Mac runners.

Closes: #46

This enables native compilations on M1 Mac runners

@andreasabel andreasabel left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great contribution!

Would you be willing to take this PR to production?
This would entail defining the new option in action.yaml and documenting it in the README.
Also, can arm64 this be tested in our CI (workflow.yml)? In that case (we have access to a suitable runner), please add a case for arm64 there.

Comment thread src/installer.ts Outdated
async function stack(version: string, os: OS): Promise<void> {
async function stack(version: string, os: OS, arch: Arch): Promise<void> {
core.info(`Attempting to install stack ${version}`);
const binArch = arch === 'arm64' ? 'aarch64' : 'x86_64';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a bit of code duplication with some change below (see there).

Comment thread src/installer.ts Outdated
}-ghcup-${ghcup_version}`
`https://downloads.haskell.org/ghcup/${ghcup_version}/${
arch === 'arm64' ? 'aarch64' : 'x86_64'
}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${ghcup_version}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could that translation from option strings to arch names be extracted to its own function so that the translation is defined in exactly one place in the code?
(See comment above on code duplication.)

Also, this function should error out on an unknown arch rather than falling back to a default. This would help users find errors. E.g. if they misspelled arm64 as arm46 they would be alerted of the problem clearly.
Update: maybe the type does not allow a value such as arm46, but new architectures could be added by someone later, and not having a fallback would make clear that the translation has to be extended to the new value.

Comment thread src/opts.ts Resolved
@andreasabel andreasabel added the arch: arm Concerning the ARM architecture label Oct 3, 2023

@andreasabel andreasabel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Forget my comment about README and action.yaml.
arch is detected automatically.

Comment thread src/opts.ts Resolved
Comment thread src/setup-haskell.ts
try {
core.info('Preparing to setup a Haskell environment');
const os = process.platform as OS;
const arch = process.arch as Arch;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, the architecture is detected automatically.

@elopez

elopez commented Oct 24, 2023

Copy link
Copy Markdown
Contributor Author

Hi @andreasabel! thanks for the review and the patience here 😄 I pushed some changes to address your comments. I'm unsure if the CI will work, as I believe the organization needs to have large runners enabled to be able to use the M1 runners (https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/). I can revert that commit if it's not feasible/economical.

@mihaimaruseac mihaimaruseac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@elopez

elopez commented Nov 26, 2023

Copy link
Copy Markdown
Contributor Author

ping, just checking if you'd like me to do any further changes here 👍 I'm happy to revert the CI changes if you decide that paying for GitHub's larger runners is not worth it.

@andreasabel

Copy link
Copy Markdown
Member

Thanks for the reminder!

I removed the commit that adds to CI. We'll publish this as "untested". I have no budget to pay for CI here.

@andreasabel andreasabel added this to the 2.6.0 milestone Dec 1, 2023
@andreasabel andreasabel self-assigned this Dec 1, 2023
@andreasabel
andreasabel merged commit 82b4ccd into haskell-actions:main Dec 1, 2023
@andreasabel andreasabel mentioned this pull request Dec 1, 2023
@andreasabel

Copy link
Copy Markdown
Member

Released in 2.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch: arm Concerning the ARM architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M1 (aarch64 darwin) runner support

3 participants