mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-08-08 02:07:02 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a5185046 | ||
|
|
7a82f1f7e4 | ||
|
|
cac2f108b2 | ||
|
|
35619fdbcc | ||
|
|
c9185454fa | ||
|
|
a2d5d1ffa4 | ||
|
|
ec9ad4417f | ||
|
|
efef6ba8fa | ||
|
|
e5ab5d43a6 |
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "ruff-check",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^Error: (.*):(\\d+):(\\d+): (\\w+) (.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"code": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "ruff-format",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(Would reformat):\\s*(.+)$",
|
||||
"message": 1,
|
||||
"file": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -28,17 +28,18 @@ jobs:
|
||||
- name: Make sure no changes from linters are detected
|
||||
run: |
|
||||
git diff --exit-code
|
||||
test-default-version:
|
||||
test-latest-version:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version
|
||||
- name: Use latest version
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/python-project
|
||||
version: latest
|
||||
test-specific-version:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
@@ -51,6 +52,39 @@ jobs:
|
||||
with:
|
||||
version: ${{ matrix.ruff-version }}
|
||||
src: __tests__/fixtures/python-project
|
||||
test-default-version-from-pyproject:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from pyproject.toml
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/python-project
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$RUFF_VERSION" != "0.6.2" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
test-default-version-from-pyproject-dev-group:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from pyproject.toml dev group
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/pyproject-dependency-dev-project
|
||||
version-file: __tests__/fixtures/pyproject-dependency-dev-project/pyproject.toml
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$RUFF_VERSION" != "0.8.3" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
test-semver-range:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -114,8 +148,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use args
|
||||
id: should-fail
|
||||
- name: Format should fail
|
||||
id: format-should-fail
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
@@ -123,7 +157,18 @@ jobs:
|
||||
src: __tests__/fixtures/malformed-python-project
|
||||
- name: Check if the action failed
|
||||
run: |
|
||||
if [ ${{ steps.should-fail.outcome }} == "success" ]; then
|
||||
if [ ${{ steps.format-should-fail.outcome }} == "success" ]; then
|
||||
exit 1
|
||||
fi
|
||||
- name: Check should fail
|
||||
id: check-should-fail
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/malformed-python-project
|
||||
- name: Check if the action failed
|
||||
run: |
|
||||
if [ ${{ steps.check-should-fail.outcome }} == "success" ]; then
|
||||
exit 1
|
||||
fi
|
||||
test-multiple-src:
|
||||
|
||||
@@ -19,19 +19,21 @@ fix).
|
||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||
- [Install a specific version](#install-a-specific-version)
|
||||
- [Install a version by supplying a semver range](#install-a-version-by-supplying-a-semver-range)
|
||||
- [Install a version from a specified version file](#install-a-version-from-a-specified-version-file)
|
||||
- [Validate checksum](#validate-checksum)
|
||||
- [GitHub authentication token](#github-authentication-token)
|
||||
- [Outputs](#outputs)
|
||||
|
||||
## Usage
|
||||
|
||||
| Input | Description | Default |
|
||||
|----------------|---------------------------------------------------------------------------------------------|--------------------|
|
||||
| `version` | The version of Ruff to install. See [Install specific versions](#install-specific-versions) | `latest` |
|
||||
| `args` | The arguments to pass to the `ruff` command. See [Configuring Ruff] | `check` |
|
||||
| `src` | The directory or single files to run `ruff` on. | [github.workspace] |
|
||||
| `checksum` | The sha256 checksum of the downloaded executable. | None |
|
||||
| `github-token` | The GitHub token to use for authentication. | `GITHUB_TOKEN` |
|
||||
| Input | Description | Default |
|
||||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
|
||||
| `version` | The version of Ruff to install. See [Install specific versions](#install-specific-versions) | `latest` |
|
||||
| `version-file` | The file to read the version from. See [Install a version from a specified version file](#install-a-version-from-a-specified-version-file) | None |
|
||||
| `args` | The arguments to pass to the `ruff` command. See [Configuring Ruff] | `check` |
|
||||
| `src` | The directory or single files to run `ruff` on. | [github.workspace] |
|
||||
| `checksum` | The sha256 checksum of the downloaded executable. | None |
|
||||
| `github-token` | The GitHub token to use for authentication. | `GITHUB_TOKEN` |
|
||||
|
||||
### Basic
|
||||
|
||||
@@ -42,7 +44,7 @@ fix).
|
||||
### Specify a different source directory
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v2
|
||||
with:
|
||||
src: "./src"
|
||||
```
|
||||
@@ -50,7 +52,7 @@ fix).
|
||||
### Specify multiple files
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v2
|
||||
with:
|
||||
src: >-
|
||||
path/to/file1.py
|
||||
@@ -62,7 +64,7 @@ fix).
|
||||
This action adds ruff to the PATH, so you can use it in subsequent steps.
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v2
|
||||
- run: ruff check --fix
|
||||
- run: ruff format
|
||||
```
|
||||
@@ -70,14 +72,18 @@ This action adds ruff to the PATH, so you can use it in subsequent steps.
|
||||
### Use `ruff format`
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v2
|
||||
with:
|
||||
args: "format --check"
|
||||
```
|
||||
|
||||
### Install specific versions
|
||||
|
||||
#### Install the latest version (default)
|
||||
By default this action looks for a pyproject.toml file in the root of the repository to determine
|
||||
the ruff version to install. If no pyproject.toml file is found, or no ruff version is defined in
|
||||
either `dependencies` or `dependency-groups.dev` the latest version is installed.
|
||||
|
||||
#### Install the latest version
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of ruff
|
||||
@@ -86,13 +92,7 @@ This action adds ruff to the PATH, so you can use it in subsequent steps.
|
||||
version: "latest"
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> Using `latest` requires to download the ruff executable on every run, which incurs a cost
|
||||
> (especially on self-hosted runners). As a best practice, consider pinning the version to a
|
||||
> specific release.
|
||||
|
||||
### Install a specific version
|
||||
#### Install a specific version
|
||||
|
||||
```yaml
|
||||
- name: Install a specific version of ruff
|
||||
@@ -101,7 +101,7 @@ This action adds ruff to the PATH, so you can use it in subsequent steps.
|
||||
version: "0.4.4"
|
||||
```
|
||||
|
||||
### Install a version by supplying a semver range
|
||||
#### Install a version by supplying a semver range
|
||||
|
||||
You can specify a [semver range](https://github.com/npm/node-semver?tab=readme-ov-file#ranges)
|
||||
to install the latest version that satisfies the range.
|
||||
@@ -120,6 +120,18 @@ to install the latest version that satisfies the range.
|
||||
version: "0.4.x"
|
||||
```
|
||||
|
||||
#### Install a version from a specified version file
|
||||
|
||||
You can specify a file to read the version from.
|
||||
Currently `pyproject.toml` is supported.
|
||||
|
||||
```yaml
|
||||
- name: Install a version from a specified version file
|
||||
uses: astral-sh/ruff-action@v2
|
||||
with:
|
||||
version-file: "my-path/to/pyproject.toml"
|
||||
```
|
||||
|
||||
### Validate checksum
|
||||
|
||||
You can specify a checksum to validate the downloaded executable. Checksums up to the default version
|
||||
|
||||
+2
@@ -1,2 +1,4 @@
|
||||
import sys
|
||||
|
||||
print("Hello world!")
|
||||
print('How are you?')
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[project]
|
||||
name = "pyproject-dependency-dev-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"ruff==0.8.3"
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def hello() -> str:
|
||||
return "Hello from python-project!"
|
||||
+1
@@ -0,0 +1 @@
|
||||
print("Hello world!")
|
||||
@@ -5,7 +5,7 @@ description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"ruff>=0.6.2",
|
||||
"ruff==0.6.2",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
|
||||
+5
-2
@@ -11,9 +11,12 @@ inputs:
|
||||
required: false
|
||||
default: ${{ github.workspace }}
|
||||
version:
|
||||
description: "The version of Ruff to use, e.g., `0.6.0` Defaults to the latest version."
|
||||
description: "The version of Ruff to use, e.g., `0.6.0` Defaults to the version in pyproject.toml or 'latest'."
|
||||
required: false
|
||||
default: ""
|
||||
version-file:
|
||||
description: "Path to a pyproject.toml or requirements.txt file to read the version from."
|
||||
required: false
|
||||
default: "latest"
|
||||
checksum:
|
||||
description: "The checksum of the ruff version to install"
|
||||
required: false
|
||||
|
||||
+2279
-9
File diff suppressed because it is too large
Load Diff
Generated
+17
-10
@@ -12,11 +12,12 @@
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@iarna/toml": "^2.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
@@ -241,6 +242,11 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@iarna/toml": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
|
||||
@@ -386,12 +392,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.9.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.3.tgz",
|
||||
"integrity": "sha512-F3u1fs/fce3FFk+DAxbxc78DF8x0cY09RRL8GnXLmkJ1jvx3TtPdWoTT5/NiYfI5ASqXBmfqJi9dZ3gxMx4lzw==",
|
||||
"version": "22.10.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
|
||||
"integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~6.19.8"
|
||||
"undici-types": "~6.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
@@ -486,10 +492,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.19.8",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
||||
"dev": true
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/universal-user-agent": {
|
||||
"version": "6.0.1",
|
||||
|
||||
+3
-2
@@ -25,11 +25,12 @@
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@iarna/toml": "^2.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
||||
@@ -29,13 +29,12 @@ export async function downloadVersion(
|
||||
checkSum: string | undefined,
|
||||
githubToken: string,
|
||||
): Promise<{ version: string; cachedToolDir: string }> {
|
||||
const resolvedVersion = await resolveVersion(version, githubToken);
|
||||
const artifact = `ruff-${arch}-${platform}`;
|
||||
let extension = ".tar.gz";
|
||||
if (platform === "pc-windows-msvc") {
|
||||
extension = ".zip";
|
||||
}
|
||||
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
|
||||
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}${extension}`;
|
||||
core.info(`Downloading ruff from "${downloadUrl}" ...`);
|
||||
|
||||
const downloadPath = await tc.downloadTool(
|
||||
@@ -43,13 +42,7 @@ export async function downloadVersion(
|
||||
undefined,
|
||||
githubToken,
|
||||
);
|
||||
await validateChecksum(
|
||||
checkSum,
|
||||
downloadPath,
|
||||
arch,
|
||||
platform,
|
||||
resolvedVersion,
|
||||
);
|
||||
await validateChecksum(checkSum, downloadPath, arch, platform, version);
|
||||
|
||||
let ruffDir: string;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
@@ -64,10 +57,10 @@ export async function downloadVersion(
|
||||
const cachedToolDir = await tc.cacheDir(
|
||||
ruffDir,
|
||||
TOOL_CACHE_NAME,
|
||||
resolvedVersion,
|
||||
version,
|
||||
arch,
|
||||
);
|
||||
return { version: resolvedVersion, cachedToolDir };
|
||||
return { version: version, cachedToolDir };
|
||||
}
|
||||
|
||||
export async function resolveVersion(
|
||||
|
||||
+54
-10
@@ -13,7 +13,16 @@ import {
|
||||
getPlatform,
|
||||
type Platform,
|
||||
} from "./utils/platforms";
|
||||
import { args, checkSum, githubToken, src, version } from "./utils/inputs";
|
||||
import {
|
||||
args,
|
||||
checkSum,
|
||||
githubToken,
|
||||
src,
|
||||
version,
|
||||
versionFile as versionFileInput,
|
||||
} from "./utils/inputs";
|
||||
import { getRuffVersionFromPyproject } from "./utils/pyproject";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const platform = getPlatform();
|
||||
@@ -26,15 +35,11 @@ async function run(): Promise<void> {
|
||||
if (arch === undefined) {
|
||||
throw new Error(`Unsupported architecture: ${process.arch}`);
|
||||
}
|
||||
const setupResult = await setupRuff(
|
||||
platform,
|
||||
arch,
|
||||
version,
|
||||
checkSum,
|
||||
githubToken,
|
||||
);
|
||||
const setupResult = await setupRuff(platform, arch, checkSum, githubToken);
|
||||
|
||||
addRuffToPath(setupResult.ruffDir);
|
||||
setOutputFormat();
|
||||
addMatchers();
|
||||
core.setOutput("ruff-version", setupResult.version);
|
||||
core.info(`Successfully installed ruff version ${setupResult.version}`);
|
||||
|
||||
@@ -53,11 +58,10 @@ async function run(): Promise<void> {
|
||||
async function setupRuff(
|
||||
platform: Platform,
|
||||
arch: Architecture,
|
||||
versionInput: string,
|
||||
checkSum: string | undefined,
|
||||
githubToken: string,
|
||||
): Promise<{ ruffDir: string; version: string }> {
|
||||
const resolvedVersion = await resolveVersion(versionInput, githubToken);
|
||||
const resolvedVersion = await determineVersion();
|
||||
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
|
||||
if (toolCacheResult.installedPath) {
|
||||
core.info(`Found ruffDir in tool-cache for ${toolCacheResult.version}`);
|
||||
@@ -81,11 +85,51 @@ async function setupRuff(
|
||||
};
|
||||
}
|
||||
|
||||
async function determineVersion(): Promise<string> {
|
||||
if (versionFileInput !== "" && version !== "") {
|
||||
throw Error("It is not allowed to specify both version and version-file");
|
||||
}
|
||||
if (version !== "") {
|
||||
return await resolveVersion(version, githubToken);
|
||||
}
|
||||
if (versionFileInput !== "") {
|
||||
const versionFromPyproject = getRuffVersionFromPyproject(versionFileInput);
|
||||
if (versionFromPyproject === undefined) {
|
||||
core.warning(
|
||||
"Could not parse version from supplied pyproject.toml. Using latest version.",
|
||||
);
|
||||
return await resolveVersion("latest", githubToken);
|
||||
}
|
||||
}
|
||||
const pyProjectPath = path.join(src, "pyproject.toml");
|
||||
if (!fs.existsSync(pyProjectPath)) {
|
||||
return await resolveVersion("latest", githubToken);
|
||||
}
|
||||
const versionFromPyproject = getRuffVersionFromPyproject(pyProjectPath);
|
||||
return await resolveVersion(versionFromPyproject || "latest", githubToken);
|
||||
}
|
||||
|
||||
function addRuffToPath(cachedPath: string): void {
|
||||
core.addPath(cachedPath);
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
|
||||
function setOutputFormat() {
|
||||
core.exportVariable("RUFF_OUTPUT_FORMAT", "github");
|
||||
core.info("Set RUFF_OUTPUT_FORMAT to github");
|
||||
}
|
||||
|
||||
function addMatchers(): void {
|
||||
const matchersPath = path.join(
|
||||
__dirname,
|
||||
`..${path.sep}..`,
|
||||
".github",
|
||||
"matchers",
|
||||
);
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, "check.json")}`);
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, "format.json")}`);
|
||||
}
|
||||
|
||||
async function runRuff(
|
||||
ruffExecutablePath: string,
|
||||
args: string[],
|
||||
|
||||
@@ -5,3 +5,4 @@ export const checkSum = core.getInput("checksum");
|
||||
export const githubToken = core.getInput("github-token");
|
||||
export const args = core.getInput("args");
|
||||
export const src = core.getInput("src");
|
||||
export const versionFile = core.getInput("version-file");
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as core from "@actions/core";
|
||||
import * as toml from "@iarna/toml";
|
||||
|
||||
export function getRuffVersionFromPyproject(
|
||||
filePath: string,
|
||||
): string | undefined {
|
||||
const pyprojectContent = fs.readFileSync(filePath, "utf-8");
|
||||
const pyproject = toml.parse(pyprojectContent) as {
|
||||
project?: { dependencies?: string[] };
|
||||
"dependency-groups"?: { dev?: string[] };
|
||||
};
|
||||
|
||||
const dependencies: string[] = pyproject?.project?.dependencies || [];
|
||||
const devDependencies: string[] = pyproject?.["dependency-groups"]?.dev || [];
|
||||
|
||||
const ruffVersionDefinition =
|
||||
dependencies.find((dep: string) => dep.startsWith("ruff")) ||
|
||||
devDependencies.find((dep: string) => dep.startsWith("ruff"));
|
||||
|
||||
if (ruffVersionDefinition) {
|
||||
const ruffVersion = ruffVersionDefinition
|
||||
.match(/^ruff([^A-Z0-9._-]+.*)$/)?.[1]
|
||||
.trim();
|
||||
if (ruffVersion?.startsWith("==")) {
|
||||
return ruffVersion.slice(2);
|
||||
}
|
||||
core.info(`Found ruff version in pyproject.toml: ${ruffVersion}`);
|
||||
return ruffVersion;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user