Skip to content

[WIP] Find previous job step result #92

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ lint:
- trufflehog@3.86.0
- trunk-toolbox@0.5.4
- yamllint@1.35.1
ignore:
- linters: [ALL]
paths:
- dist
actions:
definitions:
- id: test-pre-push
Expand Down
9 changes: 9 additions & 0 deletions __fixtures__/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { jest } from "@jest/globals";

export const debug = jest.fn();
export const error = jest.fn();
export const info = jest.fn();
export const getInput = jest.fn();
export const setOutput = jest.fn();
export const setFailed = jest.fn();
export const warning = jest.fn();
77 changes: 77 additions & 0 deletions __tests__/arguments.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { jest } from "@jest/globals";

import * as core from "../__fixtures__/core.js";
jest.unstable_mockModule("@actions/core", () => core);

const { main } = await import("../src/lib.js");

const createEchoCli = async (tmpdir: string) => {
await fs.writeFile(
path.resolve(tmpdir, "trunk-analytics-cli"),
`#!/bin/bash
echo -n $@`,
);
};

describe("Arguments", () => {
afterEach(() => {
jest.resetAllMocks();
});

it("Forwards inputs - upload", async () => {
core.getInput.mockImplementation((name) => {
switch (name) {
case "junit-paths":
return "junit.xml";
case "org-slug":
return "org";
case "token":
return "token";
case "cli-version":
return "0.0.0";
default:
return "";
}
});
const tmpdir = await fs.mkdtemp(
path.resolve(os.tmpdir(), "trunk-analytics-uploader-test-"),
);
await createEchoCli(tmpdir);
const command = await main(tmpdir);
expect(command).toMatch(
`${tmpdir}/trunk-analytics-cli upload --junit-paths "junit.xml" --org-url-slug "org" --token "token"`,
);
await fs.rm(tmpdir, { recursive: true, force: true });
});

it("Forwards inputs - test", async () => {
core.getInput.mockImplementation((name) => {
switch (name) {
case "junit-paths":
return "junit.xml";
case "org-slug":
return "org";
case "token":
return "token";
case "cli-version":
return "0.0.0";
case "run":
return "exit 0";
default:
return "";
}
});
const tmpdir = await fs.mkdtemp(
path.resolve(os.tmpdir(), "trunk-analytics-uploader-test-"),
);
await createEchoCli(tmpdir);
const command = await main(tmpdir);
expect(command).toMatch(
`${tmpdir}/trunk-analytics-cli test --junit-paths "junit.xml" --org-url-slug "org" --token "token" -- exit 0`,
);
await fs.rm(tmpdir, { recursive: true, force: true });
});
});
30 changes: 9 additions & 21 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inputs:
cli-version:
description: The version of the uploader to use.
required: false
default: latest
default: 0.7.8-beta.1
team:
description: Value to tag team owner of upload.
required: false
Expand All @@ -47,25 +47,13 @@ inputs:
hide-banner:
description: Whether to hide the top level flaky tests banner
required: false
github-token:
description: The GitHub token used to create an authenticated client
default: ${{ github.token }}
previous-step-outcome:
description: The outcome of the previous step in the workflow
required: false

runs:
using: composite
steps:
- name: Upload test results
run: ${GITHUB_ACTION_PATH}/script.sh ${{ inputs.run }}
shell: bash
env:
JUNIT_PATHS: ${{ inputs.junit-paths }}
ORG_URL_SLUG: ${{ inputs.org-slug }}
INPUT_TOKEN: ${{ inputs.token }}
REPO_HEAD_BRANCH: ${{ inputs.repo-head-branch }}
REPO_ROOT: ${{ inputs.repo-root }}
TAGS: ${{ inputs.tags }}
CLI_VERSION: ${{ inputs.cli-version }}
TEAM: ${{ inputs.team }}
QUARANTINE: ${{ inputs.quarantine }}
XCRESULT_PATH: ${{ inputs.xcresult-path }}
ALLOW_MISSING_JUNIT_FILES: ${{ inputs.allow-missing-junit-files }}
BAZEL_BEP_PATH: ${{ inputs.bazel-bep-path }}
PR_TITLE: ${{ github.event.pull_request.title }}
HIDE_BANNER: ${{ inputs.hide-banner }}
using: node20
main: dist/index.js
Loading