mirror of
https://github.com/earthly/actions-setup.git
synced 2024-12-26 22:41:01 +08:00
Fix arch is undefined, update tests, and allow manual invocation of action (#8)
* [ci]: Add workflow_dispatch event to allow running manually * [fix]: update jest snapshots to latest version * [ci]: Add GitHub token when running CI * [fix]: update test to new format of earthly version command * [chore]: run earthly +compile * [fix]: try swapping back to amd64 * [ci]: make all checkout actions use the token * [revert]: undo change to .gitignore * [revert]: Remove snapshot tests and use semver comparison instead * [ci]: patch version regexp * [chore]: actually use the version string * [ci]: add GITHUB_TOKEN env variable to prevent rate limiting * [test]: ensure we are checking for less than as well
This commit is contained in:
parent
7702c2adbf
commit
c2d4f803a6
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@ -1,11 +1,15 @@
|
||||
name: "Test action-install-earthly"
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
- "releases/*"
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
name: earthly +all
|
||||
@ -15,6 +19,8 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||
@ -30,6 +36,8 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||
@ -47,6 +55,8 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||
@ -65,6 +75,8 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||
@ -83,6 +95,8 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GRISWOLDTHECAT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||
|
@ -51,7 +51,9 @@ test-run:
|
||||
RUN ! grep 'Found tool in cache' output
|
||||
RUN cat output | grep '^::add-path::' | sed 's/::add-path:://g' > earthly-path
|
||||
RUN test "$(cat earthly-path)" = "/root/.earthly/bin"
|
||||
RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.*linux/amd64; Linux'
|
||||
# [a-zA-Z0-9]* attempt to match a commit hash
|
||||
RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | tee version.output
|
||||
RUN grep '^earthly version v.*linux/amd64; Alpine Linux' version.output
|
||||
|
||||
# validate cache was used
|
||||
RUN node dist/setup/index.js | tee output2
|
||||
|
3
dist/setup/index.js
vendored
3
dist/setup/index.js
vendored
@ -68324,7 +68324,8 @@ function run() {
|
||||
throw new Error(`Unsupported operating system - ${pkgName} is only released for ${Object.keys(nodePlatformToReleasePlatform).join(", ")}`);
|
||||
}
|
||||
const releasePlatform = nodePlatformToReleasePlatform[runnerPlatform];
|
||||
const releaseArch = nodeArchToReleaseArch[os.arch()];
|
||||
const osArch = os.arch();
|
||||
const releaseArch = nodeArchToReleaseArch[os.arch()] || osArch;
|
||||
const range = core.getInput("version");
|
||||
core.info(`Configured range: ${range}`);
|
||||
const version = yield (0, get_version_1.getVersionObject)(range);
|
||||
|
2
dist/setup/index.js.map
vendored
2
dist/setup/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`get-version range versions should match ^0 versions 1`] = `"v0.6.14"`;
|
||||
|
||||
exports[`get-version range versions should match 0.*.* versions 1`] = `"v0.6.14"`;
|
||||
|
||||
exports[`get-version range versions should match 0.4.* versions 1`] = `"v0.4.6"`;
|
||||
|
||||
exports[`get-version range versions should match 0.6.1 versions 1`] = `"v0.6.1"`;
|
||||
|
||||
exports[`get-version range versions should match 0.6.1 versions 2`] = `"v0.6.1"`;
|
||||
|
||||
exports[`get-version range versions should match latest versions 1`] = `"v0.6.14"`;
|
||||
|
||||
exports[`get-version range versions should match v0.4.* versions 1`] = `"v0.4.6"`;
|
||||
|
||||
exports[`get-version range versions should match v0.6.0 versions 1`] = `"v0.6.0"`;
|
@ -1,22 +1,29 @@
|
||||
import * as playback from "jest-playback";
|
||||
import { getVersionObject } from "../get-version";
|
||||
playback.setup(__dirname);
|
||||
import {getVersionObject} from "../get-version";
|
||||
import * as semver from 'semver';
|
||||
|
||||
// The latest version since this test was last changed
|
||||
// Feel free to update it if earthly has been updated
|
||||
const latest = '0.6.23';
|
||||
|
||||
describe("get-version", () => {
|
||||
// process.env.GITHUB_TOKEN = process.env.GITHUB_TOKEN || "my-token";
|
||||
describe("range versions", () => {
|
||||
it.each([
|
||||
"latest",
|
||||
"^0",
|
||||
"0.*.*",
|
||||
"0.4.*",
|
||||
"v0.4.*",
|
||||
"0.6.1",
|
||||
"v0.6.0",
|
||||
"0.6.1",
|
||||
] as const)("should match %s versions", async (ver) => {
|
||||
const v = await getVersionObject(ver);
|
||||
expect(v.tag_name).toMatchSnapshot();
|
||||
describe('latest range versions', () => {
|
||||
it.each(["latest", "*", "^0", "0.*.*", "0.6.*"] as const)("should match %s versions", async (ver) => {
|
||||
const v = await getVersionObject(ver);
|
||||
expect(semver.gte(v.tag_name, latest));
|
||||
});
|
||||
});
|
||||
describe("range versions", () => {
|
||||
it.each([
|
||||
{spec: "0.4.*", gte: "0.4.0", lt: "0.5.0"},
|
||||
{spec: "v0.4.*", gte: "0.4.0", lt: "0.5.0"},
|
||||
{spec: "0.6.1", eq: '0.6.1'},
|
||||
{spec: "v0.6.0", eq: "0.6.0"},
|
||||
] as const)("should match %s versions", async (test) => {
|
||||
console.log(JSON.stringify(test));
|
||||
const v = await getVersionObject(test.spec);
|
||||
if (test.gte) expect(semver.gte(v.tag_name, test.gte));
|
||||
if (test.lt) expect(semver.lt(v.tag_name, test.lt));
|
||||
if (test.eq) expect(semver.eq(v.tag_name, test.eq));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -37,7 +37,8 @@ async function run() {
|
||||
}
|
||||
|
||||
const releasePlatform = nodePlatformToReleasePlatform[runnerPlatform];
|
||||
const releaseArch = nodeArchToReleaseArch[os.arch()];
|
||||
const osArch = os.arch();
|
||||
const releaseArch = nodeArchToReleaseArch[os.arch()] || osArch;
|
||||
|
||||
const range = core.getInput("version");
|
||||
core.info(`Configured range: ${range}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user