Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defaults:
shell: bash

jobs:

test:
name: Unit Tests - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -301,3 +302,75 @@ jobs:
echo "Returned stack-root: ${{ steps.setup.outputs.stack-root }}"
exit 1
fi


# Test architecture ia32, see https://github.com/haskell-actions/setup/issues/130
#################################################################################
#
# From https://github.com/0rphee/cripto_final/actions/runs/20246908790/workflow
# https://github.com/0rphee/cripto_final/commit/403d115a61e4c6f960bf230e3b9149e1dee0c781
#
ia32:
runs-on: ubuntu-latest
container:
image: 'i386/alpine:3.19'
volumes:
- /tmp:/__e/node24_alpine
permissions:
contents: read
steps:

- name: Install system dependencies (Alpine)
shell: sh
run: |
apk update
apk add curl gcc g++ git gmp-dev libc-dev libffi-dev make musl-dev ncurses-dev perl tar xz bash

- name: Install node for actions/checkout
run: |
apk add nodejs npm
mkdir -p /__e/node24_alpine/bin
ln -sf "$(which node)" /__e/node24_alpine/bin/node
ln -sf "$(which npm)" /__e/node24_alpine/bin/npm
ln -sf "$(which npx)" /__e/node24_alpine/bin/npx

- uses: actions/checkout@v6

- uses: ./
with:
ghc-version: latest
cabal-version: latest

# Copy of steps from main job
############################################################

- name: Show installed versions and PATH
run: |
cabal --version
ghc --version
echo "$PATH"

- name: Test runghc
run: |
runghc --version
runghc __tests__/hello.hs

- name: Build test project
working-directory: __tests__/project
run: cabal build

- name: Run test project
working-directory: __tests__/project
run: cabal run

- name: Install test project
working-directory: __tests__/project
run: cabal install

- name: Run installed test project
run: hello-haskell-setup
# This tests whether the default installdir has been added to the PATH (issue #130).

- name: Build and run test with Hackage dependency
working-directory: __tests__/project-with-hackage-dependency
run: cabal build && cabal run
22 changes: 19 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/opts.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/opts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,23 @@ export async function resetTool(
}
}

async function ghcupArchString(arch: Arch): Promise<string> {
switch (arch) {
case 'arm64':
return Promise.resolve('aarch64');
case 'x64':
return Promise.resolve('x86_64');
case 'arm':
return Promise.resolve('armv7');
case 'ia32':
return Promise.resolve('i386');
default:
const err = `Unsupported architecture: ${arch}`;
core.error(err);
return Promise.reject(err);
}
}

async function stackArchString(arch: Arch): Promise<string> {
switch (arch) {
case 'arm64':
Expand Down Expand Up @@ -323,7 +340,7 @@ async function ghcupBin(os: OS, arch: Arch): Promise<string> {
const cachedBin = tc.find('ghcup', ghcup_version);
if (cachedBin) return join(cachedBin, 'ghcup');

const binArch = await stackArchString(arch);
const binArch = await ghcupArchString(arch);
const bin = await tc.downloadTool(
`https://downloads.haskell.org/ghcup/${ghcup_version}/${binArch}-${
os === 'darwin' ? 'apple-darwin' : 'linux'
Expand Down
6 changes: 3 additions & 3 deletions src/opts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Revisions = Record<
Record<Tool, Array<{from: string; to: string}>>
>;
export type OS = 'linux' | 'darwin' | 'win32';
export type Arch = 'arm64' | 'x64';
export type Arch = 'arm64' | 'x64' | 'arm' | 'ia32';
export type Tool = 'cabal' | 'ghc' | 'stack';

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