mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-27 18:54:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae80d4ecaa | ||
|
|
d00c6817f1 | ||
|
|
da3271e0a2 | ||
|
|
24b9f144af | ||
|
|
05c2a037e9 |
No files matched your search
@@ -80,6 +80,7 @@ jobs:
|
||||
tofu-wrapper: [true, false]
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: ./.github/workflows/data/local
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -31,7 +31,7 @@ A specific version of OpenTofu CLI can be installed:
|
||||
steps:
|
||||
- uses: opentofu/setup-opentofu@v1
|
||||
with:
|
||||
tofu_version: 1.6.0-alpha1
|
||||
tofu_version: 1.6.0
|
||||
```
|
||||
|
||||
Credentials for Terraform Cloud ([app.terraform.io](https://app.terraform.io/)) can be configured:
|
||||
@@ -257,6 +257,7 @@ The action supports the following inputs:
|
||||
- `tofu_wrapper` - (optional) Whether to install a wrapper to wrap subsequent calls of
|
||||
the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs
|
||||
named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
|
||||
- `github_token` - (optional) Override the GitHub token read from the environment variable. Defaults to the value of the `GITHUB_TOKEN` environment variable unless running on Forgejo or Gitea.
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
+6
-2
@@ -17,6 +17,10 @@ inputs:
|
||||
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
|
||||
default: 'true'
|
||||
required: false
|
||||
github_token:
|
||||
description: 'API token for GitHub to increase the rate limit. Defaults to the GITHUB_TOKEN environment variable unless running on Forgejo/Gitea.'
|
||||
default: ''
|
||||
required: false
|
||||
outputs:
|
||||
stdout:
|
||||
description: 'The STDOUT stream of the call to the `tofu` binary.'
|
||||
@@ -29,8 +33,8 @@ outputs:
|
||||
value: '126'
|
||||
|
||||
branding:
|
||||
icon: 'terminal'
|
||||
color: 'purple'
|
||||
icon: 'box'
|
||||
color: 'yellow'
|
||||
runs:
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
Vendored
+15
-8
@@ -33,7 +33,7 @@ class Release {
|
||||
*
|
||||
* @return {Array<Release>} Releases.
|
||||
*/
|
||||
async function fetchReleases () {
|
||||
async function fetchReleases (githubToken) {
|
||||
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
||||
|
||||
const headers = {
|
||||
@@ -41,8 +41,8 @@ async function fetchReleases () {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
};
|
||||
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
||||
if (githubToken) {
|
||||
headers.Authorization = `Bearer ${githubToken}`;
|
||||
}
|
||||
|
||||
const resp = await fetch(url, {
|
||||
@@ -50,7 +50,7 @@ async function fetchReleases () {
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error('failed fetching releases');
|
||||
throw new Error('failed fetching releases (' + resp.status + ')');
|
||||
}
|
||||
|
||||
const releasesMeta = await resp.json();
|
||||
@@ -61,7 +61,7 @@ async function fetchReleases () {
|
||||
const semver = __nccwpck_require__(1383);
|
||||
|
||||
async function findLatestVersion (versions) {
|
||||
return versions.sort((a, b) => semver.rcompare(a, b))[0];
|
||||
return versions.filter((v) => semver.prerelease(v) === null).sort((a, b) => semver.rcompare(a, b))[0];
|
||||
}
|
||||
|
||||
async function findLatestVersionInRange (versions, range) {
|
||||
@@ -72,10 +72,11 @@ async function findLatestVersionInRange (versions, range) {
|
||||
* Fetches the release given the version.
|
||||
*
|
||||
* @param {string} version: Release version.
|
||||
* @param {string} githubToken: GitHub token to use for working around rate limits.
|
||||
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
||||
* @return {Release} Release.
|
||||
*/
|
||||
async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
||||
async function getRelease (version, githubToken, fetchReleasesFn = fetchReleases) {
|
||||
const latestVersionLabel = 'latest';
|
||||
|
||||
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
||||
@@ -83,7 +84,7 @@ async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
||||
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
||||
}
|
||||
|
||||
const releases = await fetchReleasesFn();
|
||||
const releases = await fetchReleasesFn(githubToken);
|
||||
|
||||
if (releases === null || releases.length === 0) {
|
||||
throw new Error('No tofu releases found, please contact OpenTofu');
|
||||
@@ -251,13 +252,19 @@ async function run () {
|
||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||
let githubToken = core.getInput('github_token');
|
||||
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
||||
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
||||
// that may set the GITHUB_TOKEN environment variable.
|
||||
githubToken = process.env.GITHUB_TOKEN;
|
||||
}
|
||||
|
||||
// Gather OS details
|
||||
const osPlatform = os.platform();
|
||||
const osArch = os.arch();
|
||||
|
||||
core.debug(`Finding releases for OpenTofu version ${version}`);
|
||||
const release = await releases.getRelease(version);
|
||||
const release = await releases.getRelease(version, githubToken);
|
||||
const platform = mapOS(osPlatform);
|
||||
const arch = mapArch(osArch);
|
||||
const build = release.getBuild(platform, arch);
|
||||
|
||||
+8
-7
@@ -27,7 +27,7 @@ class Release {
|
||||
*
|
||||
* @return {Array<Release>} Releases.
|
||||
*/
|
||||
async function fetchReleases () {
|
||||
async function fetchReleases (githubToken) {
|
||||
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
||||
|
||||
const headers = {
|
||||
@@ -35,8 +35,8 @@ async function fetchReleases () {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
};
|
||||
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
||||
if (githubToken) {
|
||||
headers.Authorization = `Bearer ${githubToken}`;
|
||||
}
|
||||
|
||||
const resp = await fetch(url, {
|
||||
@@ -44,7 +44,7 @@ async function fetchReleases () {
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error('failed fetching releases');
|
||||
throw new Error('failed fetching releases (' + resp.status + ')');
|
||||
}
|
||||
|
||||
const releasesMeta = await resp.json();
|
||||
@@ -55,7 +55,7 @@ async function fetchReleases () {
|
||||
const semver = require('semver');
|
||||
|
||||
async function findLatestVersion (versions) {
|
||||
return versions.sort((a, b) => semver.rcompare(a, b))[0];
|
||||
return versions.filter((v) => semver.prerelease(v) === null).sort((a, b) => semver.rcompare(a, b))[0];
|
||||
}
|
||||
|
||||
async function findLatestVersionInRange (versions, range) {
|
||||
@@ -66,10 +66,11 @@ async function findLatestVersionInRange (versions, range) {
|
||||
* Fetches the release given the version.
|
||||
*
|
||||
* @param {string} version: Release version.
|
||||
* @param {string} githubToken: GitHub token to use for working around rate limits.
|
||||
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
||||
* @return {Release} Release.
|
||||
*/
|
||||
async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
||||
async function getRelease (version, githubToken, fetchReleasesFn = fetchReleases) {
|
||||
const latestVersionLabel = 'latest';
|
||||
|
||||
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
||||
@@ -77,7 +78,7 @@ async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
||||
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
||||
}
|
||||
|
||||
const releases = await fetchReleasesFn();
|
||||
const releases = await fetchReleasesFn(githubToken);
|
||||
|
||||
if (releases === null || releases.length === 0) {
|
||||
throw new Error('No tofu releases found, please contact OpenTofu');
|
||||
|
||||
+7
-1
@@ -132,13 +132,19 @@ async function run () {
|
||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||
let githubToken = core.getInput('github_token');
|
||||
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
||||
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
||||
// that may set the GITHUB_TOKEN environment variable.
|
||||
githubToken = process.env.GITHUB_TOKEN;
|
||||
}
|
||||
|
||||
// Gather OS details
|
||||
const osPlatform = os.platform();
|
||||
const osArch = os.arch();
|
||||
|
||||
core.debug(`Finding releases for OpenTofu version ${version}`);
|
||||
const release = await releases.getRelease(version);
|
||||
const release = await releases.getRelease(version, githubToken);
|
||||
const platform = mapOS(osPlatform);
|
||||
const arch = mapArch(osArch);
|
||||
const build = release.getBuild(platform, arch);
|
||||
|
||||
+187
-6
@@ -3,6 +3,184 @@ const pkg = require('../releases');
|
||||
describe('getRelease', () => {
|
||||
function mockFetchReleases () {
|
||||
const mockReleasesMeta = [{
|
||||
tag_name: 'v1.7.0-alpha2',
|
||||
assets: [{
|
||||
name: 'tofu_1.7.0-alpha2_386.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.apk'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_386.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.deb'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_386.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_amd64.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.apk'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_amd64.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.deb'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_amd64.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.apk'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.deb'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm64.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.apk'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm64.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.deb'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_arm64.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.rpm'
|
||||
}, {
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_darwin_arm64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_arm64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_freebsd_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_freebsd_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_freebsd_arm.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_arm.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_linux_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_linux_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_linux_arm.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_linux_arm64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_openbsd_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_openbsd_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_SHA256SUMS',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_SHA256SUMS.pem',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.pem'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_SHA256SUMS.sig',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.sig'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_solaris_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_solaris_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_windows_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.7.0-alpha2_windows_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_amd64.zip'
|
||||
}]
|
||||
}, {
|
||||
tag_name: 'v1.6.0',
|
||||
assets: [{
|
||||
name: 'tofu_1.6.0_386.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.apk'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_386.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.deb'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_386.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_amd64.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.apk'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_amd64.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.deb'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_amd64.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.apk'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.deb'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.rpm'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm64.apk',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.apk'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm64.deb',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.deb'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_arm64.rpm',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.rpm'
|
||||
}, {
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_darwin_arm64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_arm64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_freebsd_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_freebsd_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_freebsd_arm.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_arm.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_linux_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_linux_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_linux_arm.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_linux_arm64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_openbsd_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_openbsd_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_SHA256SUMS',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_SHA256SUMS.pem',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.pem'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_SHA256SUMS.sig',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.sig'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_solaris_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_solaris_amd64.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_windows_386.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_386.zip'
|
||||
}, {
|
||||
name: 'tofu_1.6.0_windows_amd64.zip',
|
||||
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_amd64.zip'
|
||||
}]
|
||||
}, {
|
||||
tag_name: 'v1.6.0-alpha2',
|
||||
assets: [{
|
||||
name: 'tofu_1.6.0-alpha2_386.apk',
|
||||
@@ -188,16 +366,19 @@ describe('getRelease', () => {
|
||||
|
||||
it.each(
|
||||
[
|
||||
['latest', '1.6.0-alpha2'],
|
||||
['latest', '1.6.0'],
|
||||
['<1.6.0-beta', '1.6.0-alpha2'],
|
||||
['>1.6.0-alpha1', '1.6.0-alpha2'],
|
||||
['>1.6.0-alpha1', '1.6.0'],
|
||||
['>1.6.0-alpha1 <1.6.0', '1.6.0-alpha2'],
|
||||
['~1.6.0-alpha', '1.6.0-alpha2'],
|
||||
['<=1.6.0-alpha1', '1.6.0-alpha1']
|
||||
['~1.6.0-alpha', '1.6.0'],
|
||||
['<=1.6.0-alpha1', '1.6.0-alpha1'],
|
||||
['>1.5.0', '1.6.0'],
|
||||
['>1.5.0', '1.6.0'],
|
||||
['>1.7.0-alpha', '1.7.0-alpha2']
|
||||
]
|
||||
)('happy path: getRelease(\'%s\') -> \'%s\'', async (input, wantVersion) => {
|
||||
const want = mockFetchReleases().find(el => el.version === wantVersion);
|
||||
const gotRelease = await pkg.getRelease(input, mockFetchReleases);
|
||||
const gotRelease = await pkg.getRelease(input, '', mockFetchReleases);
|
||||
expect(gotRelease).toEqual(want);
|
||||
});
|
||||
|
||||
@@ -210,7 +391,7 @@ describe('getRelease', () => {
|
||||
]
|
||||
)('unhappy path: getRelease(\'%s\') -> throw Error(\'%s\')', async (input, wantErrorMessage, mockFetchReleasesFn) => {
|
||||
try {
|
||||
await pkg.getRelease(input, mockFetchReleasesFn);
|
||||
await pkg.getRelease(input, '', mockFetchReleasesFn);
|
||||
expect(true).toBe(false);
|
||||
} catch (e) {
|
||||
expect(e.message).toBe(wantErrorMessage);
|
||||
|
||||
Generated
+6
-6
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.38.1",
|
||||
"husky": "8.0.3",
|
||||
"husky": "9.0.11",
|
||||
"jest": "29.7.0",
|
||||
"semistandard": "17.0.0"
|
||||
}
|
||||
@@ -3361,15 +3361,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/husky": {
|
||||
"version": "8.0.3",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
|
||||
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
|
||||
"version": "9.0.11",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
|
||||
"integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"husky": "lib/bin.js"
|
||||
"husky": "bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/typicode"
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.38.1",
|
||||
"husky": "8.0.3",
|
||||
"husky": "9.0.11",
|
||||
"jest": "29.7.0",
|
||||
"semistandard": "17.0.0"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user