From e58cb1b317c861f4eb4f002ed05d771b293d8137 Mon Sep 17 00:00:00 2001 From: Koen van de Sande Date: Thu, 5 Dec 2024 13:43:46 +0100 Subject: [PATCH 1/3] Support excludes --- README.md | 11 +++++++++++ action.yml | 4 ++++ src/action.ts | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bc6e69..f6d247e 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,14 @@ jobs: - name: 'Run Code Limit' uses: getcodelimit/codelimit-action@v1 ``` + +## Adding exclude paths + +```yaml + - name: 'Run Code Limit' + uses: getcodelimit/codelimit-action@v1 + with: + excludes: + - examples + - third_party +``` diff --git a/action.yml b/action.yml index 6bad401..ef7e9cb 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/src/action.ts b/src/action.ts index b80193b..bdc8187 100644 --- a/src/action.ts +++ b/src/action.ts @@ -82,7 +82,11 @@ async function main() { let exitCode = 0; const clBinary = await downloadCodeLimitBinary(); console.log('Scanning codebase...'); - await exec(clBinary, ['scan', '.']); + const excludeOpts = getInput('excludes').reduce(function(r, e) { + r.push('--exclude', e); + return r; + }, []); + await exec(clBinary, [...excludeOpts, 'scan', '.']); const markdownReport = await generateMarkdownReport(clBinary); const octokit = new Octokit({auth: getInput('token')}); await updateReportsBranch(octokit, markdownReport); From 181031f203dfbe63a6fd0e2e18dea3ee22645ac2 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:15:14 +0100 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=F0=9F=9A=A7=20Make=20TS=20happy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- dist/index.js | 4 +++- src/action.ts | 8 +++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f6d247e..e7c075e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ jobs: - name: 'Run Code Limit' uses: getcodelimit/codelimit-action@v1 with: - excludes: - - examples - - third_party + excludes: + - examples/* + - third_party/* ``` diff --git a/dist/index.js b/dist/index.js index 138dce1..0875710 100644 --- a/dist/index.js +++ b/dist/index.js @@ -49097,7 +49097,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") }); yield updateReportsBranch(octokit, markdownReport); diff --git a/src/action.ts b/src/action.ts index bdc8187..9598918 100644 --- a/src/action.ts +++ b/src/action.ts @@ -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 { @@ -82,10 +82,8 @@ async function main() { let exitCode = 0; const clBinary = await downloadCodeLimitBinary(); console.log('Scanning codebase...'); - const excludeOpts = getInput('excludes').reduce(function(r, e) { - r.push('--exclude', e); - return r; - }, []); + 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')}); From 360a8f779a6a989592b37a0e822d2000c0fa678c Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:54:24 +0100 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Update=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e7c075e..f0f592a 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,17 @@ jobs: uses: getcodelimit/codelimit-action@v1 ``` -## Adding exclude paths +## 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/* + - examples + - third_party ```