Skip to content

Commit

Permalink
Support excludes (#3)
Browse files Browse the repository at this point in the history
* Support excludes

* chore: 🚧 Make TS happy

* docs: πŸ“ Update doc

---------

Co-authored-by: Rob van der Leek <[email protected]>
  • Loading branch information
koenvandesande and robvanderleek authored Dec 7, 2024
1 parent 98e35fa commit 7ef84ca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@ jobs:
- name: 'Run Code Limit'
uses: getcodelimit/codelimit-action@v1
```
## Excluding files
Use the input parameter `excludes` to exclude files and directories, this
action parameter takes a list of
[patterns](https://git-scm.com/docs/gitignore#_pattern_format).

```yaml
- name: 'Run Code Limit'
uses: getcodelimit/codelimit-action@v1
with:
excludes:
- examples
- third_party
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ inputs:
description: 'Checked changed files'
default: 'true'
required: false
excludes:
description: 'Extra exclude patterns to pass to Code Limit'
default: []
required: false
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49118,7 +49118,9 @@ function main() {
let exitCode = 0;
const clBinary = yield (0, codelimit_1.downloadCodeLimitBinary)();
console.log("Scanning codebase...");
yield (0, exec_1.exec)(clBinary, ["scan", "."]);
const excludes = (0, core_1.getMultilineInput)("excludes");
const excludeOpts = excludes.flatMap((e) => ["--exclude", e]);
yield (0, exec_1.exec)(clBinary, [...excludeOpts, "scan", "."]);
const markdownReport = yield generateMarkdownReport(clBinary);
const octokit = new action_1.Octokit({ auth: (0, core_1.getInput)("token") });
const doCheck = (0, core_1.getInput)("check") || true;
Expand Down
6 changes: 4 additions & 2 deletions src/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs";
import {getInput} from "@actions/core";
import {getInput, getMultilineInput} from "@actions/core";
import {context} from "@actions/github";
import {Octokit} from "@octokit/action";
import {
Expand Down Expand Up @@ -85,7 +85,9 @@ async function main() {
let exitCode = 0;
const clBinary = await downloadCodeLimitBinary();
console.log('Scanning codebase...');
await exec(clBinary, ['scan', '.']);
const excludes = getMultilineInput('excludes');
const excludeOpts = excludes.flatMap(e => ['--exclude', e]);
await exec(clBinary, [...excludeOpts, 'scan', '.']);
const markdownReport = await generateMarkdownReport(clBinary);
const octokit = new Octokit({auth: getInput('token')});
const doCheck = getInput('check') || true;
Expand Down

0 comments on commit 7ef84ca

Please sign in to comment.