mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-08-08 02:07:02 +00:00
Compare commits
66
Commits
v2
...
pep440-specifiers
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f8ec3ecee | ||
|
|
0a94239999 | ||
|
|
da0c801a2d | ||
|
|
257550e917 | ||
|
|
94b3590e87 | ||
|
|
7a9e8edffe | ||
|
|
84f83ecf9e | ||
|
|
ea12b8ac41 | ||
|
|
b259b0b299 | ||
|
|
c6bea5606c | ||
|
|
400ab365db | ||
|
|
719c6e52c1 | ||
|
|
9a7114796b | ||
|
|
07c64b80af | ||
|
|
f800ba97f6 | ||
|
|
fd7f7e1868 | ||
|
|
faac838a0b | ||
|
|
94d4d711a6 | ||
|
|
9828f49eb4 | ||
|
|
8bfebd2812 | ||
|
|
b08b0d12d5 | ||
|
|
aecd4a32f6 | ||
|
|
8b3439f688 | ||
|
|
708db45010 | ||
|
|
9bdf1198e7 | ||
|
|
736d6639d0 | ||
|
|
bba8eb68c5 | ||
|
|
140ba44f2c | ||
|
|
5b3aacfc8f | ||
|
|
b11c1acffb | ||
|
|
19e5e84cff | ||
|
|
39f75e526a | ||
|
|
e0aedf576b | ||
|
|
160796f1a1 | ||
|
|
a7b1296fb5 | ||
|
|
097d5252c8 | ||
|
|
5f8cbe30d7 | ||
|
|
d8f577dec4 | ||
|
|
f173943ec8 | ||
|
|
d34edb0565 | ||
|
|
f14634c415 | ||
|
|
47de3deae8 | ||
|
|
d8281c74d4 | ||
|
|
a634044659 | ||
|
|
2993ff4a65 | ||
|
|
20a3b171f4 | ||
|
|
1c1aef9e3d | ||
|
|
0ceb04d9a0 | ||
|
|
18db80c954 | ||
|
|
0a5dfb89f1 | ||
|
|
9071a7b1c3 | ||
|
|
0c24450c01 | ||
|
|
e6390afda0 | ||
|
|
55d5f5e208 | ||
|
|
f6d50c4b88 | ||
|
|
4ef55e95c2 | ||
|
|
aef0def40a | ||
|
|
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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as yaml from "js-yaml";
|
||||
|
||||
const workflow = yaml.load(
|
||||
fs.readFileSync("../workflows/test.yml", "utf8"),
|
||||
) as any;
|
||||
const jobs = Object.keys(workflow.jobs);
|
||||
const allTestsPassed = workflow.jobs["all-tests-passed"];
|
||||
const needs: string[] = allTestsPassed.needs || [];
|
||||
|
||||
const expectedNeeds = jobs.filter((j) => j !== "all-tests-passed");
|
||||
const missing = expectedNeeds.filter((j) => !needs.includes(j));
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.error(
|
||||
`Missing jobs in all-tests-passed needs: ${missing.join(", ")}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("All jobs in test.yml are in the needs section of all-tests-passed.");
|
||||
@@ -1,49 +0,0 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: |
|
||||
npm run build
|
||||
npm run package
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff --text -v
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
@@ -12,6 +12,7 @@
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
@@ -3,17 +3,20 @@ name: Release Drafter
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
name: ✏️ Draft release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: 🚀 Run Release Drafter
|
||||
uses: release-drafter/release-drafter@v6.0.0
|
||||
uses: release-drafter/release-drafter@v6.1.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
+211
-19
@@ -1,7 +1,7 @@
|
||||
name: "test"
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -16,8 +16,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Actionlint
|
||||
uses: eifinger/actionlint-action@bdc2a242a53ae50e609e29f8eeb0d05d792edc09 # v1.7.0
|
||||
continue-on-error: true # Until https://github.com/rhysd/actionlint/pull/485 is released
|
||||
uses: eifinger/actionlint-action@23c85443d840cd73bbecb9cddfc933cc21649a38 # v1.9.1
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
@@ -25,25 +24,31 @@ jobs:
|
||||
npm install
|
||||
- run: |
|
||||
npm run all
|
||||
- name: Transpile scripts
|
||||
run: |
|
||||
tsc *.ts
|
||||
working-directory: .github/scripts
|
||||
- name: Make sure no changes from linters are detected
|
||||
run: |
|
||||
git diff --exit-code
|
||||
test-default-version:
|
||||
git diff --exit-code || (echo "::error::Please run 'npm run all' to fix the issues" && exit 1)
|
||||
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
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
ruff-version: ["0.7.4", "0.7", "0.7.x", ">=0.7.0"]
|
||||
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 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use version ${{ matrix.ruff-version }}
|
||||
@@ -51,6 +56,140 @@ jobs:
|
||||
with:
|
||||
version: ${{ matrix.ruff-version }}
|
||||
src: __tests__/fixtures/python-project
|
||||
test-unsupported-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Try install old version
|
||||
id: install
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
version: 0.0.246
|
||||
src: __tests__/fixtures/python-project
|
||||
- name: Check if the action failed
|
||||
run: |
|
||||
if [ ${{ steps.install.outcome }} == "success" ]; then
|
||||
exit 1
|
||||
fi
|
||||
test-version-from-version-file-pyproject:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use version from pyproject.toml
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/python-project
|
||||
version-file: __tests__/fixtures/pyproject.toml
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$RUFF_VERSION" != "0.9.3" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
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-default-version-from-pyproject-dependency-groups:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from pyproject.toml dependency groups
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/pyproject-dependency-groups-project
|
||||
version-file: __tests__/fixtures/pyproject-dependency-groups-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-default-version-from-pyproject-poetry-groups:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from pyproject.toml poetry group dependencies
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/pyproject-dependency-poetry-project
|
||||
version-file: __tests__/fixtures/pyproject-dependency-poetry-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-default-version-from-pyproject-optional-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from pyproject.toml optional dependencies
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/pyproject-optional-dependencies-project
|
||||
version-file: __tests__/fixtures/pyproject-optional-dependencies-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-default-version-from-requirements:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use default version from requirements.txt
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
src: __tests__/fixtures/python-project
|
||||
version-file: __tests__/fixtures/requirements.txt
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$RUFF_VERSION" != "0.9.0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
test-semver-range:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -68,17 +207,30 @@ jobs:
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
test-pep440-version-specifier:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install version 0.11.11
|
||||
id: ruff-action
|
||||
uses: ./
|
||||
with:
|
||||
version: ">=0.11.10,<0.12.0"
|
||||
src: __tests__/fixtures/python-project
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$RUFF_VERSION" != "0.11.11" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||
test-checksum:
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.inputs.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
checksum:
|
||||
["0de731c669b9ece77e799ac3f4a160c30849752714d9775c94cc4cfaf326860c"]
|
||||
exclude:
|
||||
- os: macos-latest
|
||||
inputs:
|
||||
- os: ubuntu-latest
|
||||
checksum: "0de731c669b9ece77e799ac3f4a160c30849752714d9775c94cc4cfaf326860c"
|
||||
include:
|
||||
- os: macos-latest
|
||||
checksum: "af9583bff12afbca5d5670334e0187dd60c4d91bc71317d1b2dde70cb1200ba9"
|
||||
steps:
|
||||
@@ -87,7 +239,7 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
version: "0.7.4"
|
||||
checksum: ${{ matrix.checksum }}
|
||||
checksum: ${{ matrix.inputs.checksum }}
|
||||
src: __tests__/fixtures/python-project
|
||||
test-with-explicit-token:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -114,8 +266,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 +275,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:
|
||||
@@ -140,3 +303,32 @@ jobs:
|
||||
src: >-
|
||||
__tests__/fixtures/python-project/src/python_project/__init__.py
|
||||
__tests__/fixtures/python-project/src/python_project/hello_world.py
|
||||
|
||||
all-tests-passed:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- lint
|
||||
- test-latest-version
|
||||
- test-specific-version
|
||||
- test-unsupported-version
|
||||
- test-version-from-version-file-pyproject
|
||||
- test-default-version-from-pyproject
|
||||
- test-default-version-from-pyproject-dev-group
|
||||
- test-default-version-from-pyproject-dependency-groups
|
||||
- test-default-version-from-pyproject-poetry-groups
|
||||
- test-default-version-from-pyproject-optional-dependencies
|
||||
- test-default-version-from-requirements
|
||||
- test-semver-range
|
||||
- test-pep440-version-specifier
|
||||
- test-checksum
|
||||
- test-with-explicit-token
|
||||
- test-args
|
||||
- test-failure
|
||||
- test-multiple-src
|
||||
if: always()
|
||||
steps:
|
||||
- name: All tests passed
|
||||
run: |
|
||||
echo "All jobs passed: ${{ !contains(needs.*.result, 'failure') }}"
|
||||
# shellcheck disable=SC2242
|
||||
exit ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
name: "Update known checksums"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 4 * * *" # Run every day at 4am UTC
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
@@ -17,7 +22,7 @@ jobs:
|
||||
src/download/checksum/known-checksums.ts ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: npm install && npm run all
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
|
||||
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||
with:
|
||||
commit-message: "chore: update known checksums"
|
||||
title:
|
||||
|
||||
@@ -13,7 +13,36 @@ jobs:
|
||||
update_major_minor_tags:
|
||||
name: Make sure major and minor tags are up to date on a patch release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run Update semver
|
||||
uses: haya14busa/action-update-semver@v1.2.1
|
||||
- name: Update Major Minor Tags
|
||||
run: |
|
||||
set -x
|
||||
|
||||
cd "${GITHUB_WORKSPACE}" || exit
|
||||
|
||||
# Set up variables.
|
||||
TAG="${GITHUB_REF#refs/tags/}" # v1.2.3
|
||||
MINOR="${TAG%.*}" # v1.2
|
||||
MAJOR="${MINOR%.*}" # v1
|
||||
|
||||
if [ "${GITHUB_REF}" = "${TAG}" ]; then
|
||||
echo "This workflow is not triggered by tag push: GITHUB_REF=${GITHUB_REF}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MESSAGE="Release ${TAG}"
|
||||
|
||||
# Set up Git.
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
|
||||
# Update MAJOR/MINOR tag
|
||||
git tag -fa "${MAJOR}" -m "${MESSAGE}"
|
||||
git tag -fa "${MINOR}" -m "${MESSAGE}"
|
||||
|
||||
# Push
|
||||
git push --force origin "${MINOR}"
|
||||
git push --force origin "${MAJOR}"
|
||||
|
||||
@@ -4,8 +4,8 @@ A GitHub Action to run [ruff](https://github.com/astral-sh/ruff).
|
||||
|
||||
This action is commonly used as a pass/fail test to ensure your repository stays
|
||||
clean, abiding the [rules](https://docs.astral.sh/ruff/rules/) specified in your
|
||||
configuration. Though it runs `ruff`, the action can do anything `ruff` can (ex,
|
||||
fix).
|
||||
configuration. Though it runs `ruff check` by default, the action can do
|
||||
anything `ruff` can (ex, fix).
|
||||
|
||||
## Contents
|
||||
|
||||
@@ -16,33 +16,35 @@ fix).
|
||||
- [Use to install ruff](#use-to-install-ruff)
|
||||
- [Use `ruff format`](#use-ruff-format)
|
||||
- [Install specific versions](#install-specific-versions)
|
||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||
- [Install the latest version](#install-the-latest-version)
|
||||
- [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 by supplying a semver range or pep440 specifier](#install-a-version-by-supplying-a-semver-range-or-pep440-specifier)
|
||||
- [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
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v2
|
||||
- uses: astral-sh/ruff-action@v3
|
||||
```
|
||||
|
||||
### Specify a different source directory
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
src: "./src"
|
||||
```
|
||||
@@ -50,7 +52,7 @@ fix).
|
||||
### Specify multiple files
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
src: >-
|
||||
path/to/file1.py
|
||||
@@ -62,64 +64,97 @@ 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@v3
|
||||
- run: ruff check --fix
|
||||
- run: ruff format
|
||||
```
|
||||
|
||||
By default, this action runs `ruff check` after installation.
|
||||
If you do not want to run any `ruff` command but only install it,
|
||||
you can use the `args` input to overwrite the default value (`check`):
|
||||
|
||||
```yaml
|
||||
- name: Install ruff without running check or format
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
args: "--version"
|
||||
```
|
||||
|
||||
### Use `ruff format`
|
||||
|
||||
```yaml
|
||||
- uses: astral-sh/ruff-action@v1
|
||||
- uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
args: "format --check"
|
||||
args: "format --check --diff"
|
||||
```
|
||||
|
||||
### 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
|
||||
`project.dependencies`, `project.optional-dependencies`, or `dependency-groups`,
|
||||
the latest version is installed.
|
||||
|
||||
> [!NOTE]
|
||||
> This action does only support ruff versions v0.0.247 and above.
|
||||
|
||||
#### Install the latest version
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of ruff
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
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
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version: "0.4.4"
|
||||
```
|
||||
|
||||
### Install a version by supplying a semver range
|
||||
#### Install a version by supplying a semver range or pep440 specifier
|
||||
|
||||
You can specify a [semver range](https://github.com/npm/node-semver?tab=readme-ov-file#ranges)
|
||||
or [pep440 specifier](https://peps.python.org/pep-0440/#version-specifiers)
|
||||
to install the latest version that satisfies the range.
|
||||
|
||||
```yaml
|
||||
- name: Install a semver range of ruff
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version: ">=0.4.0"
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Pinning a minor version of ruff
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version: "0.4.x"
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Install a pep440-specifier-satisfying version of ruff
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version: ">=0.11.10,<0.12.0"
|
||||
```
|
||||
|
||||
#### Install a version from a specified version file
|
||||
|
||||
You can specify a file to read the version from.
|
||||
Currently `pyproject.toml` and `requirements.txt` are supported.
|
||||
|
||||
```yaml
|
||||
- name: Install a version from a specified version file
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version-file: "my-path/to/pyproject.toml-or-requirements.txt"
|
||||
```
|
||||
|
||||
### Validate checksum
|
||||
|
||||
You can specify a checksum to validate the downloaded executable. Checksums up to the default version
|
||||
@@ -128,7 +163,7 @@ are automatically verified by this action. The sha256 hashes can be found on the
|
||||
|
||||
```yaml
|
||||
- name: Install a specific version and validate the checksum
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
version: "0.7.4"
|
||||
checksum: "0de731c669b9ece77e799ac3f4a160c30849752714d9775c94cc4cfaf326860c"
|
||||
@@ -146,7 +181,7 @@ are not sufficient, you can provide a custom GitHub token with the necessary per
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of ruff with a custom GitHub token
|
||||
uses: astral-sh/ruff-action@v2
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
+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!")
|
||||
@@ -0,0 +1,22 @@
|
||||
[project]
|
||||
name = "pyproject-dependency-groups-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
{ include-group = "docs" },
|
||||
{ include-group = "lint" },
|
||||
]
|
||||
docs = [
|
||||
"sphinx",
|
||||
]
|
||||
lint = [
|
||||
"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!")
|
||||
@@ -0,0 +1,14 @@
|
||||
[project]
|
||||
name = "pyproject-dependency-poetry-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
sphinx = "*"
|
||||
ruff = "0.8.3"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def hello() -> str:
|
||||
return "Hello from python-project!"
|
||||
+1
@@ -0,0 +1 @@
|
||||
print("Hello world!")
|
||||
@@ -0,0 +1,15 @@
|
||||
[project]
|
||||
name = "pyproject-optional-dependencies-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[project.optional-dependencies]
|
||||
lint = [
|
||||
"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!")
|
||||
@@ -0,0 +1,13 @@
|
||||
[project]
|
||||
name = "pyython-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"ruff==0.9.3",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
@@ -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]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ruff==0.9.0
|
||||
+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
|
||||
|
||||
+6433
-4491
File diff suppressed because it is too large
Load Diff
+4530
-4461
File diff suppressed because it is too large
Load Diff
Generated
+134
-148
@@ -11,16 +11,21 @@
|
||||
"dependencies": {
|
||||
"@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.2",
|
||||
"@octokit/core": "^6.1.4",
|
||||
"@octokit/plugin-paginate-rest": "^11.4.3",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||
"@renovatebot/pep440": "^4.1.0",
|
||||
"smol-toml": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^22.13.10",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"typescript": "^5.6.3"
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
@@ -40,17 +45,6 @@
|
||||
"@actions/io": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/github": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz",
|
||||
"integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.2.0",
|
||||
"@octokit/core": "^5.0.1",
|
||||
"@octokit/plugin-paginate-rest": "^9.0.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz",
|
||||
@@ -66,16 +60,15 @@
|
||||
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
|
||||
},
|
||||
"node_modules/@actions/tool-cache": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
|
||||
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
|
||||
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/io": "^1.1.1",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.2"
|
||||
"semver": "^6.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@biomejs/biome": {
|
||||
@@ -242,156 +235,148 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
|
||||
"integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==",
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.1.2.tgz",
|
||||
"integrity": "sha512-JcQDsBdg49Yky2w2ld20IHAlwr8d/d8N6NiOXbtuoPCqzbsiJgF633mVUw3x4mo0H5ypataQIX7SFu3yy44Mpw==",
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/core": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
|
||||
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
|
||||
"version": "6.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.4.tgz",
|
||||
"integrity": "sha512-lAS9k7d6I0MPN+gb9bKDt7X8SdxknYqAMh44S5L+lNqIN2NuV8nvv3g8rPp7MuRxcOpxpUIATWprO0C34a8Qmg==",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^4.0.0",
|
||||
"@octokit/graphql": "^7.1.0",
|
||||
"@octokit/request": "^8.3.1",
|
||||
"@octokit/request-error": "^5.1.0",
|
||||
"@octokit/types": "^13.0.0",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
"@octokit/auth-token": "^5.0.0",
|
||||
"@octokit/graphql": "^8.1.2",
|
||||
"@octokit/request": "^9.2.1",
|
||||
"@octokit/request-error": "^6.1.7",
|
||||
"@octokit/types": "^13.6.2",
|
||||
"before-after-hook": "^3.0.2",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/endpoint": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.5.tgz",
|
||||
"integrity": "sha512-ekqR4/+PCLkEBF6qgj8WqJfvDq65RH85OAgrtnVp1mSxaXF03u2xW/hUdweGS5654IlC0wkNYC18Z50tSYTAFw==",
|
||||
"version": "10.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.3.tgz",
|
||||
"integrity": "sha512-nBRBMpKPhQUxCsQQeW+rCJ/OPSMcj3g0nfHn01zGYZXuNDvvXudF/TYY6APj5THlurerpFN4a/dQAIAaM6BYhA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^13.1.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
"@octokit/types": "^13.6.2",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/graphql": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.0.tgz",
|
||||
"integrity": "sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==",
|
||||
"version": "8.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.1.2.tgz",
|
||||
"integrity": "sha512-bdlj/CJVjpaz06NBpfHhp4kGJaRZfz7AzC+6EwUImRtrwIw8dIgJ63Xg0OzV9pRn3rIzrt5c2sa++BL0JJ8GLw==",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^8.3.0",
|
||||
"@octokit/types": "^13.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
"@octokit/request": "^9.1.4",
|
||||
"@octokit/types": "^13.6.2",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/openapi-types": {
|
||||
"version": "22.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",
|
||||
"integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="
|
||||
"version": "23.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz",
|
||||
"integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "9.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.1.tgz",
|
||||
"integrity": "sha512-wfGhE/TAkXZRLjksFXuDZdmGnJQHvtU/joFQdweXUgzo1XwvBCD4o4+75NtFfjfLK5IwLf9vHTfSiU3sLRYpRw==",
|
||||
"version": "11.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.3.tgz",
|
||||
"integrity": "sha512-tBXaAbXkqVJlRoA/zQVe9mUdb8rScmivqtpv3ovsC5xhje/a+NOCivs7eUhWBwCApJVsR4G5HMeaLbq7PxqZGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^12.6.0"
|
||||
"@octokit/types": "^13.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": "5"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/openapi-types": {
|
||||
"version": "20.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz",
|
||||
"integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": {
|
||||
"version": "12.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz",
|
||||
"integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^20.0.0"
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "10.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz",
|
||||
"integrity": "sha512-xV1b+ceKV9KytQe3zCVqjg+8GTGfDYwaT1ATU5isiUyVtlVAO3HNdzpS4sr4GBx4hxQ46s7ITtZrAsxG22+rVg==",
|
||||
"version": "13.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.3.1.tgz",
|
||||
"integrity": "sha512-o8uOBdsyR+WR8MK9Cco8dCgvG13H1RlM1nWnK/W7TEACQBFux/vPREgKucxUfuDQ5yi1T3hGf4C5ZmZXAERgwQ==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^12.6.0"
|
||||
"@octokit/types": "^13.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": "5"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": {
|
||||
"version": "20.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz",
|
||||
"integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": {
|
||||
"version": "12.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz",
|
||||
"integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^20.0.0"
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request": {
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.0.tgz",
|
||||
"integrity": "sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==",
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.2.2.tgz",
|
||||
"integrity": "sha512-dZl0ZHx6gOQGcffgm1/Sf6JfEpmh34v3Af2Uci02vzUYz6qEN6zepoRtmybWXIGXFIK8K9ylE3b+duCWqhArtg==",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^9.0.1",
|
||||
"@octokit/request-error": "^5.1.0",
|
||||
"@octokit/types": "^13.1.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
"@octokit/endpoint": "^10.1.3",
|
||||
"@octokit/request-error": "^6.1.7",
|
||||
"@octokit/types": "^13.6.2",
|
||||
"fast-content-type-parse": "^2.0.0",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request-error": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.0.tgz",
|
||||
"integrity": "sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==",
|
||||
"version": "6.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.7.tgz",
|
||||
"integrity": "sha512-69NIppAwaauwZv6aOzb+VVLwt+0havz9GT5YplkeJv7fG7a40qpLt/yZKyiDxAhgz0EtgNdNcb96Z0u+Zyuy2g==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^13.1.0",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
"@octokit/types": "^13.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "13.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",
|
||||
"integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",
|
||||
"version": "13.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz",
|
||||
"integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^22.2.0"
|
||||
"@octokit/openapi-types": "^23.0.1"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"node_modules/@renovatebot/pep440": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@renovatebot/pep440/-/pep440-4.1.0.tgz",
|
||||
"integrity": "sha512-mo2RxnOSp78Njt1HmgMwjl6FapP4OyIS8HypJlymCvN7AIV2Xf5PmZfl/E3O1WWZ6IjKrfsEAaPWFMi8tnkq3g==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^20.9.0 || ^22.11.0",
|
||||
"pnpm": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/js-yaml": {
|
||||
"version": "4.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
|
||||
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.13.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz",
|
||||
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.19.8"
|
||||
"undici-types": "~6.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
@@ -416,14 +401,24 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/before-after-hook": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
||||
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz",
|
||||
"integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A=="
|
||||
},
|
||||
"node_modules/deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
"node_modules/fast-content-type-parse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-2.0.1.tgz",
|
||||
"integrity": "sha512-nGqtvLrj5w0naR6tDPfB4cUmYCqouzyQiz6C5y/LtcDllJdrcc6WaWW6iXyIIOErTa/XRybj28aasdn4LkVk6Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.0",
|
||||
@@ -437,14 +432,6 @@
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||
@@ -453,6 +440,17 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/smol-toml": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz",
|
||||
"integrity": "sha512-tEYNll18pPKHroYSmLLrksq233j021G0giwW7P3D24jC54pQ5W5BXMsQ/Mvw1OJCmEYDgY+lrzT+3nNUtoNfXQ==",
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/cyyynthia"
|
||||
}
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
@@ -462,10 +460,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||
"version": "5.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
||||
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -475,9 +474,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.28.4",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
|
||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
||||
"version": "5.28.5",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||
"dependencies": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
},
|
||||
@@ -486,29 +485,16 @@
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz",
|
||||
"integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ=="
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",
|
||||
"integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -12,7 +12,7 @@
|
||||
"package": "ncc build -o dist/ruff-action src/ruff-action.ts && ncc build -o dist/update-known-checksums src/update-known-checksums.ts",
|
||||
"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.js src/download/checksum/known-checksums.ts \"$(gh auth token)\"",
|
||||
"all": "npm run build && npm run format && npm run lint && npm run package"
|
||||
"all": "npm install && npm run build && npm run format && npm run lint && npm run package"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,15 +24,20 @@
|
||||
"dependencies": {
|
||||
"@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.2",
|
||||
"@octokit/core": "^6.1.4",
|
||||
"@octokit/plugin-paginate-rest": "^11.4.3",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||
"@renovatebot/pep440": "^4.1.0",
|
||||
"smol-toml": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^22.13.10",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"typescript": "^5.6.3"
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,16 @@ import * as core from "@actions/core";
|
||||
import * as tc from "@actions/tool-cache";
|
||||
import * as path from "node:path";
|
||||
import { promises as fs } from "node:fs";
|
||||
import * as semver from "semver";
|
||||
import * as pep440 from "@renovatebot/pep440";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
|
||||
import type { Architecture, Platform } from "../utils/platforms";
|
||||
import { validateChecksum } from "./checksum/checksum";
|
||||
import * as github from "@actions/github";
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
||||
|
||||
const PaginatingOctokit = Octokit.plugin(paginateRest, restEndpointMethods);
|
||||
|
||||
export function tryGetFromToolCache(
|
||||
arch: Architecture,
|
||||
@@ -29,28 +35,64 @@ 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}`;
|
||||
core.info(`Downloading ruff from "${downloadUrl}" ...`);
|
||||
const downloadUrl = constructDownloadUrl(version, platform, arch);
|
||||
core.debug(`Downloading ruff from "${downloadUrl}" ...`);
|
||||
|
||||
const downloadPath = await tc.downloadTool(
|
||||
downloadUrl,
|
||||
undefined,
|
||||
githubToken,
|
||||
);
|
||||
await validateChecksum(
|
||||
checkSum,
|
||||
core.debug(`Downloaded ruff to "${downloadPath}"`);
|
||||
await validateChecksum(checkSum, downloadPath, arch, platform, version);
|
||||
|
||||
const extractedDir = await extractDownloadedArtifact(
|
||||
version,
|
||||
downloadPath,
|
||||
arch,
|
||||
extension,
|
||||
platform,
|
||||
resolvedVersion,
|
||||
artifact,
|
||||
);
|
||||
|
||||
const cachedToolDir = await tc.cacheDir(
|
||||
extractedDir,
|
||||
TOOL_CACHE_NAME,
|
||||
version,
|
||||
arch,
|
||||
);
|
||||
return { version: version, cachedToolDir };
|
||||
}
|
||||
|
||||
function constructDownloadUrl(
|
||||
version: string,
|
||||
platform: Platform,
|
||||
arch: Architecture,
|
||||
): string {
|
||||
const artifactVersionSuffix =
|
||||
semver.lte(version, "v0.4.10") && semver.gte(version, "v0.1.8")
|
||||
? `-${version}`
|
||||
: "";
|
||||
const artifact = `ruff${artifactVersionSuffix}-${arch}-${platform}`;
|
||||
let extension = ".tar.gz";
|
||||
if (platform === "pc-windows-msvc") {
|
||||
extension = ".zip";
|
||||
}
|
||||
const versionPrefix = semver.lte(version, "v0.4.10") ? "v" : "";
|
||||
return `https://github.com/${OWNER}/${REPO}/releases/download/${versionPrefix}${version}/${artifact}${extension}`;
|
||||
}
|
||||
|
||||
async function extractDownloadedArtifact(
|
||||
version: string,
|
||||
downloadPath: string,
|
||||
extension: string,
|
||||
platform: Platform,
|
||||
artifact: string,
|
||||
): Promise<string> {
|
||||
let ruffDir: string;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
@@ -58,22 +100,22 @@ export async function downloadVersion(
|
||||
ruffDir = await tc.extractZip(fullPathWithExtension);
|
||||
// On windows extracting the zip does not create an intermediate directory
|
||||
} else {
|
||||
const extractedDir = await tc.extractTar(downloadPath);
|
||||
ruffDir = path.join(extractedDir, artifact);
|
||||
ruffDir = await tc.extractTar(downloadPath);
|
||||
if (semver.gte(version, "v0.5.0")) {
|
||||
// Since v0.5.0 an intermediate directory is created
|
||||
ruffDir = path.join(ruffDir, artifact);
|
||||
}
|
||||
}
|
||||
const cachedToolDir = await tc.cacheDir(
|
||||
ruffDir,
|
||||
TOOL_CACHE_NAME,
|
||||
resolvedVersion,
|
||||
arch,
|
||||
);
|
||||
return { version: resolvedVersion, cachedToolDir };
|
||||
const files = await fs.readdir(ruffDir);
|
||||
core.debug(`Contents of ${ruffDir}: ${files.join(", ")}`);
|
||||
return ruffDir;
|
||||
}
|
||||
|
||||
export async function resolveVersion(
|
||||
versionInput: string,
|
||||
githubToken: string,
|
||||
): Promise<string> {
|
||||
core.debug(`Resolving ${versionInput}...`);
|
||||
const version =
|
||||
versionInput === "latest"
|
||||
? await getLatestVersion(githubToken)
|
||||
@@ -83,16 +125,35 @@ export async function resolveVersion(
|
||||
return version;
|
||||
}
|
||||
const availableVersions = await getAvailableVersions(githubToken);
|
||||
const resolvedVersion = tc.evaluateVersions(availableVersions, version);
|
||||
if (resolvedVersion === "") {
|
||||
const resolvedVersion = maxSatisfying(availableVersions, version);
|
||||
if (resolvedVersion === undefined) {
|
||||
throw new Error(`No version found for ${version}`);
|
||||
}
|
||||
core.debug(`Resolved version: ${resolvedVersion}`);
|
||||
return resolvedVersion;
|
||||
}
|
||||
|
||||
async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
const octokit = github.getOctokit(githubToken);
|
||||
try {
|
||||
const octokit = new PaginatingOctokit({
|
||||
auth: githubToken,
|
||||
});
|
||||
return await getReleaseTagNames(octokit);
|
||||
} catch (err) {
|
||||
if ((err as Error).message.includes("Bad credentials")) {
|
||||
core.info(
|
||||
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
|
||||
);
|
||||
const octokit = new PaginatingOctokit();
|
||||
return await getReleaseTagNames(octokit);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async function getReleaseTagNames(
|
||||
octokit: InstanceType<typeof PaginatingOctokit>,
|
||||
): Promise<string[]> {
|
||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
@@ -101,15 +162,56 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
}
|
||||
|
||||
async function getLatestVersion(githubToken: string) {
|
||||
const octokit = github.getOctokit(githubToken);
|
||||
|
||||
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
const octokit = new PaginatingOctokit({
|
||||
auth: githubToken,
|
||||
});
|
||||
|
||||
let latestRelease: { tag_name: string } | undefined;
|
||||
try {
|
||||
latestRelease = await getLatestRelease(octokit);
|
||||
} catch (err) {
|
||||
if ((err as Error).message.includes("Bad credentials")) {
|
||||
core.info(
|
||||
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
|
||||
);
|
||||
const octokit = new PaginatingOctokit();
|
||||
latestRelease = await getLatestRelease(octokit);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!latestRelease) {
|
||||
throw new Error("Could not determine latest release.");
|
||||
}
|
||||
return latestRelease.tag_name;
|
||||
}
|
||||
|
||||
async function getLatestRelease(
|
||||
octokit: InstanceType<typeof PaginatingOctokit>,
|
||||
) {
|
||||
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
});
|
||||
return latestRelease;
|
||||
}
|
||||
|
||||
function maxSatisfying(
|
||||
versions: string[],
|
||||
version: string,
|
||||
): string | undefined {
|
||||
const maxSemver = tc.evaluateVersions(versions, version);
|
||||
if (maxSemver !== "") {
|
||||
core.debug(`Found a version that satisfies the semver range: ${maxSemver}`);
|
||||
return maxSemver;
|
||||
}
|
||||
const maxPep440 = pep440.maxSatisfying(versions, version);
|
||||
if (maxPep440 !== null) {
|
||||
core.debug(
|
||||
`Found a version that satisfies the pep440 specifier: ${maxPep440}`,
|
||||
);
|
||||
return maxPep440;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
+68
-10
@@ -13,7 +13,17 @@ 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 { getRuffVersionFromRequirementsFile } from "./utils/pyproject";
|
||||
import * as fs from "node:fs";
|
||||
import * as semver from "semver";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const platform = getPlatform();
|
||||
@@ -26,15 +36,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 +59,15 @@ 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();
|
||||
if (semver.lt(resolvedVersion, "v0.0.247")) {
|
||||
throw Error(
|
||||
"This action does not support ruff versions older than 0.0.247",
|
||||
);
|
||||
}
|
||||
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
|
||||
if (toolCacheResult.installedPath) {
|
||||
core.info(`Found ruffDir in tool-cache for ${toolCacheResult.version}`);
|
||||
@@ -81,11 +91,59 @@ 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 =
|
||||
getRuffVersionFromRequirementsFile(versionFileInput);
|
||||
if (versionFromPyproject === undefined) {
|
||||
core.warning(
|
||||
`Could not parse version from ${versionFileInput}. Using latest version.`,
|
||||
);
|
||||
}
|
||||
return await resolveVersion(versionFromPyproject || "latest", githubToken);
|
||||
}
|
||||
const pyProjectPath = path.join(src, "pyproject.toml");
|
||||
if (!fs.existsSync(pyProjectPath)) {
|
||||
core.info(`Could not find ${pyProjectPath}. Using latest version.`);
|
||||
return await resolveVersion("latest", githubToken);
|
||||
}
|
||||
const versionFromPyproject =
|
||||
getRuffVersionFromRequirementsFile(pyProjectPath);
|
||||
if (versionFromPyproject === undefined) {
|
||||
core.warning(
|
||||
`Could not parse version from ${pyProjectPath}. Using latest version.`,
|
||||
);
|
||||
}
|
||||
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[],
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import * as github from "@actions/github";
|
||||
import { Octokit } from "@octokit/core";
|
||||
import * as core from "@actions/core";
|
||||
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
||||
|
||||
import { OWNER, REPO } from "./utils/constants";
|
||||
import * as semver from "semver";
|
||||
|
||||
import { updateChecksums } from "./download/checksum/update-known-checksums";
|
||||
|
||||
const PaginatingOctokit = Octokit.plugin(paginateRest, restEndpointMethods);
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const checksumFilePath = process.argv.slice(2)[0];
|
||||
const github_token = process.argv.slice(2)[1];
|
||||
|
||||
const octokit = github.getOctokit(github_token);
|
||||
const octokit = new PaginatingOctokit({ auth: github_token });
|
||||
|
||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||
owner: OWNER,
|
||||
|
||||
@@ -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,90 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as core from "@actions/core";
|
||||
import * as toml from "smol-toml";
|
||||
|
||||
function getRuffVersionFromAllDependencies(
|
||||
allDependencies: string[],
|
||||
): string | undefined {
|
||||
const ruffVersionDefinition = allDependencies.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;
|
||||
}
|
||||
|
||||
interface Pyproject {
|
||||
project?: {
|
||||
dependencies?: string[];
|
||||
"optional-dependencies"?: Record<string, string[]>;
|
||||
};
|
||||
"dependency-groups"?: Record<string, Array<string | object>>;
|
||||
tool?: {
|
||||
poetry?: {
|
||||
group?: Record<string, { dependencies: Record<string, string | object> }>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function parsePyproject(pyprojectContent: string): string | undefined {
|
||||
const pyproject: Pyproject = toml.parse(pyprojectContent);
|
||||
const dependencies: string[] = pyproject?.project?.dependencies || [];
|
||||
const optionalDependencies: string[] = Object.values(
|
||||
pyproject?.project?.["optional-dependencies"] || {},
|
||||
).flat();
|
||||
const devDependencies: string[] = Object.values(
|
||||
pyproject?.["dependency-groups"] || {},
|
||||
)
|
||||
.flat()
|
||||
.filter((item: string | object) => typeof item === "string");
|
||||
return (
|
||||
getRuffVersionFromAllDependencies(
|
||||
dependencies.concat(optionalDependencies, devDependencies),
|
||||
) || getRuffVersionFromPoetryGroups(pyproject)
|
||||
);
|
||||
}
|
||||
|
||||
function getRuffVersionFromPoetryGroups(
|
||||
pyproject: Pyproject,
|
||||
): string | undefined {
|
||||
// Special handling for Poetry until it supports PEP 735
|
||||
// See: <https://github.com/python-poetry/poetry/issues/9751>
|
||||
const poetryGroups = Object.values(pyproject?.tool?.poetry?.group || {});
|
||||
return poetryGroups
|
||||
.flatMap((group) => Object.entries(group.dependencies))
|
||||
.map(([name, spec]) => {
|
||||
if (name === "ruff" && typeof spec === "string") return spec;
|
||||
return undefined;
|
||||
})
|
||||
.find((version) => version !== undefined);
|
||||
}
|
||||
|
||||
export function getRuffVersionFromRequirementsFile(
|
||||
filePath: string,
|
||||
): string | undefined {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
core.warning(`Could not find file: ${filePath}`);
|
||||
return undefined;
|
||||
}
|
||||
const pyprojectContent = fs.readFileSync(filePath, "utf-8");
|
||||
if (filePath.endsWith(".txt")) {
|
||||
return getRuffVersionFromAllDependencies(pyprojectContent.split("\n"));
|
||||
}
|
||||
try {
|
||||
return parsePyproject(pyprojectContent);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.warning(`Error while parsing ${filePath}: ${message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||
|
||||
Reference in New Issue
Block a user