Skip to content

Commit

Permalink
[Feature] Add branch option (#19)
Browse files Browse the repository at this point in the history
* 🌳 Add --branch option

* 📖 Document new option

* 🔧 Build the app

* 🌲 Include branch in action.yml

* 📖 Update README

* ☝️ Use Node 16, bump packages

* 📕 Add descriptions to inputs, bump Node in test.yml

* 👷‍♀️ Build dist

Also removes old dist files which were tracked

* 🐘 Minify output

No reason for this to not be minified

* 🔧 Don't interpolate `github` as a var in config

* 🔧 Fix a bad import

* 👨‍🔬 Test passing the branch option

* 1️⃣ Only run CI tests once

* 🔧 Fix workflow syntax

* 🔧 Fix it fix it fix it fix it fix it fix it

fix it fix it fix it fix it fix it fix it
fix it fix it fix it fix it fix it fix it

* 🔧 Try fixing the workflow again

* ↕️ Reorder workflow

Run the test ones last, they take awhile
  • Loading branch information
himynameisdave authored Apr 13, 2022
1 parent 88bec1f commit 942c3da
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 5,592 deletions.
17 changes: 9 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
module.exports = {
'root': true,
'parser': '@typescript-eslint/parser',
'parserOptions': {
'project': './tsconfig.json',
'sourceType': 'module',
},
"ignorePatterns": ["dist/", ".eslintrc.js"],
'settings': {
'import/resolver': {
'node': {
'extensions': ['.ts', '.d.ts', '.js', '.json'],
},
},
},
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -23,7 +32,6 @@ module.exports = {
'node': true,
'mocha': true,
},
'root': true,
"globals": {
"GLOBAL": true,
},
Expand Down Expand Up @@ -131,11 +139,4 @@ module.exports = {
'@typescript-eslint/no-use-before-define': ["error", {"variables": false, "typedefs": false, "functions": false, "classes": false }],
'no-use-before-define': ["error", {"variables": true, "functions": false, "classes": false }],
},
'settings': {
'import/resolver': {
'node': {
'extensions': ['.ts', '.d.ts', '.js', '.json'],
},
},
},
};
32 changes: 22 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: 'FOSSA Action'

# Ensures that this is only run once, either when pushing
# directly to main OR when pushing to a PR against main.
on:
- pull_request
- push
pull_request:
branches:
- main
push:
branches:
- main

jobs:
fossa-scan:
Expand All @@ -11,12 +17,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Use Node.js 12.x
uses: actions/setup-node@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x

- name: Install npm packages
run: yarn --frozen-lockfile
Expand All @@ -29,19 +35,25 @@ jobs:
with:
api-key: ${{secrets.fossaApiKey}}

- name: Run FOSSA test
- name: Run FOSSA container scan and upload build data
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
run-tests: true
container: alpine:latest

- name: Run FOSSA container scan and upload build data
- name: Run FOSSA scan with branch
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
container: alpine:latest
branch: develop

- name: Run FOSSA test
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
run-tests: true

- name: Run FOSSA test with container
uses: ./
with:
api-key: ${{secrets.fossaApiKey}}
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.14.2
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
Expand All @@ -45,7 +45,7 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
Expand All @@ -62,14 +62,32 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
container: ubuntu:20.04
```

### `branch`

**Optional** Branch 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}}
branch: some-feature-branch
```

### `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).

Example
Expand All @@ -78,7 +96,7 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
Expand All @@ -96,7 +114,7 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
with:
api-key: ${{secrets.fossaApiKey}}
Expand All @@ -111,7 +129,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout Code"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Run FOSSA Scan"
uses: fossas/fossa-action@main # Use a specific version if locking is preferred
Expand All @@ -134,7 +152,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout Code"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Run FOSSA Scan"
uses: fossas/fossa-action@main # Use a specific version if locking is preferred
Expand Down
15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ author: Solomon Rubin

inputs:
api-key:
description: >-
Your FOSSA API key.
required: true
run-tests:
description: >-
If set to `true` FOSSA will run the `fossa test` command.
default: false
container:
description: >-
A container name or OCI image path. Set to use FOSSA's container scanning functionality. This will run `fossa container analyze` (default behavior) and `fossa container test` (if used in combination with `run-tests`).
required: false
endpoint:
description: >-
Endpoint passed to FOSSA CLI. Defaults to `app.fossa.com`.
required: false
branch:
description: >-
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

runs:
using: node12
using: node16
main: dist/index.js

branding:
Expand Down
9 changes: 9 additions & 0 deletions dist/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

@actions/exec
MIT
The MIT License (MIT)

Copyright 2019 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@actions/http-client
MIT
Expand Down
8 changes: 0 additions & 8 deletions dist/config.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/config.js.map

This file was deleted.

73 changes: 0 additions & 73 deletions dist/download-cli.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/download-cli.js.map

This file was deleted.

Loading

0 comments on commit 942c3da

Please sign in to comment.