mirror of
https://github.com/j178/prek.git
synced 2026-04-25 02:11:36 +02:00
a1b6d2821e
* Refactor `bloat-check` and `hotpath` workflow * Use faster profiling profile * Fix template injection issue * Tweak
376 lines
12 KiB
YAML
376 lines
12 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths-ignore:
|
|
- "README.md"
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
permissions: {}
|
|
|
|
env:
|
|
# UV_VERSION should not greater than MAX_UV_VERSION in `languages/python/uv`.
|
|
# Otherwise, tests jobs will install their own uv, and it will encounter concurrency issue.
|
|
UV_VERSION: "0.8.22"
|
|
NODE_VERSION: "20"
|
|
GO_VERSION: "1.24"
|
|
PYTHON_VERSION: "3.12"
|
|
LUA_VERSION: "5.4"
|
|
LUAROCKS_VERSION: "3.12.2"
|
|
|
|
jobs:
|
|
lint:
|
|
name: "lint"
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- name: "Install Rustfmt"
|
|
run: rustup component add rustfmt
|
|
- name: "rustfmt"
|
|
run: cargo fmt --all --check
|
|
- name: Run prek hooks
|
|
uses: j178/prek-action@91fd7d7cf70ae1dee9f4f44e7dfa5d1073fe6623 # v1.0.11
|
|
with:
|
|
extra-args: "--all-files --skip cargo-fmt --skip cargo-clippy"
|
|
|
|
cargo-clippy-linux:
|
|
name: "cargo clippy | ubuntu"
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup component add clippy
|
|
- name: "Clippy"
|
|
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
|
|
|
cargo-clippy-windows:
|
|
timeout-minutes: 15
|
|
runs-on: windows-latest
|
|
name: "cargo clippy | windows"
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- name: Create Dev Drive
|
|
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
|
|
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup component add clippy
|
|
|
|
- name: "Clippy"
|
|
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
|
|
|
cargo-shear:
|
|
name: "cargo shear"
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- name: "Install cargo shear"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-shear
|
|
- run: cargo shear
|
|
|
|
cargo-test-without-uv:
|
|
timeout-minutes: 5
|
|
runs-on: ubuntu-latest
|
|
name: "cargo test | without uv"
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup component add llvm-tools-preview
|
|
|
|
- name: "Install cargo nextest"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: "Install cargo-llvm-cov"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
|
|
- name: "Cargo test without uv"
|
|
run: |
|
|
echo "::group::Test install uv with auto select"
|
|
cargo llvm-cov nextest \
|
|
--no-report \
|
|
-E 'binary_id(prek::run) and test(run_basic)'
|
|
echo "::endgroup::"
|
|
|
|
for source in github pypi aliyun pip invalid; do
|
|
echo "::group::Test install uv from $source"
|
|
export PREK_UV_SOURCE=$source
|
|
cargo llvm-cov nextest \
|
|
--no-report \
|
|
-E 'binary_id(prek::run) and test(run_basic)'
|
|
echo "::endgroup::"
|
|
done
|
|
|
|
cargo llvm-cov report --lcov --output-path lcov.info
|
|
|
|
- name: "Upload coverage reports to Codecov"
|
|
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: lcov.info
|
|
|
|
cargo-test-linux:
|
|
timeout-minutes: 5
|
|
runs-on: ubuntu-latest
|
|
name: "cargo test | ubuntu"
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup component add llvm-tools-preview
|
|
|
|
- name: "Install cargo nextest"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: "Install cargo-llvm-cov"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
|
|
- name: "Install uv"
|
|
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
|
|
- name: "Install Python"
|
|
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: "Install Node.js"
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: npm
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- name: "Install Go"
|
|
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- name: "Install Lua"
|
|
uses: leafo/gh-actions-lua@8c9e175e7a3d77e21f809eefbee34a19b858641b
|
|
with:
|
|
luaVersion: ${{ env.LUA_VERSION }}
|
|
|
|
- name: "Install LuaRocks"
|
|
uses: leafo/gh-actions-luarocks@97053c556d6ce2c8e26eb7ac93743437c7af7248
|
|
with:
|
|
luaRocksVersion: ${{ env.LUAROCKS_VERSION }}
|
|
|
|
- name: "Cargo test"
|
|
run: |
|
|
cargo llvm-cov nextest \
|
|
--no-report \
|
|
--workspace \
|
|
--status-level skip \
|
|
--failure-output immediate \
|
|
--no-fail-fast \
|
|
-j 8 \
|
|
--final-status-level slow
|
|
|
|
cargo llvm-cov report --lcov --output-path lcov.info
|
|
|
|
- name: "Upload coverage reports to Codecov"
|
|
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: lcov.info
|
|
|
|
cargo-test-macos:
|
|
runs-on: macos-latest
|
|
name: "cargo test | macos"
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup show
|
|
|
|
- name: "Install cargo nextest"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: "Install uv"
|
|
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
|
|
- name: "Install Python"
|
|
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: "Install Node.js"
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: npm
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- name: "Install Go"
|
|
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- name: "Install Lua"
|
|
uses: leafo/gh-actions-lua@8c9e175e7a3d77e21f809eefbee34a19b858641b
|
|
with:
|
|
luaVersion: ${{ env.LUA_VERSION }}
|
|
|
|
- name: "Install LuaRocks"
|
|
uses: leafo/gh-actions-luarocks@97053c556d6ce2c8e26eb7ac93743437c7af7248
|
|
with:
|
|
luaRocksVersion: ${{ env.LUAROCKS_VERSION }}
|
|
|
|
- name: "Cargo test"
|
|
run: |
|
|
cargo nextest show-config test-groups
|
|
cargo nextest run \
|
|
--workspace \
|
|
--status-level skip \
|
|
--failure-output immediate \
|
|
--no-fail-fast \
|
|
-j 8 \
|
|
--final-status-level slow
|
|
|
|
cargo-test-windows:
|
|
runs-on: windows-latest
|
|
name: "cargo test | windows"
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- name: Create Dev Drive
|
|
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
|
|
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
|
|
- name: "Install Rust toolchain"
|
|
run: rustup component add llvm-tools-preview
|
|
|
|
- name: "Install cargo nextest"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: "Install cargo-llvm-cov"
|
|
uses: taiki-e/install-action@5ab30948b991e8d6aa5a6c1e33c6aea130c6de65 # v2.62.12
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
|
|
- name: "Install uv"
|
|
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
cache-local-path: ${{ env.DEV_DRIVE }}/uv-cache
|
|
|
|
- name: "Install Python"
|
|
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: "Install Node.js"
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: npm
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- name: "Install Go"
|
|
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
# A dummy dependency path to enable caching of go modules.
|
|
cache-dependency-path: LICENSE
|
|
|
|
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # windows only
|
|
- name: "Install Lua"
|
|
uses: luarocks/gh-actions-lua@989f8e6ffba55ce1817e236478c98558e598776c # windows only
|
|
with:
|
|
luaVersion: ${{ env.LUA_VERSION }}
|
|
|
|
- name: "Install LuaRocks"
|
|
uses: luarocks/gh-actions-luarocks@7c85eeff60655651b444126f2a78be784e836a0a # windows only
|
|
with:
|
|
luaRocksVersion: ${{ env.LUAROCKS_VERSION }}
|
|
|
|
- name: "Find node and npm versions"
|
|
run: |
|
|
Get-Command node -All
|
|
Get-Command npm -All
|
|
shell: pwsh
|
|
|
|
- name: "Cargo test"
|
|
run: |
|
|
cargo llvm-cov nextest `
|
|
--no-report `
|
|
--workspace `
|
|
--status-level skip `
|
|
--failure-output immediate `
|
|
--no-fail-fast `
|
|
-j 8 `
|
|
--final-status-level slow
|
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
cargo llvm-cov report --lcov --output-path lcov.info
|
|
shell: pwsh
|
|
|
|
- name: "Upload coverage reports to Codecov"
|
|
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: lcov.info
|