-
Notifications
You must be signed in to change notification settings - Fork 23
Pin version opt #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pin version opt #266
Changes from 19 commits
484e8b7
a0d75a8
5a07d5f
463c182
327a861
81c02b4
7fc4737
b92a100
1aefdd1
963615d
7e4f07e
600baa3
f1771fe
72bb0d9
f0539db
7494de9
53cffc0
f902777
6404b54
1311655
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v20.16.0 | ||
| v20.19.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env -S mise tool-stub | ||
| # Tool for running github actions locally for testing. | ||
|
|
||
| version = "latest" | ||
| tool = "act" | ||
| bin = "act" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| nodejs 20.16.0 | ||
| nodejs 20.19.0 |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [tasks.build-dist] | ||
| description = 'Build the dist/ version of the program.' | ||
| run = ''' | ||
| yarn build | ||
| ''' | ||
|
|
||
| [tasks.lint] | ||
| description = 'Lint the project.' | ||
| run = 'yarn lint' | ||
|
|
||
| [tasks.lint-fix] | ||
| description = 'Lint the project while also auto-fixing things that can be.' | ||
| run = 'yarn lint --fix' | ||
|
|
||
| [tasks.test-local] | ||
| description = 'Use `act` to test locally.' | ||
| run = './.stubs/act push -s fossaApiKey=${FOSSA_API_KEY}' | ||
|
|
||
| [tools] | ||
| node = "20.19.0" | ||
| "npm:eslint" = "latest" | ||
| "npm:yarn" = "latest" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { addPath, debug } from '@actions/core'; | |||||
| import { exec } from '@actions/exec'; | ||||||
| import { find, downloadTool, cacheDir, cacheFile, findAllVersions } from '@actions/tool-cache'; | ||||||
| import * as fs from 'node:fs'; | ||||||
| import { PINNED_CLI_VERSION } from './config'; | ||||||
|
|
||||||
| const CACHE_NAME = 'fossa'; | ||||||
|
|
||||||
|
|
@@ -38,6 +39,28 @@ async function getInstaller() { | |||||
| return downloadPath; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Select a CLI version to install. | ||||||
| * | ||||||
| * Defaults to latest. | ||||||
| */ | ||||||
| function selectCliVersion(platform: string) : string { | ||||||
| let selectedCliVersion: string; | ||||||
|
|
||||||
| if (PINNED_CLI_VERSION) { | ||||||
| const trimmed = PINNED_CLI_VERSION.trimStart(); | ||||||
| if (trimmed.startsWith('v')) { | ||||||
| selectedCliVersion = trimmed; | ||||||
| } else { | ||||||
| selectedCliVersion = `v${trimmed}`; | ||||||
| } | ||||||
| } else { | ||||||
| selectedCliVersion = findAllVersions(CACHE_NAME, platform).sort().reverse()[0] || '-1'; // We'll never cache a version as -1 | ||||||
| } | ||||||
|
|
||||||
| return selectedCliVersion; | ||||||
| } | ||||||
|
|
||||||
| export async function fetchFossaCli(): Promise<void> { | ||||||
| const devNull = fs.createWriteStream('/dev/null', {flags: 'a'}); | ||||||
| const defaultOptions = {outStream: devNull}; | ||||||
|
|
@@ -46,15 +69,18 @@ export async function fetchFossaCli(): Promise<void> { | |||||
| const platform = getPlatform(); | ||||||
|
|
||||||
| // Get cached path | ||||||
| const latestVersion = findAllVersions(CACHE_NAME, platform).sort().reverse()[0] || '-1'; // We'll never cache a version as -1 | ||||||
| let fossaPath = find(CACHE_NAME, latestVersion, platform); | ||||||
| const selectedCliVersion = selectCliVersion(platform); | ||||||
|
|
||||||
| let fossaPath = find(CACHE_NAME, selectedCliVersion, platform); | ||||||
|
|
||||||
| if (latestVersion) debug(`Using FOSSA version ${latestVersion}`); | ||||||
| if (selectedCliVersion) debug(`Using FOSSA version ${selectedCliVersion}`); | ||||||
|
|
||||||
| if (!fossaPath) { | ||||||
| debug(`Fetching new FOSSA version`); | ||||||
|
|
||||||
| if (await exec('bash', [installer, '-b', './fossa'], {...defaultOptions}) !== 0) { | ||||||
| const versionArgs = (selectedCliVersion !== '-1' && [selectedCliVersion]) || []; | ||||||
|
||||||
| const versionArgs = (selectedCliVersion !== '-1' && [selectedCliVersion]) || []; | |
| const versionArgs = selectedCliVersion !== '-1' ? [selectedCliVersion] : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes when you get in that head-space it's hard to jump back out...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to trim trailing spaces too, no?