Skip to content

Commit

Permalink
Support override of Mayhem project name (#159)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
swarkentin authored Oct 3, 2023
1 parent 148de75 commit 36ef87d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: sarif
- name: Archive Coverage report
uses: actions/upload-artifact@v3
with:
Expand All @@ -143,7 +143,7 @@ jobs:
with:
name: mcode-junit
path: junit
- name: Upload SARIF file(s)
uses: github/codeql-action/upload-sarif@v2
with:
Expand All @@ -160,6 +160,8 @@ The mCode Action accepts the following inputs:
| | `sarif-output` | string | Path for generating a SARIF report output file. |
| | `junit-output` | string | Path for generating a jUnit report output file. |
| | `coverage-output` | string | Path for generating a coverage report output files. |
| | `owner` | string | The workspace for the run. |
| | `project` | string | The name of the project | Defaults to the name of your repository if not defined. |

The mCode Action provides the following outputs:
| Output Name | Type | Description | Default
Expand Down
19 changes: 11 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Mayhem for Code"
description: "Automatically test your Rust targets with Mayhem"
description: "Automatically test your binary targets with Mayhem"
author: "ForAllSecure"
inputs:
mayhem-token:
Expand All @@ -9,35 +9,38 @@ inputs:
description: URL pointing to your Mayhem instance
required: false
owner:
description: sets the owner of the project (organization or user).
description: Sets the owner of the project (workspace or account name).
required: false
default: ${{ github.repository_owner }}
project:
description: Sets the name of the project. Defaults to the name of your repository if not defined.
required: false
github-token:
description: github token for posting feedback
description: GitHub token for posting feedback
required: false
default: ${{ github.token }}
sarif-output:
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
required: false
junit-output:
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
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
required: false
coverage-output:
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
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
required: false
fail-on-defects:
description: should we fail the workflow upon detecting a defect?
description: Should we fail the workflow upon detecting a defect?
required: false
default: "false"
verbosity:
description: verbosity level for starting runs
description: Verbosity level for starting runs
required: false
package:
description: Path to the Mayhem package relative to the repository root
required: false
default: "."
args:
description: command line arguments to override CLI behavior
description: Command line arguments to override CLI behavior
required: false
runs:
using: "node16"
Expand Down
5 changes: 3 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function run(): Promise<void> {
);
}

const project: string = (core.getInput("project") || repo).toLowerCase();
const eventPath = process.env["GITHUB_EVENT_PATH"] || "event.json";
const event = JSON.parse(readFileSync(eventPath, "utf-8")) || {};
const eventPullRequest = event.pull_request;
Expand Down Expand Up @@ -119,7 +120,7 @@ async function run(): Promise<void> {
# Run mayhem
run=$(${cli} --verbosity ${verbosity} run ${packagePath} \
--project ${repo.toLowerCase()} \
--project ${project} \
--owner ${owner} ${argsString});
# Persist the run id to the GitHub output
Expand All @@ -143,7 +144,7 @@ async function run(): Promise<void> {
# run name is the last part of the run id
runName="$(echo $run | awk -F / '{ print $(NF-1) }')";
# wait for run to finish
if ! ${cli} --verbosity ${verbosity} wait $run \
--owner ${owner} \
Expand Down

0 comments on commit 36ef87d

Please sign in to comment.