Skip to content

Commit 0512451

Browse files
authored
Fix #130: support GHCup on 32bit architecture (#131)
Allow 32bit architectures when constructing download path for GHCup. Closes #130.
1 parent 45e5652 commit 0512451

File tree

7 files changed

+133
-11
lines changed

7 files changed

+133
-11
lines changed

.github/workflows/workflow.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ defaults:
1515
shell: bash
1616

1717
jobs:
18+
1819
test:
1920
name: Unit Tests - ${{ matrix.os }}
2021
runs-on: ${{ matrix.os }}
@@ -301,3 +302,75 @@ jobs:
301302
echo "Returned stack-root: ${{ steps.setup.outputs.stack-root }}"
302303
exit 1
303304
fi
305+
306+
307+
# Test architecture ia32, see https://github.com/haskell-actions/setup/issues/130
308+
#################################################################################
309+
#
310+
# From https://github.com/0rphee/cripto_final/actions/runs/20246908790/workflow
311+
# https://github.com/0rphee/cripto_final/commit/403d115a61e4c6f960bf230e3b9149e1dee0c781
312+
#
313+
ia32:
314+
runs-on: ubuntu-latest
315+
container:
316+
image: 'i386/alpine:3.19'
317+
volumes:
318+
- /tmp:/__e/node24_alpine
319+
permissions:
320+
contents: read
321+
steps:
322+
323+
- name: Install system dependencies (Alpine)
324+
shell: sh
325+
run: |
326+
apk update
327+
apk add curl gcc g++ git gmp-dev libc-dev libffi-dev make musl-dev ncurses-dev perl tar xz bash
328+
329+
- name: Install node for actions/checkout
330+
run: |
331+
apk add nodejs npm
332+
mkdir -p /__e/node24_alpine/bin
333+
ln -sf "$(which node)" /__e/node24_alpine/bin/node
334+
ln -sf "$(which npm)" /__e/node24_alpine/bin/npm
335+
ln -sf "$(which npx)" /__e/node24_alpine/bin/npx
336+
337+
- uses: actions/checkout@v6
338+
339+
- uses: ./
340+
with:
341+
ghc-version: latest
342+
cabal-version: latest
343+
344+
# Copy of steps from main job
345+
############################################################
346+
347+
- name: Show installed versions and PATH
348+
run: |
349+
cabal --version
350+
ghc --version
351+
echo "$PATH"
352+
353+
- name: Test runghc
354+
run: |
355+
runghc --version
356+
runghc __tests__/hello.hs
357+
358+
- name: Build test project
359+
working-directory: __tests__/project
360+
run: cabal build
361+
362+
- name: Run test project
363+
working-directory: __tests__/project
364+
run: cabal run
365+
366+
- name: Install test project
367+
working-directory: __tests__/project
368+
run: cabal install
369+
370+
- name: Run installed test project
371+
run: hello-haskell-setup
372+
# This tests whether the default installdir has been added to the PATH (issue #130).
373+
374+
- name: Build and run test with Hackage dependency
375+
working-directory: __tests__/project-with-hackage-dependency
376+
run: cabal build && cabal run

dist/index.js

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/installer.js

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/opts.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/opts.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/installer.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ export async function resetTool(
221221
}
222222
}
223223

224+
async function ghcupArchString(arch: Arch): Promise<string> {
225+
switch (arch) {
226+
case 'arm64':
227+
return Promise.resolve('aarch64');
228+
case 'x64':
229+
return Promise.resolve('x86_64');
230+
case 'arm':
231+
return Promise.resolve('armv7');
232+
case 'ia32':
233+
return Promise.resolve('i386');
234+
default:
235+
const err = `Unsupported architecture: ${arch}`;
236+
core.error(err);
237+
return Promise.reject(err);
238+
}
239+
}
240+
224241
async function stackArchString(arch: Arch): Promise<string> {
225242
switch (arch) {
226243
case 'arm64':
@@ -323,7 +340,7 @@ async function ghcupBin(os: OS, arch: Arch): Promise<string> {
323340
const cachedBin = tc.find('ghcup', ghcup_version);
324341
if (cachedBin) return join(cachedBin, 'ghcup');
325342

326-
const binArch = await stackArchString(arch);
343+
const binArch = await ghcupArchString(arch);
327344
const bin = await tc.downloadTool(
328345
`https://downloads.haskell.org/ghcup/${ghcup_version}/${binArch}-${
329346
os === 'darwin' ? 'apple-darwin' : 'linux'

src/opts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type Revisions = Record<
1414
Record<Tool, Array<{from: string; to: string}>>
1515
>;
1616
export type OS = 'linux' | 'darwin' | 'win32';
17-
export type Arch = 'arm64' | 'x64';
17+
export type Arch = 'arm64' | 'x64' | 'arm' | 'ia32';
1818
export type Tool = 'cabal' | 'ghc' | 'stack';
1919

2020
export interface ProgramOpt {
@@ -98,11 +98,11 @@ function resolve(
9898
const result =
9999
version === 'latest'
100100
? supported[0]
101-
: supported.find(v => v === version) ??
101+
: (supported.find(v => v === version) ??
102102
supported.find(v => v.startsWith(version + '.')) ??
103103
// Andreas, 2023-05-19, issue #248
104104
// Append "." so that eg stack "2.1" resolves to "2.1.3" and not "2.11.1".
105-
version;
105+
version);
106106
// Andreas 2022-12-29, issue #144: inform about resolution here where we can also output ${tool}.
107107
if (verbose === true && version !== result)
108108
core.info(`Resolved ${tool} ${version} to ${result}`);

0 commit comments

Comments
 (0)