mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
coursier: additional_dependencies support
This commit is contained in:
parent
59ed51a309
commit
70bfd76ced
10 changed files with 132 additions and 66 deletions
|
|
@ -1,11 +0,0 @@
|
|||
$wc = New-Object System.Net.WebClient
|
||||
|
||||
$coursier_url = "https://github.com/coursier/coursier/releases/download/v2.0.5/cs-x86_64-pc-win32.exe"
|
||||
$coursier_dest = "C:\coursier\cs.exe"
|
||||
$coursier_hash ="d63d497f7805261e1cd657b8aaa626f6b8f7264cdb68219b2e6be9dd882033a9"
|
||||
|
||||
New-Item -Path "C:\" -Name "coursier" -ItemType "directory"
|
||||
$wc.DownloadFile($coursier_url, $coursier_dest)
|
||||
if ((Get-FileHash $coursier_dest -Algorithm SHA256).Hash -ne $coursier_hash) {
|
||||
throw "Invalid coursier file"
|
||||
}
|
||||
|
|
@ -1,15 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
# This is a script used in CI to install coursier
|
||||
set -euo pipefail
|
||||
|
||||
COURSIER_URL="https://github.com/coursier/coursier/releases/download/v2.0.0/cs-x86_64-pc-linux"
|
||||
COURSIER_HASH="e2e838b75bc71b16bcb77ce951ad65660c89bda7957c79a0628ec7146d35122f"
|
||||
ARTIFACT="/tmp/coursier/cs"
|
||||
if [ "$OSTYPE" = msys ]; then
|
||||
URL='https://github.com/coursier/coursier/releases/download/v2.1.0-RC4/cs-x86_64-pc-win32.zip'
|
||||
SHA256='0d07386ff0f337e3e6264f7dde29d137dda6eaa2385f29741435e0b93ccdb49d'
|
||||
TARGET='/tmp/coursier/cs.zip'
|
||||
|
||||
unpack() {
|
||||
unzip "$TARGET" -d /tmp/coursier
|
||||
mv /tmp/coursier/cs-*.exe /tmp/coursier/cs.exe
|
||||
cygpath -w /tmp/coursier >> "$GITHUB_PATH"
|
||||
}
|
||||
else
|
||||
URL='https://github.com/coursier/coursier/releases/download/v2.1.0-RC4/cs-x86_64-pc-linux.gz'
|
||||
SHA256='176e92e08ab292531aa0c4993dbc9f2c99dec79578752f3b9285f54f306db572'
|
||||
TARGET=/tmp/coursier/cs.gz
|
||||
|
||||
unpack() {
|
||||
gunzip "$TARGET"
|
||||
chmod +x /tmp/coursier/cs
|
||||
echo /tmp/coursier >> "$GITHUB_PATH"
|
||||
}
|
||||
fi
|
||||
|
||||
mkdir -p /tmp/coursier
|
||||
rm -f "$ARTIFACT"
|
||||
curl --location --silent --output "$ARTIFACT" "$COURSIER_URL"
|
||||
echo "$COURSIER_HASH $ARTIFACT" | sha256sum --check
|
||||
chmod ugo+x /tmp/coursier/cs
|
||||
|
||||
echo '/tmp/coursier' >> "$GITHUB_PATH"
|
||||
curl --location --silent --output "$TARGET" "$URL"
|
||||
echo "$SHA256 $TARGET" | sha256sum --check
|
||||
unpack
|
||||
|
|
|
|||
33
testing/language_helpers.py
Normal file
33
testing/language_helpers.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.languages.all import Language
|
||||
from pre_commit.prefix import Prefix
|
||||
|
||||
|
||||
def run_language(
|
||||
path: os.PathLike[str],
|
||||
language: Language,
|
||||
exe: str,
|
||||
args: Sequence[str] = (),
|
||||
file_args: Sequence[str] = (),
|
||||
version: str = C.DEFAULT,
|
||||
deps: Sequence[str] = (),
|
||||
) -> tuple[int, bytes]:
|
||||
prefix = Prefix(str(path))
|
||||
|
||||
language.install_environment(prefix, version, deps)
|
||||
with language.in_env(prefix, version):
|
||||
ret, out = language.run_hook(
|
||||
prefix,
|
||||
exe,
|
||||
args,
|
||||
file_args,
|
||||
require_serial=True,
|
||||
color=False,
|
||||
)
|
||||
out = out.replace(b'\r\n', b'\n')
|
||||
return ret, out
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"repositories": [
|
||||
"central"
|
||||
],
|
||||
"dependencies": [
|
||||
"io.get-coursier:echo:latest.stable"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
- id: echo-java
|
||||
name: echo-java
|
||||
description: echo from java
|
||||
entry: echo-java
|
||||
language: coursier
|
||||
|
|
@ -42,10 +42,6 @@ def cmd_output_mocked_pre_commit_home(
|
|||
return ret, out.replace('\r\n', '\n'), None
|
||||
|
||||
|
||||
skipif_cant_run_coursier = pytest.mark.skipif(
|
||||
os.name == 'nt' or parse_shebang.find_executable('cs') is None,
|
||||
reason="coursier isn't installed or can't be found",
|
||||
)
|
||||
skipif_cant_run_docker = pytest.mark.skipif(
|
||||
os.name == 'nt' or not docker_is_running(),
|
||||
reason="Docker isn't running or can't be accessed",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue