-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
78 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: 0 0 * * * | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
import * as fs from 'fs'; | ||
import * as resolve from '../src/resolve'; | ||
import { resolveVersion } from '../src/resolve'; | ||
import { allSet, all, versions } from './versions'; | ||
|
||
type Environment = keyof typeof versions; | ||
const environments: Environment[] = Object.keys(versions) as Environment[]; | ||
import { versionMap } from './selftest'; | ||
|
||
const code = (input: string) => '`' + input + '`'; | ||
const majorVersion = (version: string) => version.split('.').splice(0, 2).join('.'); | ||
const unique = (xs: string[]) => [...new Set(xs)]; | ||
|
||
const supports = (version: string) => (name: Environment) => { | ||
return versions[name].includes(version) ? 'oo' : 'xx'; | ||
}; | ||
async function main() { | ||
const versions = await versionMap(); | ||
|
||
const majorVersion = (version: string) => version.split('.').splice(0, 2).join('.'); | ||
type Environment = keyof typeof versions; | ||
const environments: Environment[] = Object.keys(versions) as Environment[]; | ||
|
||
const unique = (xs: string[]) => [...new Set(xs)]; | ||
const supports = (version: string) => (name: Environment) => { | ||
return versions[name].has(version) ? 'oo' : 'xx'; | ||
}; | ||
|
||
const latestMajorVersions = Object.fromEntries( | ||
unique(all.map(majorVersion)).map(major => [resolveVersion(major, allSet), major]) | ||
); | ||
const allSet = new Set(Object.values(versions).map(x => Array.from(x)).flat()); | ||
const all = [...allSet].sort(resolve.compare); | ||
|
||
function codeVersion(version: string): string { | ||
const major = latestMajorVersions[version]; | ||
return major ? `${code(version)} ${code(major)}` : code(version); | ||
} | ||
const latestMajorVersions = Object.fromEntries( | ||
unique(all.map(majorVersion)).map(major => [resolveVersion(major, allSet), major]) | ||
); | ||
|
||
function codeVersion(version: string): string { | ||
const major = latestMajorVersions[version]; | ||
return major ? `${code(version)} ${code(major)}` : code(version); | ||
} | ||
|
||
async function main() { | ||
const { markdownTable } = await import('markdown-table'); | ||
const header = [''].concat(environments.map(code)); | ||
const align = ['l'].concat(environments.map(_ => 'c')); | ||
const row = (version: string) => [codeVersion(version)].concat(environments.map(supports(version))); | ||
const rows = all.reverse().map(row); | ||
const table = [header].concat(rows); | ||
console.log(markdownTable(table, { align }).replace(/oo/g, '🟢').replace(/xx/g, '❌')); | ||
fs.writeFileSync('README.md', markdownTable(table, { align }).replace(/oo/g, '🟢').replace(/xx/g, '❌') + '\n'); | ||
} | ||
|
||
main(); | ||
if (require.main === module) { | ||
main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
import * as fs from 'fs'; | ||
import * as YAML from 'yaml'; | ||
import { versions } from './versions'; | ||
import * as resolve from '../src/resolve'; | ||
|
||
for (const [name, supported] of Object.entries(versions)) { | ||
const file = `.github/workflows/selftest.${name}.yml`; | ||
const yaml = YAML.parse(fs.readFileSync(file, 'utf8')); | ||
yaml.jobs.build.strategy.matrix.ghc = supported; | ||
fs.writeFileSync(file, YAML.stringify(yaml)); | ||
import { ppa } from '../src/apt'; | ||
import { list } from '../src/ghcup'; | ||
|
||
export async function versionMap() { | ||
const ghcup = await list(); | ||
return { | ||
'ubuntu-18.04': new Set([...ppa.ubuntu18, ...ghcup]), | ||
'ubuntu-20.04': new Set([...ppa.ubuntu20, ...ghcup]), | ||
'macos-10.15': ghcup, | ||
'macos-11': ghcup, | ||
'windows-2019': ghcup, | ||
'windows-2022': ghcup, | ||
}; | ||
} | ||
|
||
async function main() { | ||
const versions = await versionMap(); | ||
for (const [name, supported] of Object.entries(versions)) { | ||
const file = `.github/workflows/selftest.${name}.yml`; | ||
const yaml = YAML.parse(fs.readFileSync(file, 'utf8')); | ||
yaml.jobs.build.strategy.matrix.ghc = [...supported].sort(resolve.compare); | ||
fs.writeFileSync(file, YAML.stringify(yaml)); | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
main(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters