Skip to content

Allow specifying previous step outcome #96

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

Merged
merged 1 commit into from
May 5, 2025
Merged
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 action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ inputs:
variant:
description: User specified variant of a set of tests being uploaded.
required: false
previous-step-outcome:
description: The outcome of the previous step in the workflow. Set this equal to steps.[id].outcome where `[id]` is the id of the corresponding test run.
required: false

runs:
using: composite
Expand All @@ -73,3 +76,4 @@ runs:
PR_TITLE: ${{ github.event.pull_request.title }}
HIDE_BANNER: ${{ inputs.hide-banner }}
VARIANT: ${{ inputs.variant }}
PREVIOUS_STEP_OUTCOME: ${{ inputs.previous-step-outcome }}
9 changes: 9 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ BAZEL_BEP_PATH="${BAZEL_BEP_PATH-}"
ALLOW_MISSING_JUNIT_FILES_ARG=$(parse_bool "${ALLOW_MISSING_JUNIT_FILES}" "--allow-missing-junit-files")
HIDE_BANNER=$(parse_bool "${HIDE_BANNER}" "--hide-banner")
QUARANTINE_ARG=$(parse_bool "${QUARANTINE}" "--use-quarantining")
if [[ -n ${PREVIOUS_STEP_OUTCOME} ]]; then
if [[ ${PREVIOUS_STEP_OUTCOME} == "success" ]]; then
PREVIOUS_STEP_OUTCOME="0"
else
PREVIOUS_STEP_OUTCOME="1"
fi
fi
VARIANT="${VARIANT-}"

# CLI.
Expand All @@ -99,6 +106,7 @@ if [[ $# -eq 0 ]]; then
${REPO_HEAD_BRANCH:+--repo-head-branch "${REPO_HEAD_BRANCH}"} \
--repo-root "${REPO_ROOT}" \
--team "${TEAM}" \
${PREVIOUS_STEP_OUTCOME:+--test-process-exit-code="${PREVIOUS_STEP_OUTCOME}"} \
${ALLOW_MISSING_JUNIT_FILES_ARG} \
${HIDE_BANNER} \
${VARIANT:+--variant "${VARIANT}"} \
Expand All @@ -113,6 +121,7 @@ else
${REPO_HEAD_BRANCH:+--repo-head-branch "${REPO_HEAD_BRANCH}"} \
--repo-root "${REPO_ROOT}" \
--team "${TEAM}" \
${PREVIOUS_STEP_OUTCOME:+--test-process-exit-code="${PREVIOUS_STEP_OUTCOME}"} \
${ALLOW_MISSING_JUNIT_FILES_ARG} \
${HIDE_BANNER} \
${VARIANT:+--variant "${VARIANT}"} \
Expand Down
3 changes: 2 additions & 1 deletion tests/arguments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test("Forwards inputs", async () => {
ALLOW_MISSING_JUNIT_FILES: "",
BAZEL_BEP_PATH: "",
HIDE_BANNER: "",
PREVIOUS_STEP_OUTCOME: "success",
};

const scriptPath = path.resolve(repoRoot, "script.sh");
Expand All @@ -57,7 +58,7 @@ test("Forwards inputs", async () => {
}
expect({ stdout, stderr, exit_code }).toMatchObject({
stdout:
"upload --junit-paths junit.xml --org-url-slug org --token token --repo-root --team",
"upload --junit-paths junit.xml --org-url-slug org --token token --repo-root --team --test-process-exit-code=0",
stderr: `+ [[ 0.0.0 == \\l\\a\\t\\e\\s\\t ]]
+ [[ -f ./trunk-analytics-cli ]]
+ chmod +x ./trunk-analytics-cli
Expand Down