Skip to content

Commit

Permalink
XXX remove
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Dec 12, 2024
1 parent e01f5a4 commit 208d8d2
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 135 deletions.
53 changes: 2 additions & 51 deletions .github/workflows/selftest.macos-13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cron: 0 0 1 * *
push:
branches:
- selftest
- update
jobs:
build:
name: ${{ matrix.os }} / GHC ${{ matrix.ghc }}
Expand All @@ -21,58 +21,9 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- macos-13
ghc:
- 7.10.3
- 8.0.2
- 8.2.2
- 8.4.1
- 8.4.2
- 8.4.3
- 8.4.4
- 8.6.1
- 8.6.2
- 8.6.3
- 8.6.4
- 8.6.5
- 8.8.1
- 8.8.2
- 8.8.3
- 8.8.4
- 8.10.1
- 8.10.2
- 8.10.3
- 8.10.4
- 8.10.5
- 8.10.6
- 8.10.7
- 9.0.1
- 9.0.2
- 9.2.1
- 9.2.2
- 9.2.3
- 9.2.4
- 9.2.5
- 9.2.6
- 9.2.7
- 9.2.8
- 9.4.1
- 9.4.2
- 9.4.3
- 9.4.4
- 9.4.5
- 9.4.6
- 9.4.7
- 9.4.8
- 9.6.1
- 9.6.2
- 9.6.3
- 9.6.4
- 9.6.5
- 9.6.6
- 9.8.1
- 9.8.2
- 9.8.4
- 9.10.1
1 change: 1 addition & 0 deletions .github/workflows/selftest.macos-14.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- macos-14
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.macos-15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- macos-15
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.ubuntu-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.ubuntu-22.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.ubuntu-24.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.windows-2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- windows-2019
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/selftest.windows-2022.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: cabal install alex
- run: alex --version
strategy:
fail-fast: false
matrix:
os:
- windows-2022
Expand Down
100 changes: 50 additions & 50 deletions README.md

Large diffs are not rendered by default.

57 changes: 41 additions & 16 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion generate/selftest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function versionMap() {
'ubuntu-20.04': new Set([...ppa.ubuntu20, ...ghcup]),
'ubuntu-22.04': new Set([...ghcup].filter(v => !not_working_on_ubuntu_22_04.has(v))),
'ubuntu-24.04': ghcup,
'macos-13': ghcup,
'macos-13': new Set(['9.8.2']),
'macos-14': ghcup,
'macos-15': ghcup,
'windows-2019': ghcup,
Expand Down
19 changes: 18 additions & 1 deletion src/ghcup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import * as core from '@actions/core';
import { exec, getExecOutput } from '@actions/exec';
import { compareVersions } from './resolve';
import { which } from '@actions/io';

export async function ensure() {
if (!await which('ghcup')) {
await exec('brew install ghcup');
const home = process.env['HOME'];
if (home) {
core.addPath(home + '/.ghcup/bin/');
}
}
if (!await which('cabal')) {
await exec('ghcup install cabal latest --set');
const result = await getExecOutput('cabal', ['path', '-v0', '--installdir'], {
silent: true,
});
core.addPath(result.stdout.trim());
}
}

export async function install(version: string) {
const older804 = compareVersions(version, '8.4') == -1;
Expand All @@ -12,7 +30,6 @@ export async function install(version: string) {
}
await core.group('ghcup install', async () => {
await exec(`ghcup install ghc ${version} --set`);
core.addPath('$HOME/.ghcup/bin');
});
}

Expand Down
9 changes: 1 addition & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { installed, resolve, ResolvedVersion } from './resolve';

async function main() {
try {
await ghcup.ensure();
await workaroundRunnerImageIssue7061();
await addCabalBinToPath();
const requested = core.getInput('ghc-version');
const version = await ensure(requested);
core.setOutput('ghc-version', version);
Expand All @@ -32,13 +32,6 @@ async function workaroundRunnerImageIssue7061() {
});
}

async function addCabalBinToPath() {
const home = process.env['HOME'];
if (home) {
core.addPath(home + '/.cabal/bin/');
}
}

async function ensure(requested: string): Promise<string> {
const resolved = await resolve(requested);
await install(resolved);
Expand Down
29 changes: 21 additions & 8 deletions src/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getExecOutput } from '@actions/exec';
import { which } from '@actions/io';

import * as apt from './apt';
import * as ghcup from './ghcup';
Expand Down Expand Up @@ -39,18 +40,26 @@ export type ResolvedVersion = {
source: 'system' | 'apt' | 'ghcup';
};

async function resolveFoo(requested: string): Promise<string | undefined> {
const versions = new Set([...apt.versions(), ...await ghcup.list()]);
return resolveVersion(requested, versions);
}

export async function resolve(requested: string): Promise<ResolvedVersion> {
const systemVersion = await installed();
const aptVersions = apt.versions();

let version;
if (requested === 'system') {
version = systemVersion;
if (systemVersion) {
version = systemVersion;
} else {
version = await resolveFoo('latest');
}
} else if (apt.versions().has(requested)) {
version = requested;
} else {
const versions = new Set([...apt.versions(), ...await ghcup.list()]);
version = resolveVersion(requested, versions);
version = await resolveFoo(requested);
}

if (version) {
Expand All @@ -65,9 +74,13 @@ export async function resolve(requested: string): Promise<ResolvedVersion> {
}
}

export async function installed(): Promise<string> {
const result = await getExecOutput('ghc', ['--numeric-version'], {
silent: true,
});
return result.stdout.trim();
export async function installed(): Promise<string | undefined> {
if (await which('ghc')) {
const result = await getExecOutput('ghc', ['--numeric-version'], {
silent: true,
});
return result.stdout.trim();
} else {
return undefined;
}
}

0 comments on commit 208d8d2

Please sign in to comment.