mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-05-12 20:50:14 +02:00
Support hashes in requirement files for version-file (#287)
This commit is contained in:
@@ -236,6 +236,25 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
RUFF_VERSION: ${{ steps.ruff-action.outputs.ruff-version }}
|
||||||
|
test-default-version-from-requirements-with-hash:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Use default version from requirements-with-hash.txt
|
||||||
|
id: ruff-action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
src: __tests__/fixtures/python-project
|
||||||
|
version-file: __tests__/fixtures/requirements-with-hash.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:
|
test-semver-range:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -383,6 +402,7 @@ jobs:
|
|||||||
- test-default-version-from-pyproject-poetry
|
- test-default-version-from-pyproject-poetry
|
||||||
- test-default-version-from-pyproject-optional-dependencies
|
- test-default-version-from-pyproject-optional-dependencies
|
||||||
- test-default-version-from-requirements
|
- test-default-version-from-requirements
|
||||||
|
- test-default-version-from-requirements-with-hash
|
||||||
- test-semver-range
|
- test-semver-range
|
||||||
- test-pep440-version-specifier
|
- test-pep440-version-specifier
|
||||||
- test-checksum
|
- test-checksum
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ruff==0.9.0 \
|
||||||
|
--hash=sha256:badc0de
|
||||||
+4
-7
@@ -32317,14 +32317,11 @@ const toml = __importStar(__nccwpck_require__(7106));
|
|||||||
function getRuffVersionFromAllDependencies(allDependencies) {
|
function getRuffVersionFromAllDependencies(allDependencies) {
|
||||||
const ruffVersionDefinition = allDependencies.find((dep) => dep.startsWith("ruff"));
|
const ruffVersionDefinition = allDependencies.find((dep) => dep.startsWith("ruff"));
|
||||||
if (ruffVersionDefinition) {
|
if (ruffVersionDefinition) {
|
||||||
const ruffVersion = ruffVersionDefinition
|
const match = ruffVersionDefinition.trim().match(/^ruff\s*==\s*([^\s\\]+)/);
|
||||||
.match(/^ruff([^A-Z0-9._-]+.*)$/)?.[1]
|
if (match) {
|
||||||
.trim();
|
core.info(`Found ruff version in requirements file: ${match[1]}`);
|
||||||
if (ruffVersion?.startsWith("==")) {
|
return match[1];
|
||||||
return ruffVersion.slice(2);
|
|
||||||
}
|
}
|
||||||
core.info(`Found ruff version in pyproject.toml: ${ruffVersion}`);
|
|
||||||
return ruffVersion;
|
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,12 @@ function getRuffVersionFromAllDependencies(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (ruffVersionDefinition) {
|
if (ruffVersionDefinition) {
|
||||||
const ruffVersion = ruffVersionDefinition
|
const match = ruffVersionDefinition.trim().match(/^ruff\s*==\s*([^\s\\]+)/);
|
||||||
.match(/^ruff([^A-Z0-9._-]+.*)$/)?.[1]
|
|
||||||
.trim();
|
if (match) {
|
||||||
if (ruffVersion?.startsWith("==")) {
|
core.info(`Found ruff version in requirements file: ${match[1]}`);
|
||||||
return ruffVersion.slice(2);
|
return match[1];
|
||||||
}
|
}
|
||||||
core.info(`Found ruff version in pyproject.toml: ${ruffVersion}`);
|
|
||||||
return ruffVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user