diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2fedf07..0115f57 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -15,6 +15,7 @@ defaults: shell: bash jobs: + test: name: Unit Tests - ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -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 diff --git a/dist/index.js b/dist/index.js index 752f551..107acc0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35191,6 +35191,22 @@ async function resetTool(tool, _version, os, arch) { return; } } +async function ghcupArchString(arch) { + 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) { switch (arch) { case 'arm64': @@ -35272,7 +35288,7 @@ async function ghcupBin(os, arch) { const cachedBin = tc.find('ghcup', opts_1.ghcup_version); if (cachedBin) return (0, path_1.join)(cachedBin, 'ghcup'); - const binArch = await stackArchString(arch); + const binArch = await ghcupArchString(arch); const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/${binArch}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`); await fs_1.promises.chmod(bin, 0o755); return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup'); @@ -35510,11 +35526,11 @@ function resolve(version, supported, tool, os, verbose // If resolution isn't th ) { 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}`); diff --git a/lib/installer.js b/lib/installer.js index b5727aa..bb1e89f 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -215,6 +215,22 @@ async function resetTool(tool, _version, os, arch) { return; } } +async function ghcupArchString(arch) { + 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) { switch (arch) { case 'arm64': @@ -296,7 +312,7 @@ async function ghcupBin(os, arch) { const cachedBin = tc.find('ghcup', opts_1.ghcup_version); if (cachedBin) return (0, path_1.join)(cachedBin, 'ghcup'); - const binArch = await stackArchString(arch); + const binArch = await ghcupArchString(arch); const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/${binArch}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`); await fs_1.promises.chmod(bin, 0o755); return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup'); diff --git a/lib/opts.d.ts b/lib/opts.d.ts index 9bd22ab..fae5d45 100644 --- a/lib/opts.d.ts +++ b/lib/opts.d.ts @@ -6,7 +6,7 @@ export type Revisions = Record>>; 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 { enable: boolean; diff --git a/lib/opts.js b/lib/opts.js index a4c9601..98c5be9 100644 --- a/lib/opts.js +++ b/lib/opts.js @@ -98,11 +98,11 @@ function resolve(version, supported, tool, os, verbose // If resolution isn't th ) { 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}`); diff --git a/src/installer.ts b/src/installer.ts index 5b972ae..c5c5fc3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -221,6 +221,23 @@ export async function resetTool( } } +async function ghcupArchString(arch: Arch): Promise { + 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 { switch (arch) { case 'arm64': @@ -323,7 +340,7 @@ async function ghcupBin(os: OS, arch: Arch): Promise { 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' diff --git a/src/opts.ts b/src/opts.ts index b919513..8a0776f 100644 --- a/src/opts.ts +++ b/src/opts.ts @@ -14,7 +14,7 @@ export type Revisions = Record< Record> >; 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 { @@ -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}`);