Skip to content

Commit

Permalink
feat: add the wotking-directory input parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Jul 20, 2023
1 parent 49e1acc commit c049064
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 17 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@ jobs:
os: ["ubuntu-20.04", "ubuntu-22.04"]
runs-on: ${{ matrix.os }}
needs: check-dist
env:
CODSPEED_SKIP_UPLOAD: true
steps:
- uses: actions/checkout@v3
- uses: ./
- name: Check basic action execution
uses: ./
with:
run: echo "Working!"
env:
CODSPEED_SKIP_UPLOAD: true
- name: Check action in a custom directory
uses: ./
with:
working-directory: examples
# Check that the directory is actually changed
run: if [ $(basename $(pwd)) != "examples" ]; then exit 1; fi

tests:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ GitHub Actions for running [CodSpeed](https://codspeed.io) in your CI.
# The command used to run your codspeed benchmarks
run: ""

# [OPTIONAL]
# The directory where the `run` command will be executed.
# ⚠️ WARNING: if you use `defaults.run.working-directory`, you must still set this parameter.
working-directory: ""

# [OPTIONAL]
# A custom upload url, only if you are using an on premise CodSpeed instance
upload_url: ""
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ inputs:
run:
description: "The command to run the benchmarks"
required: true
working-directory:
description: |
The directory where the `run` command will be executed.
Warning: if you use defaults.working-directory, you must still set this parameter.
required: false
upload_url:
description: "The upload endpoint (for on-premise deployments)"
default: "https://api.codspeed.io/upload"
Expand Down
22 changes: 11 additions & 11 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const getActionInputs = (): ActionInputs => {
return {
uploadUrl: core.getInput("upload_url", {required: true}),
run: core.getInput("run", {required: true}),
workingDirectory:
core.getInput("working-directory", {required: false}) || undefined,
token,
tokenless,
};
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface ActionInputs {
token: string;
uploadUrl: string;
run: string;
workingDirectory: string | undefined;
tokenless: boolean;
}

Expand Down
1 change: 1 addition & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const run = async (inputs: ActionInputs): Promise<{profileFolder: string}> => {
].join(" ");
core.debug(`Running: ${command}`);
const exitCode = await exec(command, [], {
cwd: inputs.workingDirectory,
env: {
...process.env,
// prepend the custom dist/bin folder to the path, to run our custom node script instead of the regular node
Expand Down

0 comments on commit c049064

Please sign in to comment.