Skip to content

Commit

Permalink
Godeepakm/add project flag (#31)
Browse files Browse the repository at this point in the history
* add prpject flag

* add prpject flagcd

* Build app

* Add test for scanning with a --project option.

* Run fossa test correctly. Oops.

---------

Co-authored-by: root <[email protected]>
Co-authored-by: Chelsea Boling <[email protected]>
Co-authored-by: Christopher Sasarak <[email protected]>
  • Loading branch information
4 people authored Feb 15, 2024
1 parent 32c7979 commit 47ef11b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ jobs:
with:
api-key: ${{secrets.fossaApiKey}}
branch: develop
project: custom-test-project

- name: Run FOSSA test with a --project and --branch
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
branch: develop
project: custom-test-project

- name: Run FOSSA test
uses: ./
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ jobs:
branch: some-feature-branch
```

### `project`

**Optional** Project flag passed to FOSSA CLI.

Example
```yml
jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
project: some-project-name
```

### `endpoint`

**Optional** Endpoint passed to FOSSA CLI. Defaults to `app.fossa.com`. [Read more](https://github.com/fossas/spectrometer/blob/master/docs/userguide.md#common-fossa-project-flags).
Expand Down Expand Up @@ -144,7 +161,7 @@ jobs:
```

### Running tests
This run `fossa tests` after doing an initial scan.
This runs `fossa tests` after doing an initial scan.

```yml
jobs:
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ inputs:
Override the detected FOSSA project branch. If running FOSSA analysis on a
Pull Request, as a start you can use the contexts `github.ref` or `github.ref_name`.
required: false
project:
description: >-
Override the detected FOSSA project name. If running FOSSA analysis on a
Pull Request, as a start you can use the contexts `github.ref` or `github.ref_name`.
required: false
debug:
description: >-
Run all FOSSA commands in debug mode. Running `fossa analyze` in debug
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const CONTAINER = getInput('container', getInputOptions());
export const RUN_TESTS = getBooleanInput('run-tests', {required: false});
export const ENDPOINT = getInput('endpoint', getInputOptions());
export const BRANCH = getInput('branch', getInputOptions());
export const PROJECT = getInput('project', getInputOptions());
export const DEBUG = getBooleanInput('debug', {required: false});
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RUN_TESTS,
ENDPOINT,
BRANCH,
PROJECT,
DEBUG,
} from './config';
import { fetchFossaCli } from './download-cli';
Expand All @@ -21,12 +22,17 @@ export async function analyze(): Promise<void> {
'--branch',
BRANCH,
];
const getProjectArgs = (): string[] => !PROJECT ? [] : [
'--project',
PROJECT,
];

const getArgs = (cmd: string) => [
CONTAINER ? 'container' : null,
cmd,
...getEndpointArgs(),
...getBranchArgs(),
...getProjectArgs(),
DEBUG ? '--debug' : null,
].filter(arg => arg);

Expand Down

0 comments on commit 47ef11b

Please sign in to comment.