Skip to content

Commit 36ef87d

Browse files
authored
Support override of Mayhem project name (#159)
* Added a new input, `project` which allows action callers to override the `--project` argument that is passed to the `mayhem` CLI. If not set, the existing behavior remains unchanged -- falling back to the GitHub repository name for the project.
1 parent 148de75 commit 36ef87d

5 files changed

Lines changed: 22 additions & 15 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
uses: github/codeql-action/upload-sarif@v2
132132
with:
133133
sarif_file: sarif
134-
134+
135135
- name: Archive Coverage report
136136
uses: actions/upload-artifact@v3
137137
with:
@@ -143,7 +143,7 @@ jobs:
143143
with:
144144
name: mcode-junit
145145
path: junit
146-
146+
147147
- name: Upload SARIF file(s)
148148
uses: github/codeql-action/upload-sarif@v2
149149
with:
@@ -160,6 +160,8 @@ The mCode Action accepts the following inputs:
160160
| | `sarif-output` | string | Path for generating a SARIF report output file. |
161161
| | `junit-output` | string | Path for generating a jUnit report output file. |
162162
| | `coverage-output` | string | Path for generating a coverage report output files. |
163+
| | `owner` | string | The workspace for the run. |
164+
| | `project` | string | The name of the project | Defaults to the name of your repository if not defined. |
163165

164166
The mCode Action provides the following outputs:
165167
| Output Name | Type | Description | Default

action.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Mayhem for Code"
2-
description: "Automatically test your Rust targets with Mayhem"
2+
description: "Automatically test your binary targets with Mayhem"
33
author: "ForAllSecure"
44
inputs:
55
mayhem-token:
@@ -9,35 +9,38 @@ inputs:
99
description: URL pointing to your Mayhem instance
1010
required: false
1111
owner:
12-
description: sets the owner of the project (organization or user).
12+
description: Sets the owner of the project (workspace or account name).
1313
required: false
1414
default: ${{ github.repository_owner }}
15+
project:
16+
description: Sets the name of the project. Defaults to the name of your repository if not defined.
17+
required: false
1518
github-token:
16-
description: github token for posting feedback
19+
description: GitHub token for posting feedback
1720
required: false
1821
default: ${{ github.token }}
1922
sarif-output:
2023
description: SARIF output path (must be a directory, doesn't have to exist yet). You can upload to to GitHub using the 'github/codeql-action/upload-sarif@v1' action
2124
required: false
2225
junit-output:
23-
description: jUnit output path (must be a directory, doesn't have to exist yet). You can upload the artifact to GitHub using the 'actions/upload-artifact' action
26+
description: JUnit output path (must be a directory, doesn't have to exist yet). You can upload the artifact to GitHub using the 'actions/upload-artifact' action
2427
required: false
2528
coverage-output:
26-
description: coverage report output path (must be a directory, doesn't have to exist yet). You can upload the artifacts to GitHub using the 'actions/upload-artifact' action
29+
description: Coverage report output path (must be a directory, doesn't have to exist yet). You can upload the artifacts to GitHub using the 'actions/upload-artifact' action
2730
required: false
2831
fail-on-defects:
29-
description: should we fail the workflow upon detecting a defect?
32+
description: Should we fail the workflow upon detecting a defect?
3033
required: false
3134
default: "false"
3235
verbosity:
33-
description: verbosity level for starting runs
36+
description: Verbosity level for starting runs
3437
required: false
3538
package:
3639
description: Path to the Mayhem package relative to the repository root
3740
required: false
3841
default: "."
3942
args:
40-
description: command line arguments to override CLI behavior
43+
description: Command line arguments to override CLI behavior
4144
required: false
4245
runs:
4346
using: "node16"

dist/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async function run(): Promise<void> {
5656
);
5757
}
5858

59+
const project: string = (core.getInput("project") || repo).toLowerCase();
5960
const eventPath = process.env["GITHUB_EVENT_PATH"] || "event.json";
6061
const event = JSON.parse(readFileSync(eventPath, "utf-8")) || {};
6162
const eventPullRequest = event.pull_request;
@@ -119,7 +120,7 @@ async function run(): Promise<void> {
119120
120121
# Run mayhem
121122
run=$(${cli} --verbosity ${verbosity} run ${packagePath} \
122-
--project ${repo.toLowerCase()} \
123+
--project ${project} \
123124
--owner ${owner} ${argsString});
124125
125126
# Persist the run id to the GitHub output
@@ -143,7 +144,7 @@ async function run(): Promise<void> {
143144
144145
# run name is the last part of the run id
145146
runName="$(echo $run | awk -F / '{ print $(NF-1) }')";
146-
147+
147148
# wait for run to finish
148149
if ! ${cli} --verbosity ${verbosity} wait $run \
149150
--owner ${owner} \

0 commit comments

Comments
 (0)