From 86e68ce8505c1015ffafbd63b14627c103cbdd14 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:33:45 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20More=20configuration=20flag?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 3 +++ README.md | 8 +++++++ action.yml | 12 ++++++---- src/action.ts | 45 +++++++++++++++++++++++++++----------- src/codelimit.ts | 9 +++++++- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed4f157..9dcc6ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,3 +39,6 @@ jobs: - name: 'Run CodeLimit action' uses: getcodelimit/codelimit-action@main + with: + check: false + codelimit-version: 'main' diff --git a/README.md b/README.md index 817c2fe..a374431 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,11 @@ jobs: - name: 'Run CodeLimit' uses: getcodelimit/codelimit-action@v1 ``` + +## Inputs + +| Name | Description | Required | Default | +| --- | --- | --- | --- | +| token | GitHub token for storing results | false | ${{ github.token }} | +| check | Check changed files | false | true | +| codelimit-version | CodeLimit version | false | 'latest' | diff --git a/action.yml b/action.yml index 0fe49a1..69a0645 100644 --- a/action.yml +++ b/action.yml @@ -8,10 +8,14 @@ runs: image: 'Dockerfile' inputs: token: - description: 'GitHub token for repository' - default: ${{ github.token }} + description: 'GitHub token for storing results' required: false + default: ${{ github.token }} check: - description: 'Checked changed files' - default: 'true' + description: 'Check changed files' + required: false + default: true + codelimit-version: + description: 'CodeLimit version' required: false + default: 'latest' \ No newline at end of file diff --git a/src/action.ts b/src/action.ts index f29f9a9..47bdb16 100644 --- a/src/action.ts +++ b/src/action.ts @@ -1,5 +1,5 @@ import fs from "fs"; -import {getInput} from "@actions/core"; +import {getBooleanInput, getInput} from "@actions/core"; import {context} from "@actions/github"; import {Octokit} from "@octokit/action"; import { @@ -14,7 +14,13 @@ import { updateComment } from "./github"; import {exec, getExecOutput} from "@actions/exec"; -import {downloadCodeLimitBinary, getReportContent, makeNotFoundBadgeSvg, makeStatusBadgeSvg} from "./codelimit"; +import { + downloadCodeLimitBinary, + getReportContent, + installCodeLimit, + makeNotFoundBadgeSvg, + makeStatusBadgeSvg +} from "./codelimit"; import {getChangedFiles} from "./utils"; import {version} from "./version"; import signale, {error, info, success} from "signale"; @@ -87,22 +93,12 @@ async function checkChangedFiles(octokit: Octokit, clBinary: string): Promise { const binaryUrl = await getLatestBinaryUrl(); info(`Downloading CodeLimit binary from URL: ${binaryUrl}`); const response = await nodeFetch(binaryUrl); @@ -44,6 +45,12 @@ export async function downloadCodeLimitBinary() { return filename; } +export async function installCodeLimit(): Promise { + await exec('pipx', ['install', 'git+https://github.com/getcodelimit/codelimit.git']); + await exec('pipx', ['list']); + return 'codelimit'; +} + export function getReportContent(): string | undefined { return fs.readFileSync('.codelimit_cache/codelimit.json', 'utf8'); }