mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-12-06 09:51:01 +00:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3099ca9c7 | ||
|
|
665801e39d | ||
|
|
5226eeb6a9 | ||
|
|
ea181cb604 | ||
|
|
107126dd4d | ||
|
|
280e92ea43 | ||
|
|
be1f93951f | ||
|
|
747ffb9220 | ||
|
|
70c5336f5b | ||
|
|
22ba4f8560 | ||
|
|
f2f46687ac | ||
|
|
a737711ea8 | ||
|
|
4307b3970e | ||
|
|
8fc297008d | ||
|
|
6776b96909 | ||
|
|
cc56f639e4 | ||
|
|
3906fcf994 | ||
|
|
c890b57484 | ||
|
|
6f8f9a9d5f | ||
|
|
127e6a115e | ||
|
|
6d5deb5cee | ||
|
|
46b5b9699e | ||
|
|
848ccd1cb2 | ||
|
|
1f30a84c67 |
@@ -1,2 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
dist/** -diff linguist-generated=true
|
||||
src/download/checksum/known-checksums.json linguist-generated=true
|
||||
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
source-root: src
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
uses: github/codeql-action/autobuild@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -71,4 +71,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: 🚀 Run Release Drafter
|
||||
uses: release-drafter/release-drafter@c2e2804cc59f45f57076a99af580d0fedb697927 # v7.3.0
|
||||
uses: release-drafter/release-drafter@eada3c96a64734dd381cfbda23511034e328ddb0 # v7.6.0
|
||||
with:
|
||||
commitish: ${{ github.sha }}
|
||||
env:
|
||||
|
||||
@@ -24,13 +24,15 @@ jobs:
|
||||
- name: Actionlint
|
||||
uses: eifinger/actionlint-action@1fc89649be682d16ec5cf65ea16e269eb88d3982 # v1.10.2
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: zizmorcore/zizmor-action@6599ee8b7a49aef6a770f63d261d214911a7ce02 # v0.6.0
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
- run: |
|
||||
npm ci --ignore-scripts
|
||||
- name: Verify npm package signatures
|
||||
run: npm audit signatures
|
||||
- run: |
|
||||
npm run all
|
||||
- name: Check all jobs are in all-tests-passed.needs
|
||||
@@ -45,7 +47,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
|
||||
os: [ubuntu-latest, macos-latest, macos-15, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
@@ -60,7 +62,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
ruff-version: ["0.1.7", "0.1.8", "0.4.7", "0.4.10", "0.7", "0.7.x", ">=0.7.0"]
|
||||
os: [ ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-14, windows-latest ]
|
||||
os: [ ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15, windows-latest ]
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
@@ -22,8 +22,11 @@ jobs:
|
||||
id: update-known-checksums
|
||||
run:
|
||||
node dist/update-known-checksums/index.cjs
|
||||
src/download/checksum/known-checksums.ts ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: npm ci --ignore-scripts && npm run all
|
||||
src/download/checksum/known-checksums.json ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
npm ci --ignore-scripts
|
||||
npm audit signatures
|
||||
npm run all
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, jest, test } from "@jest/globals";
|
||||
|
||||
const mockDownloadTool = jest.fn<() => Promise<string>>();
|
||||
|
||||
jest.unstable_mockModule("@actions/tool-cache", () => ({
|
||||
downloadTool: mockDownloadTool,
|
||||
}));
|
||||
|
||||
const { updateChecksums } = await import(
|
||||
"../../../src/download/checksum/update-known-checksums"
|
||||
);
|
||||
|
||||
test("serializes checksum entries as JSON data", async () => {
|
||||
const tempDirectory = await fs.mkdtemp(
|
||||
path.join(os.tmpdir(), "ruff-action-checksums-test-"),
|
||||
);
|
||||
const checksumPath = path.join(tempDirectory, "checksum");
|
||||
const outputPath = path.join(tempDirectory, "known-checksums.json");
|
||||
const checksum = 'checksum"\\value';
|
||||
const platform = 'platform"\n};\ncompromised = true;';
|
||||
const downloadUrl = `https://example.com/v1.0.0/ruff-1.0.0-${platform}.tar.gz.sha256`;
|
||||
|
||||
try {
|
||||
await fs.writeFile(checksumPath, `${checksum} ruff.tar.gz`);
|
||||
mockDownloadTool.mockResolvedValue(checksumPath);
|
||||
|
||||
await updateChecksums(outputPath, [downloadUrl]);
|
||||
|
||||
const content = await fs.readFile(outputPath, "utf8");
|
||||
expect(JSON.parse(content)).toEqual({ [`${platform}-1.0.0`]: checksum });
|
||||
expect(content.endsWith("\n")).toBe(true);
|
||||
} finally {
|
||||
await fs.rm(tempDirectory, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as path from "node:path";
|
||||
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||
import * as semver from "semver";
|
||||
|
||||
@@ -450,7 +451,7 @@ describe("download-version", () => {
|
||||
|
||||
expect(mockExtractTar).toHaveBeenCalledWith("/tmp/downloaded");
|
||||
expect(mockCacheDir).toHaveBeenCalledWith(
|
||||
"/tmp/extracted/ruff-x86_64-unknown-linux-gnu",
|
||||
path.join("/tmp/extracted", "ruff-x86_64-unknown-linux-gnu"),
|
||||
"ruff",
|
||||
"0.15.8",
|
||||
"x86_64",
|
||||
|
||||
@@ -17,6 +17,7 @@ const {
|
||||
const { findPyprojectToml } = await import("../../src/utils/pyproject-finder");
|
||||
|
||||
let tempDir: string | undefined;
|
||||
const symlinkTest = process.platform === "win32" ? it.skip : it;
|
||||
|
||||
afterEach(async () => {
|
||||
if (tempDir !== undefined) {
|
||||
@@ -177,7 +178,7 @@ describe("expandSourceInput", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not traverse symlinked directories", async () => {
|
||||
symlinkTest("does not traverse symlinked directories", async () => {
|
||||
const projectDir = await createTempProject();
|
||||
const externalDir = path.join(projectDir, "external");
|
||||
const symlinkPath = path.join(projectDir, "src", "linked");
|
||||
@@ -368,7 +369,7 @@ describe("getSourceBasePath", () => {
|
||||
|
||||
it("does not treat brace expansion as glob syntax", async () => {
|
||||
await expect(getSourceBasePath("src/{a,b}/*.py")).resolves.toBe(
|
||||
"src/{a,b}",
|
||||
path.join("src", "{a,b}"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
+284
-264
File diff suppressed because it is too large
Load Diff
+15
-5
@@ -5,12 +5,22 @@
|
||||
"type": "module",
|
||||
"description": "A GitHub Action to run Ruff, an extremely fast Python linter and code formatter.",
|
||||
"main": "dist/ruff-action/index.cjs",
|
||||
"engines": {
|
||||
"npm": ">=11.10.0"
|
||||
},
|
||||
"devEngines": {
|
||||
"packageManager": {
|
||||
"name": "npm",
|
||||
"version": ">=11.10.0",
|
||||
"onFail": "error"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit",
|
||||
"check": "biome check --write",
|
||||
"package": "node scripts/build-dist.mjs",
|
||||
"act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"",
|
||||
"update-known-checksums": "RUNNER_TEMP=known_checksums node dist/update-known-checksums/index.cjs src/download/checksum/known-checksums.ts \"$(gh auth token)\"",
|
||||
"update-known-checksums": "RUNNER_TEMP=known_checksums node dist/update-known-checksums/index.cjs src/download/checksum/known-checksums.json \"$(gh auth token)\"",
|
||||
"test:unit": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
|
||||
"test": "npm run build && npm run test:unit",
|
||||
"all": "npm run build && npm run check && npm run package && npm run test:unit"
|
||||
@@ -28,12 +38,12 @@
|
||||
"author": "@eifinger",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^3.0.0",
|
||||
"@actions/core": "^3.0.1",
|
||||
"@actions/exec": "^3.0.0",
|
||||
"@actions/glob": "^0.7.0",
|
||||
"@actions/tool-cache": "^4.0.0",
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/plugin-paginate-rest": "^13.1.1",
|
||||
"@octokit/plugin-paginate-rest": "^15.0.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^17.0.0",
|
||||
"@renovatebot/pep440": "^4.2.1",
|
||||
"smol-toml": "^1.6.0",
|
||||
@@ -43,9 +53,9 @@
|
||||
"@biomejs/biome": "^2.4.7",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/node": "^26.1.1",
|
||||
"@types/semver": "^7.7.1",
|
||||
"esbuild": "^0.27.4",
|
||||
"esbuild": "^0.28.2",
|
||||
"jest": "^30.3.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"ts-jest": "^29.4.6",
|
||||
|
||||
+3442
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,25 +5,16 @@ export async function updateChecksums(
|
||||
filePath: string,
|
||||
downloadUrls: string[],
|
||||
): Promise<void> {
|
||||
await fs.rm(filePath);
|
||||
await fs.appendFile(
|
||||
filePath,
|
||||
"// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n",
|
||||
);
|
||||
let firstLine = true;
|
||||
const checksums: Record<string, string> = {};
|
||||
for (const downloadUrl of downloadUrls) {
|
||||
const key = getKey(downloadUrl);
|
||||
if (key === undefined) {
|
||||
continue;
|
||||
}
|
||||
const checksum = await getOrDownloadChecksum(key, downloadUrl);
|
||||
if (!firstLine) {
|
||||
await fs.appendFile(filePath, ",\n");
|
||||
}
|
||||
await fs.appendFile(filePath, ` "${key}":\n "${checksum}"`);
|
||||
firstLine = false;
|
||||
checksums[key] = checksum;
|
||||
}
|
||||
await fs.appendFile(filePath, ",\n};\n");
|
||||
await fs.writeFile(filePath, `${JSON.stringify(checksums, null, 2)}\n`);
|
||||
}
|
||||
|
||||
function getKey(downloadUrl: string): string | undefined {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"target": "ES2022"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user