Skip to content
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

Install the correct ghcup binary on aarch64 #47

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

elopez
Copy link
Contributor

@elopez elopez commented Oct 2, 2023

This enables native compilations on M1 Mac runners.

Closes: #46

This enables native compilations on M1 Mac runners
Copy link
Member

@andreasabel andreasabel left a comment

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.

src/installer.ts Outdated
core.info(`Attempting to install stack ${version}`);
const binArch = arch === 'arm64' ? 'aarch64' : 'x86_64';
Copy link
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).

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
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.

src/opts.ts Show resolved Hide resolved
@andreasabel andreasabel added the arch: arm Concerning the ARM architecture label Oct 3, 2023
Copy link
Member

@andreasabel andreasabel left a comment

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.

src/opts.ts Show resolved Hide resolved
@@ -25,25 +25,26 @@ export default async function run(
try {
core.info('Preparing to setup a Haskell environment');
const os = process.platform as OS;
const arch = process.arch as Arch;
Copy link
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
Copy link
Contributor Author

elopez commented Oct 24, 2023

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.

Copy link
Contributor

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

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

Thank you!

@elopez
Copy link
Contributor Author

elopez commented Nov 26, 2023

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
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
43 of 45 checks passed
@andreasabel andreasabel mentioned this pull request Dec 1, 2023
@andreasabel
Copy link
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