Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7da401093 | ||
|
|
ea9defd544 | ||
|
|
7cb7930e5c | ||
|
|
f6a193191b | ||
|
|
91c5b34b70 | ||
|
|
ddb18cfff9 | ||
|
|
329eb5fa43 | ||
|
|
56f0ba980e | ||
|
|
e2ab1c3836 | ||
|
|
d2db46a173 | ||
|
|
83dc934d7f | ||
|
|
601d02e82d | ||
|
|
2c7c51e283 | ||
|
|
9a022034a6 | ||
|
|
dc1022bc69 | ||
|
|
b4ab796093 | ||
|
|
b094471e7c | ||
|
|
885ad4bc41 | ||
|
|
c40b27b8f9 | ||
|
|
7619b10b9f | ||
|
|
a72a5f146c | ||
|
|
f0ceffbf58 | ||
|
|
c04b5a0b3e | ||
|
|
e10d0dcde7 | ||
|
|
52839d91bd | ||
|
|
5b5d0b578b | ||
|
|
02bec77bb9 | ||
|
|
67b2637704 | ||
|
|
cd04d1a926 | ||
|
|
242cf4bba9 | ||
|
|
8a64ff717c | ||
|
|
a8c1049914 | ||
|
|
c76d836532 | ||
|
|
07f5468cc3 | ||
|
|
1024265def | ||
|
|
faf2f9fd0a | ||
|
|
a183497a0a | ||
|
|
718071590b | ||
|
|
a1777f5838 | ||
|
|
b1824d4802 | ||
|
|
3d79b24531 | ||
|
|
9ec7e60cb6 | ||
|
|
fd3526da5f | ||
|
|
12331c384e | ||
|
|
dbeb1eb6a2 | ||
|
|
dad7ec15de | ||
|
|
02640563b4 | ||
|
|
3f82d5723e | ||
|
|
fe9ef8cc9c | ||
|
|
7ad7c57bed | ||
|
|
9ea5352c0f | ||
|
|
8a96988e48 |
15
.github/workflows/lint.yml
vendored
15
.github/workflows/lint.yml
vendored
@@ -8,18 +8,15 @@ env:
|
||||
jobs:
|
||||
lint:
|
||||
name: Check that code is lint clean using precious
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.email "jdoe@example.com"
|
||||
git config --global user.name "J. Doe"
|
||||
- name: Run install-dev-tools.sh
|
||||
- name: Install mise
|
||||
run: |
|
||||
set -e
|
||||
mkdir $HOME/bin
|
||||
./dev/bin/install-dev-tools.sh
|
||||
set -x
|
||||
curl https://mise.run | sh
|
||||
mise install
|
||||
- name: Run precious
|
||||
run: |
|
||||
PATH=$PATH:$HOME/bin precious lint -a
|
||||
mise exec -- precious lint -a
|
||||
|
||||
467
.github/workflows/test.yml
vendored
467
.github/workflows/test.yml
vendored
@@ -5,218 +5,286 @@ on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
test-action:
|
||||
name: Test action
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- platform_name: FreeBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
- name: FreeBSD-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-freebsd
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+FreeBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: false
|
||||
expect-file-re: "x86-64.+FreeBSD"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Linux-x86_64
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
# It's important to use a musl target here to make sure that the step to install
|
||||
# musl-tools works.
|
||||
target: x86_64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+x86-64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "ELF.+x86-64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-x86_64 (beta)
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
toolchain: beta
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "ELF.+x86-64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- name: Linux-x86_64 (nightly)
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
toolchain: nightly
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "ELF.+x86-64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- name: Linux-x86_64 (force cross)
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
force-use-cross: true
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "ELF.+x86-64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- name: Linux-x86_64 (stable 8 months ago)
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
toolchain: "stable 8 months ago"
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "ELF.+x86-64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- name: Linux-aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 (no cache)
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
- name: Linux-aarch64 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
- name: Linux-aarch64 with cross v0.2.3
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "v0.2.3"
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-cross-version: "0.2.3"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
- name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "v0.2.3"
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-cross-version: "0.2.3"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
- name: Linux-aarch64 with cross 19be834
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "19be834"
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-cross-version: "19be834"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
- name: Linux-aarch64 with cross 19be834 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "19be834"
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-cross-version: "19be834"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-arm
|
||||
os: ubuntu-20.04
|
||||
target: arm-unknown-linux-musleabi
|
||||
- name: Linux-aarch64 with arm64 host
|
||||
runs-on: ubuntu-24.04-arm
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+ARM"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-i586
|
||||
os: ubuntu-20.04
|
||||
target: i586-unknown-linux-musl
|
||||
# This fails because of some sort of weird bug in cross. See
|
||||
# https://github.com/cross-rs/cross/issues/1628 for more details. Until that's fixed
|
||||
# cross-compiling on Linux ARM won't work without a custom Docker image, which I don't
|
||||
# want to do just for the sake of testing this.
|
||||
#
|
||||
# - name: Linux-aarch64 with arm64 host compile to x86-64
|
||||
# runs-on: ubuntu-24.04-arm
|
||||
# target: x86_64-unknown-linux-gnu
|
||||
# # Until cross produces arm64 binary releases we _have_ to set this when running on
|
||||
# # arm64.
|
||||
# cross-version: "c7dee4d"
|
||||
# cache-cross-binary: true
|
||||
# expect-file-re: "ELF.+x86-64"
|
||||
# expect-cross: "--expect-cross"
|
||||
# expect-stripped: ""
|
||||
# can-execute: true
|
||||
|
||||
- name: Linux-arm
|
||||
runs-on: ubuntu-24.04
|
||||
target: arm-unknown-linux-gnueabi
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "32.+ARM"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-i686
|
||||
os: ubuntu-20.04
|
||||
target: i686-unknown-linux-musl
|
||||
- name: Linux-i586
|
||||
runs-on: ubuntu-24.04
|
||||
target: i586-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "ELF.+80386"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-i686
|
||||
runs-on: ubuntu-24.04
|
||||
target: i686-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "ELF.+80386"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- name: Linux-powerpc
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "32.+PowerPC"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-powerpc64
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "64.+PowerPC"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64le
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-powerpc64le
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc64le-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "64.+PowerPC"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-riscv64
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+RISC-V"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "64.+RISC-V"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-s390x
|
||||
os: ubuntu-20.04
|
||||
- name: Linux-s390x
|
||||
runs-on: ubuntu-24.04
|
||||
target: s390x-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+S/390"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "64.+S/390"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: NetBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
- name: NetBSD-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-netbsd
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+NetBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: false
|
||||
expect-file-re: "x86-64.+NetBSD"
|
||||
expect-cross: "--expect-cross"
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Windows-aarch64
|
||||
os: windows-latest
|
||||
- name: Windows-aarch64
|
||||
runs-on: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Aarch64.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: false
|
||||
expect-file-re: "Windows.+ARM64"
|
||||
expect-cross: ""
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Windows-i686
|
||||
os: windows-latest
|
||||
- name: Windows-i686
|
||||
runs-on: windows-latest
|
||||
target: i686-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "80386.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "Windows.+Intel i386"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Windows-x86_64
|
||||
os: windows-latest
|
||||
- name: Windows-x86_64
|
||||
runs-on: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+Windows"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "Windows.+x86-64"
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: macOS-x86_64
|
||||
os: macOS-latest
|
||||
- name: macOS-x86_64
|
||||
runs-on: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+x86_64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
expect-file-re: "Mach-O.+x86_64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: macOS-aarch64
|
||||
os: macOS-latest
|
||||
- name: macOS-aarch64
|
||||
runs-on: macOS-latest
|
||||
target: aarch64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+arm64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: false
|
||||
expect-file-re: "Mach-O.+arm64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: false
|
||||
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
runs-on: ${{ matrix.platform.runs-on }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -229,55 +297,144 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
command: both
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
if: ${{ matrix.platform.can-execute }}
|
||||
- name: Run test command
|
||||
uses: ./
|
||||
with:
|
||||
command: test
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
if: ${{ matrix.platform.can-execute }}
|
||||
- name: Run test command with args
|
||||
uses: ./
|
||||
with:
|
||||
command: test
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: "-- --ignored"
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
if: ${{ matrix.platform.can-execute }}
|
||||
- name: Run build command
|
||||
uses: ./
|
||||
with:
|
||||
command: build
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
strip: true
|
||||
- name: Check binary and cross for main crate on ${{ matrix.platform.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
set -x
|
||||
cargo run --manifest-path ./run-tests/Cargo.toml -- \
|
||||
--checkout-root "$PWD" \
|
||||
--target "${{ matrix.platform.target }}" \
|
||||
--expect-file-re "${{ matrix.platform.expect-file-re }}" \
|
||||
--expect-cross-version "${{ matrix.platform.expect-cross-version }}" \
|
||||
${{ matrix.platform.expect-cross }} \
|
||||
${{ matrix.platform.expect-stripped }}
|
||||
- name: Run build command for subdir
|
||||
uses: ./
|
||||
with:
|
||||
command: build
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
working-directory: subcrate
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
strip: true
|
||||
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||
- name: Check binary and cross for subcrate on ${{ matrix.platform.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
tests/check-binary.pl \
|
||||
set -e
|
||||
set -x
|
||||
cargo run --manifest-path ./run-tests/Cargo.toml -- \
|
||||
--checkout-root "$PWD" \
|
||||
--target "${{ matrix.platform.target }}" \
|
||||
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
|
||||
--expect-cross-version "${{ matrix.platform.expect_cross_version }}" \
|
||||
${{ matrix.platform.expect_cross }} \
|
||||
${{ matrix.platform.expect_stripped }}
|
||||
--expect-file-re "${{ matrix.platform.expect-file-re }}" \
|
||||
--expect-cross-version "${{ matrix.platform.expect-cross-version }}" \
|
||||
${{ matrix.platform.expect-cross }} \
|
||||
${{ matrix.platform.expect-stripped }} \
|
||||
--is-subcrate
|
||||
- name: Run bench command
|
||||
uses: ./
|
||||
with:
|
||||
command: bench
|
||||
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
working-directory: bench
|
||||
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can-execute }}
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-artifacts-${{ matrix.platform.name }}
|
||||
path: |
|
||||
target/${{ matrix.platform.target }}/debug/bin*
|
||||
subcrate/target/${{ matrix.platform.target }}/debug/subcrate
|
||||
|
||||
test-validate-inputs:
|
||||
name: Test validate-inputs
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: ./validate-inputs.py --test
|
||||
|
||||
test-other-cargo-commands:
|
||||
name: Test a "cargo foo" command
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Copy test project to root
|
||||
shell: bash
|
||||
run: |
|
||||
cp -a test-project/* .
|
||||
rm -fr test-project
|
||||
- name: Create cargo-foo command
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
dir="${{ github.workspace }}/bin"
|
||||
mkdir -p "$dir"
|
||||
|
||||
bin="$dir/cargo-foo"
|
||||
|
||||
echo "#!/bin/bash" >> "$bin"
|
||||
echo "echo 'This is cargo-foo!'" >> "$bin"
|
||||
echo "exit 0" >> "$bin"
|
||||
chmod 0755 "$bin"
|
||||
|
||||
echo "PATH=$dir:$PATH" >> "$GITHUB_ENV"
|
||||
- name: Run cargo-foo command
|
||||
uses: ./
|
||||
with:
|
||||
command: foo
|
||||
target: x86_64-unknown-linux-gnu
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,4 +3,5 @@
|
||||
/package.json
|
||||
.\#*
|
||||
\#*\#
|
||||
run-tests/**/target/**
|
||||
test-project/**/target/**
|
||||
|
||||
65
Changes.md
65
Changes.md
@@ -1,3 +1,68 @@
|
||||
## 1.0.4 - 2025-04-12
|
||||
|
||||
- Removed validation for the `toolchain` input. The
|
||||
[dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) accepts a lot of different
|
||||
options that this action wasn't allowing. It's simpler and more flexible to just let that action
|
||||
handle validation. Requested by @axos88 (Akos Vandra-Meyer). GH #42.
|
||||
- Removed validation for the `command` input. This allows you to use this action with any `cargo`
|
||||
extension command, like `cargo-deb`. Setting `command` to `both` is still supported and will run
|
||||
the `build` and `test` commands. Requested by @bvaisvil (Benjamin Vaisvil). GH #43.
|
||||
|
||||
## 1.0.3 - 2025-02-17
|
||||
|
||||
- Fixed a bug when running with a Linux ARM host where the action would use a cached `cross`
|
||||
download for x86-64 Linux (or vice versa). Now the cache key for the `cross` binary includes both
|
||||
the runner's architecture in addition to its OS.
|
||||
- This release partially support running on Linxu ARM, but see the `README.md` file for details on
|
||||
this.
|
||||
|
||||
## 1.0.2 - 2025-02-16
|
||||
|
||||
- Added a new `force-use-cross` input, which does what it says. It will force the use of `cross`
|
||||
even when it is not required for given platform/target combination. Note that this only works on
|
||||
Linux hosts.
|
||||
|
||||
## 1.0.1 - 2025-01-20
|
||||
|
||||
- Fixed a bug where this action would attempt to use `cross` when compiling for an ARM Linux target
|
||||
on an ARM Linux host.
|
||||
|
||||
## 1.0.0 - 2025-01-11
|
||||
|
||||
The addition of caching is a significant behavior change for this action, so the version has been
|
||||
bumped to v1.0.0 because of this change.
|
||||
|
||||
- This action will now configure and use `Swatinem/rust-cache` by default for you. It will include
|
||||
the `target` parameter as part of the cache key automatically, as well as the OS version when
|
||||
using `cargo` on Linux. Suggested by @jennydaman (Jennings Zhang). GH #23.
|
||||
- This action now validates its input and will exit early if they are not valid. GH #35.
|
||||
- When compiling for `musl` targets, this action will not try to reinstall the `musl-tools` package
|
||||
if it's already installed.
|
||||
|
||||
The following changes were made since the 1.0.0-beta1 release:
|
||||
|
||||
- The cache key includes information that causes the cache to not be re-used when the system running
|
||||
`cargo` or `cross` changes. When using `cargo` on Linux, this is the OS version, like "Ubuntu
|
||||
22.04". When using `cross`, this is the hash of the `cross` binary itself. This is needed because
|
||||
the Docker images that `cross` uses can change when the binary is updated. This can include
|
||||
changing the underlying Docker image base OS, in which case it's quite likely the old cache
|
||||
contents would be incompatible with the the new image.
|
||||
|
||||
## 1.0.0-beta1 - 2024-12-21
|
||||
|
||||
The addition of caching is a significant behavior change for this action, so the version has been
|
||||
bumped to v1.0.0 because of this change.
|
||||
|
||||
- This action will now configure and use `Swatinem/rust-cache` by default for you. It will include
|
||||
the `target` parameter as part of the cache key automatically. Suggested by @jennydaman (Jennings
|
||||
Zhang). GH #23.
|
||||
- This action now validates its inputs and will exit early if they are not valid. GH #35.
|
||||
|
||||
## 0.0.17 - 2024-11-23
|
||||
|
||||
- Added support for running `cargo bench` or `cross bench`. Implemented by @RaulTrombin (Raul Victor
|
||||
Trombin). GH #32.
|
||||
|
||||
## 0.0.16 - 2024-11-17
|
||||
|
||||
- Arguments passed in the `args` parameter are now always last when executing `cargo`. This lets you
|
||||
|
||||
152
README.md
152
README.md
@@ -14,20 +14,19 @@ jobs:
|
||||
matrix:
|
||||
platform:
|
||||
- os-name: FreeBSD-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-freebsd
|
||||
skip_tests: true
|
||||
|
||||
- os-name: Linux-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-aarch64
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-riscv64
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
|
||||
- os-name: Windows-x86_64
|
||||
@@ -43,9 +42,9 @@ jobs:
|
||||
runs-on: ${{ matrix.platform.runs-on }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
uses: houseabsolute/actions-rust-cross@v1
|
||||
with:
|
||||
command: ${{ matrix.platform.command }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
@@ -58,25 +57,51 @@ jobs:
|
||||
target: ${{ matrix.platform.target }}
|
||||
```
|
||||
|
||||
Note that for Linux or BSD targets, you should always set the `runs-on` key to an x86-64
|
||||
architecture runner. If you want to do native ARM compilation, for example using
|
||||
`ubuntu-latest-arm`, then there's no point in using this action. This action is only tested on
|
||||
Note that for Linux or BSD targets, you should always set the `runs-on` key to a Linux x86-64
|
||||
architecture runner.
|
||||
|
||||
If you _only_ want to do native ARM compilation, for example using the `ubuntu-24.04-arm` runner,
|
||||
then there's no need to use this action. However, if you want to compile for _many_ platforms,
|
||||
including Linux ARM, using this action will simplify your config. This action is only tested on
|
||||
Ubuntu x86-64, Windows, and macOS runners.
|
||||
|
||||
## Input Parameters
|
||||
|
||||
This action takes the following parameters:
|
||||
|
||||
| Key | Type | Required? | Description |
|
||||
| ------------------- | ---------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `command` | string (one of `build`, `test`, or `both`) | no | The command(s) to run. The default is `build`. Running the `test` command will fail with \*BSD targets and non-x86 Windows. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets found by running `rustup target list`. |
|
||||
| `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). |
|
||||
| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable`. |
|
||||
| `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. |
|
||||
| `args` | string | no | A string-separated list of arguments to be passed to `cross build`, like `--release --locked`. |
|
||||
| `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. |
|
||||
| Key | Type | Required? | Description |
|
||||
| ----------------------- | --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `command` | string | no | The command(s) to run. The default is `build`. Running the `test` command will fail with \*BSD targets and non-x86 Windows. You can use any command supported by `cargo` and/or `cross`. For example, if you install `cargo-deb`, the command can be `deb`. Use the special string "both" to run both `build` and `test. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets found by running `rustup target list`. |
|
||||
| `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). |
|
||||
| `toolchain` | string) | no | The Rust toolchain version to install. This is passed directly to [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain), which accepts many different options. See its documentation for more details. The default is `stable`. |
|
||||
| `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. |
|
||||
| `args` | string | no | A string-separated list of arguments to be passed to `cross build`, like `--release --locked`. |
|
||||
| `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. |
|
||||
| `force-use-cross` | boolean (`true` or `false`) | no | If this is true, then the action will use `cross` even if it is not needed for the given target. If this is set to `true`, then the resulting binary will not be stripped, regardless of whether `strip` is `true` or not. This only works on Linux hosts. Forcing the use of `cross` on other hosts is not supported. |
|
||||
| `use-rust-cache` | boolean | no | Whether or not to use [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). This defaults to true. |
|
||||
| `rust-cache-parameters` | string (containing JSON) | no | This must be a string containing valid JSON. The JSON should be an object where the keys are the parameters for [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). |
|
||||
|
||||
### Setting Environment Variables
|
||||
|
||||
By default, `cross` passes most rust-related environment variables through when it runs `cargo` in a
|
||||
Docker image. This means you can simply set an `env` key in the workflow step that uses this action.
|
||||
|
||||
```
|
||||
- name: Run build command
|
||||
uses: houseabsolute/actions-rust-cross@v1
|
||||
env:
|
||||
CARGO_LOG: debug
|
||||
RUSTFLAGS: "-g"
|
||||
with:
|
||||
command: build
|
||||
```
|
||||
|
||||
If you want to pass other environment variables through, you will need to configure `cross` to do
|
||||
see. See the
|
||||
[`cross` docs](https://github.com/cross-rs/cross/blob/main/docs/environment_variables.md#environment-variable-passthrough)
|
||||
for more details.
|
||||
|
||||
## How it Works
|
||||
|
||||
@@ -94,12 +119,85 @@ build `cross`.
|
||||
When compiling on Windows, it will do so in a Powershell environment, which can matter in some
|
||||
corner cases, like compiling the `openssl` crate with the `vendored` feature.
|
||||
|
||||
Finally, it will run `strip` to strip the binaries if the `strip` parameter is true. This is only
|
||||
possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64` cannot
|
||||
be stripped either.
|
||||
When running `cargo` on a Linux system, it will also include the output of running
|
||||
`lsb_release --short --description` in the cache key. This is important for crates that link against
|
||||
system libraries. If those library versions change across OS versions (e.g. Ubuntu 20.04 to 22.04),
|
||||
then the cache will be broken for these cases.
|
||||
|
||||
## Caching Rust Compilation Output
|
||||
When running `cross`, the hash of the `cross` binary will be included in the cache key. This is done
|
||||
because the Docker images that `cross` uses can change when `cross` is updated. We want to make sure
|
||||
that we do not re-use the cache across changes when these images change.
|
||||
|
||||
You can use the [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) action with this one
|
||||
seamlessly, whether or not a specific build target needs `cross`. There is no special configuration
|
||||
that you need for this. It just works.
|
||||
Finally, it will run `strip` to strip the binaries it builds if the `strip` parameter is true. This
|
||||
is only possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64`
|
||||
cannot be stripped either.
|
||||
|
||||
### Caching
|
||||
|
||||
By default, this action will use
|
||||
[the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache) to cache compiled
|
||||
dependencies for a crate. Note that per the documentation for the `rust-cache` action, it has fairly
|
||||
limited value for crates without a `Cargo.lock` file. The `key` parameter passed to this action will
|
||||
always include the value of the `target` input. If you specify a `key` parameter in
|
||||
`rust-cache-parameters`, then the `target` input will be appended to the value you specify.
|
||||
|
||||
#### Weird Caching Issue with Multiple Crates
|
||||
|
||||
In my testing, it seemed like in some cases restoring the cache would delete existing files in a
|
||||
`target` directory. This manifested with this sequence of actions:
|
||||
|
||||
1. Run `actions-rust-cross` to compile a crate in a top-level directory.
|
||||
2. Run `actions-rust-cross` to compile a crate in a subdirectory.
|
||||
|
||||
After step 2, the compiled binaries from step 1 were no longer present, _sometimes_. I'm not sure
|
||||
exactly what's going on here, but my recommendation is to structure your workflows so that this
|
||||
cannot affect you.
|
||||
|
||||
For example, if you have multiple crates, each of which builds a binary you want to release, then
|
||||
you can avoid this issue by structuring your workflow as follows:
|
||||
|
||||
1. Run `actions-rust-cross` to compile crate A.
|
||||
2. Run the release steps for crate A.
|
||||
3. Run `actions-rust-cross` to compile crate B.
|
||||
4. Run the release steps for crate B.
|
||||
|
||||
When structured this way, it does not matter if the output of crate A is deleted in step 3.
|
||||
|
||||
## Cross-Compiling from Linux ARM Runners
|
||||
|
||||
In theory, this should work, and this action does implement some of the necessary work for this.
|
||||
However, there are a couple issues with this:
|
||||
|
||||
1. As of 2025-02-17, the `cross` project does not publish Linux ARM binary releases. That means that
|
||||
in order to use `cross` on a Linux ARM runner as part of this action, you must set
|
||||
`cross-version` to a more recent commit from the `cross` repo.
|
||||
2. There is
|
||||
[a bug in `cross` that means you must use a custom Docker image](https://github.com/cross-rs/cross/issues/1628)
|
||||
when cross-compiling from a Linux ARM runner. See
|
||||
[this other `cross` issue](https://github.com/cross-rs/cross/issues/751) for more details.
|
||||
|
||||
## Linting and Tidying this Code
|
||||
|
||||
The code in this repo is linted and tidied with
|
||||
[`precious`](https://github.com/houseabsolute/precious). This repo contains a `mise.toml` file.
|
||||
[Mise](https://mise.jdx.dev/) is a tool for managing dev tools with per-repo configuration. You can
|
||||
install `mise` and use it to run `precious` as follows:
|
||||
|
||||
```
|
||||
# Installs mise
|
||||
curl https://mise.run | sh
|
||||
# Installs precious and other dev tools
|
||||
mise install
|
||||
```
|
||||
|
||||
Once this is done, you can run `precious` via `mise`:
|
||||
|
||||
```
|
||||
# Lints all code
|
||||
mise exec -- precious lint -a
|
||||
# Tidies all code
|
||||
mise exec -- precious tidy -a
|
||||
```
|
||||
|
||||
If you want to use `mise` for other projects, see [its documentation](https://mise.jdx.dev/) for
|
||||
more details on how you can configure your shell to always activate `mise`.
|
||||
|
||||
164
action.yml
164
action.yml
@@ -1,61 +1,121 @@
|
||||
name: "Build Rust Projects with Cross"
|
||||
author: "Dave Rolsky <autarch@urth.org>"
|
||||
|
||||
branding:
|
||||
icon: home
|
||||
color: gray-dark
|
||||
|
||||
description: |
|
||||
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
||||
|
||||
inputs:
|
||||
working-directory:
|
||||
description: The working directory for each step
|
||||
default: "."
|
||||
command:
|
||||
description: |
|
||||
The commands to run (one of "build", "test", or "both").
|
||||
default: build
|
||||
target:
|
||||
description: The target platform
|
||||
required: true
|
||||
|
||||
command:
|
||||
description: |
|
||||
The commands to run. Use "both" to run both "build" and "test".
|
||||
default: build
|
||||
|
||||
toolchain:
|
||||
description: |
|
||||
The target toolchain to use (one of "stable", "beta", or "nightly").
|
||||
The target toolchain to use.
|
||||
default: stable
|
||||
|
||||
working-directory:
|
||||
description: The working directory for each step
|
||||
default: "."
|
||||
|
||||
GITHUB_TOKEN:
|
||||
description: |
|
||||
A GitHub token, available in the secrets.GITHUB_TOKEN working-directory variable.
|
||||
default: ${{ github.token }}
|
||||
|
||||
args:
|
||||
description: |
|
||||
The arguments to be passed to cross or cargo when building, as a
|
||||
space-separated string.
|
||||
default: ""
|
||||
|
||||
strip:
|
||||
description: Strip the compiled binary
|
||||
default: false
|
||||
|
||||
cross-version:
|
||||
description: |
|
||||
The version of cross to use. If not specified, then the latest version
|
||||
will be used.
|
||||
|
||||
cache-cross-binary:
|
||||
description: |
|
||||
Cache the cross binary if one is installed. This is primarily for use in
|
||||
tests of this action.
|
||||
default: true
|
||||
|
||||
force-use-cross:
|
||||
description: |
|
||||
If this is true, the action will use cross even for targets where it is not needed.
|
||||
default: false
|
||||
|
||||
use-rust-cache:
|
||||
description: |
|
||||
Use `Swatinem/rust-cache@v2`. Defaults to true.
|
||||
default: true
|
||||
|
||||
rust-cache-parameters:
|
||||
description: |
|
||||
A JSON string containing parameters to pass to `Swatinem/rust-cache@v2`. You can use the
|
||||
`toJSON()` function in your action to make passing this easier.
|
||||
default: "{}"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Show inputs
|
||||
shell: bash
|
||||
run: |
|
||||
echo '${{ toJSON(inputs) }}'
|
||||
|
||||
- name: Add this action's path to PATH
|
||||
shell: bash
|
||||
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
||||
|
||||
- name: Validate inputs
|
||||
shell: bash
|
||||
run: |
|
||||
"${{ github.action_path }}"/validate-inputs.py "${{ github.workspace }}"
|
||||
env:
|
||||
INPUTS_target: ${{ inputs.target }}
|
||||
INPUTS_command: ${{ inputs.command }}
|
||||
INPUTS_toolchain: ${{ inputs.toolchain }}
|
||||
INPUTS_working_directory: ${{ inputs.working-directory }}
|
||||
INPUTS_strip: ${{ inputs.strip }}
|
||||
INPUTS_cache_cross_binary: ${{ inputs.cache-cross-binary }}
|
||||
INPUTS_force_use_cross: ${{ inputs.force-use-cross }}
|
||||
INPUTS_use_rust_cache: ${{ inputs.use-rust-cache }}
|
||||
INPUTS_rust_cache_parameters: ${{ inputs.rust-cache-parameters }}
|
||||
|
||||
- name: Determine whether we need to cross-compile
|
||||
id: determine-cross-compile
|
||||
shell: bash
|
||||
run: set-cross-compile.sh ${{ inputs.target }}
|
||||
run: set-cross-compile.py ${{ inputs.target }} ${{ inputs.force-use-cross }}
|
||||
|
||||
- name: Install toolchain
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
targets: ${{ inputs.target }}
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
|
||||
- name: Install qemu-user emulator binaries if cross-compiling on arm64 host
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os == 'Linux' && contains(runner.arch, 'ARM')
|
||||
|
||||
- name: Determine cross version
|
||||
id: determine-cross-version
|
||||
shell: bash
|
||||
@@ -63,6 +123,7 @@ runs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
|
||||
# We need to access this in both this YAML config and shell scripts. It
|
||||
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||
- name: Set directory for installing cross
|
||||
@@ -70,55 +131,96 @@ runs:
|
||||
shell: bash
|
||||
run: set-cross-dir.sh
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
|
||||
- name: Cache cross
|
||||
id: cache-cross
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
||||
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install musl-tools on Linux if target includes "musl"
|
||||
shell: bash
|
||||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
|
||||
run: |
|
||||
if dpkg -l musl-tools | grep -q "^ii\s*musl-tools"; then
|
||||
exit 0
|
||||
fi
|
||||
sudo apt-get update --yes && \
|
||||
sudo apt-get install --yes musl-tools
|
||||
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
||||
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||
- name: Run tests (*nix)
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
|
||||
- name: Determine which cargo commands to run
|
||||
id: determine-cargo-commands
|
||||
shell: bash
|
||||
run: determine-cargo-commands.sh ${{ inputs.command }}
|
||||
|
||||
- name: Parse `rust-cache-parameters` and set inputs for `Swatinem/rust-cache@v2`
|
||||
id: parse-rust-cache-parameters
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: inputs.command != 'build' && runner.os != 'Windows'
|
||||
# We want to run in Powershell on Windows to make sure we compile in a
|
||||
# native Windows environment. Some things won't compile properly under
|
||||
# msys, notably OpenSSL, which is compiled locally when using the
|
||||
# `openssl` crate with the `vendored` feature.
|
||||
- name: Run tests (Windows)
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
OS_VERSION=""
|
||||
if [ -x /usr/bin/lsb_release ]; then
|
||||
# This will be something like "Ubuntu 22.04.5 LTS"
|
||||
OS_VERSION="$( lsb_release --short --description )"
|
||||
fi
|
||||
# This will get the inputs JSON from the `RUST_CACHE_PARAMETERS` env var. This avoids
|
||||
# any string interpolation issues, since the inputs will contain quotes.
|
||||
parse-and-set-rust-cache-parameters.py "${{ inputs.target }}" "${{ steps.set-build-command.outputs.build-command }}" "$OS_VERSION"
|
||||
env:
|
||||
RUST_CACHE_PARAMETERS: ${{ inputs.rust-cache-parameters }}
|
||||
if: inputs.use-rust-cache == 'true'
|
||||
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with: ${{ steps.parse-rust-cache-parameters.outputs }}
|
||||
if: inputs.use-rust-cache == 'true'
|
||||
|
||||
- name: Run cargo test
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: inputs.command != 'build' && runner.os == 'Windows'
|
||||
- name: Build binary (*nix)
|
||||
${{ steps.set-build-command.outputs.build-command }} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.test == 'true'
|
||||
|
||||
- name: Run cargo build
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: inputs.command != 'test' && runner.os != 'Windows'
|
||||
- name: Build binary (Windows)
|
||||
${{ steps.set-build-command.outputs.build-command }} build --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.build == 'true'
|
||||
|
||||
- name: Run cargo ${{ steps.determine-cargo-commands.outputs.command }}
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: inputs.command != 'test' && runner.os == 'Windows'
|
||||
${{ steps.set-build-command.outputs.build-command }} ${{ steps.determine-cargo-commands.outputs.command }} --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.command != ''
|
||||
|
||||
- name: Strip binary
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
|
||||
13
determine-cargo-commands.sh
Executable file
13
determine-cargo-commands.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
COMMAND="$1"
|
||||
if [ "$COMMAND" == 'both' ]; then
|
||||
echo "build=true" >>"$GITHUB_OUTPUT"
|
||||
echo "test=true" >>"$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "command=$COMMAND" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
set -x
|
||||
|
||||
function run() {
|
||||
echo "$1"
|
||||
eval "$1"
|
||||
}
|
||||
|
||||
function install_tools() {
|
||||
curl --silent --location \
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
sh
|
||||
run "ubi --project houseabsolute/precious --in $HOME/bin"
|
||||
run "ubi --project houseabsolute/omegasort --in $HOME/bin"
|
||||
run "ubi --project koalaman/shellcheck --in $HOME/bin"
|
||||
run "ubi --project mvdan/sh --in $HOME/bin --exe shfmt"
|
||||
run "ubi --project crate-ci/typos --in $HOME/bin"
|
||||
run "npm install prettier"
|
||||
run "curl -L https://cpanmin.us/ -o $HOME/bin/cpanm"
|
||||
run "chmod 0755 $HOME/bin/cpanm"
|
||||
run "$HOME/bin/cpanm --sudo --notest Perl::Tidy"
|
||||
}
|
||||
|
||||
if [ "$1" == "-v" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME"/bin
|
||||
|
||||
set +e
|
||||
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >&/dev/null
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" -eq "0" ]; then
|
||||
path_has_home_bin=1
|
||||
fi
|
||||
set -e
|
||||
|
||||
if [ -z "$path_has_home_bin" ]; then
|
||||
PATH=$HOME/bin:$PATH
|
||||
fi
|
||||
|
||||
install_tools
|
||||
|
||||
echo "Tools were installed into $HOME/bin."
|
||||
if [ -z "$path_has_home_bin" ]; then
|
||||
echo "You should add $HOME/bin to your PATH."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
52
git/setup.py
Executable file
52
git/setup.py
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This code was mostly written by Claude.ai.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""
|
||||
Main entry point to create a pre-commit hook symlink.
|
||||
"""
|
||||
symlink_hook("pre-commit")
|
||||
|
||||
|
||||
def symlink_hook(hook: str) -> None:
|
||||
"""
|
||||
Create a symlink for a Git hook if it doesn't already exist.
|
||||
|
||||
Args:
|
||||
hook: Name of the Git hook (e.g., 'pre-commit')
|
||||
"""
|
||||
# Path to the hook in .git/hooks
|
||||
dot_hook_path = os.path.join(".git", "hooks", hook)
|
||||
|
||||
# Path to the actual hook script
|
||||
file_hook_path = os.path.join("git", "hooks", f"{hook}.sh")
|
||||
|
||||
# Relative symlink path
|
||||
link_path = os.path.join("..", "..", file_hook_path)
|
||||
|
||||
# Check if the hook already exists
|
||||
if os.path.exists(dot_hook_path):
|
||||
# If it's already a symlink, check if it points to the correct location
|
||||
if os.path.islink(dot_hook_path):
|
||||
# If the existing symlink is correct, do nothing
|
||||
if os.readlink(dot_hook_path) == link_path:
|
||||
return
|
||||
|
||||
# If a hook exists and is not the expected symlink, warn and exit
|
||||
print(f"You already have a hook at {dot_hook_path}!", file=sys.stderr)
|
||||
return
|
||||
|
||||
# Create the symlink
|
||||
try:
|
||||
os.symlink(link_path, dot_hook_path)
|
||||
except OSError as e:
|
||||
print(f"Error creating symlink: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
10
mise.toml
Normal file
10
mise.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[tools]
|
||||
node = "22.11.0"
|
||||
"npm:prettier" = "3.4.1"
|
||||
ruff = "0.8.3"
|
||||
shellcheck = "0.10.0"
|
||||
shfmt = "v3.10.0"
|
||||
taplo = "0.9.3"
|
||||
typos = "1.28.1"
|
||||
"ubi:houseabsolute/omegasort" = "v0.1.3"
|
||||
"ubi:houseabsolute/precious" = "v0.7.3"
|
||||
49
parse-and-set-rust-cache-parameters.py
Executable file
49
parse-and-set-rust-cache-parameters.py
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
|
||||
def main():
|
||||
target = sys.argv[1]
|
||||
build_command = sys.argv[2]
|
||||
|
||||
os_version = sys.argv[3]
|
||||
|
||||
parameters = json.loads(os.environ["RUST_CACHE_PARAMETERS"])
|
||||
if "key" not in parameters:
|
||||
parameters["key"] = target
|
||||
else:
|
||||
parameters["key"] += "-{}".format(target)
|
||||
|
||||
if build_command == "cargo":
|
||||
# If we're running cargo, we need to add the OS version to the cache. Otherwise things that link
|
||||
# against system packages, like openssl, can break when we use the same cache across different
|
||||
# versions of the runner OS. For example, when going from Ubuntu 20.04 to 22.04, we move from
|
||||
# OpenSSL 1.1.x to 3.x.
|
||||
parameters["key"] += "-{}".format(os_version)
|
||||
else:
|
||||
# Otherwise we want to include the `cross` binary's hash. The Docker images that `cross`
|
||||
# uses can change when the binary is updated. This protects us from using the same cache
|
||||
# inside containers that have changed.
|
||||
parameters["key"] += "-cross-binary-hash-{}".format(
|
||||
get_file_hash(build_command)
|
||||
)
|
||||
|
||||
file = os.environ["GITHUB_OUTPUT"]
|
||||
with open(file, "w") as f:
|
||||
for key, value in parameters.items():
|
||||
f.write(f"{key}={value}")
|
||||
|
||||
|
||||
def get_file_hash(build_command):
|
||||
with open(build_command, "rb") as f:
|
||||
file_hash = hashlib.sha256()
|
||||
while chunk := f.read(65536):
|
||||
file_hash.update(chunk)
|
||||
return file_hash.hexdigest()
|
||||
|
||||
|
||||
main()
|
||||
@@ -3,6 +3,80 @@ exclude = [
|
||||
"tests/lib/**/*",
|
||||
]
|
||||
|
||||
[commands.clippy]
|
||||
type = "lint"
|
||||
include = "**/*.rs"
|
||||
invoke = "once"
|
||||
path-args = "none"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = [
|
||||
"cargo",
|
||||
"clippy",
|
||||
"--color",
|
||||
"always",
|
||||
"--locked",
|
||||
"--all-targets",
|
||||
"--all-features",
|
||||
"--",
|
||||
"-D",
|
||||
"clippy::pedantic",
|
||||
]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 101
|
||||
expect_stderr = true
|
||||
labels = ["default"]
|
||||
|
||||
[commands."clippy --fix"]
|
||||
type = "tidy"
|
||||
include = "**/*.rs"
|
||||
invoke = "once"
|
||||
path-args = "none"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = [
|
||||
"cargo",
|
||||
"clippy",
|
||||
"--fix",
|
||||
"--allow-dirty",
|
||||
"--locked",
|
||||
"--all-targets",
|
||||
"--all-features",
|
||||
"--",
|
||||
"-D",
|
||||
"clippy::pedantic",
|
||||
]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 101
|
||||
expect_stderr = true
|
||||
labels = ["default"]
|
||||
|
||||
[commands.rustfmt]
|
||||
type = "both"
|
||||
include = "**/*.rs"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = ["rustfmt", "--edition", "2021"]
|
||||
lint_flags = "--check"
|
||||
ok_exit_codes = [0]
|
||||
lint_failure_exit_codes = [1]
|
||||
labels = ["default", "fast-tidy"]
|
||||
|
||||
[commands."ruff for linting"]
|
||||
type = "both"
|
||||
include = [ "**/*.py" ]
|
||||
cmd = "ruff"
|
||||
lint_flags = [ "check" ]
|
||||
tidy_flags = [ "check", "--fix" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
[commands."ruff for tidying"]
|
||||
type = "both"
|
||||
include = [ "**/*.py" ]
|
||||
cmd = "ruff"
|
||||
lint_flags = [ "format", "--check" ]
|
||||
tidy_flags = [ "format" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
[commands.typos]
|
||||
type = "both"
|
||||
include = "**/*"
|
||||
@@ -13,21 +87,10 @@ tidy_flags = "--write-changes"
|
||||
ok-exit-codes = 0
|
||||
lint-failure-exit-codes = 2
|
||||
|
||||
[commands.perltidy]
|
||||
type = "both"
|
||||
include = [ "**/*.{pl,pm,t,psgi}" ]
|
||||
exclude = "tests/lib/**"
|
||||
cmd = [ "perltidy", "--profile=$PRECIOUS_ROOT/perltidyrc" ]
|
||||
lint_flags = [ "--assert-tidy", "--no-standard-output", "--outfile=/dev/null" ]
|
||||
tidy_flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 2
|
||||
ignore_stderr = "Begin Error Output Stream"
|
||||
|
||||
[commands.prettier-md]
|
||||
type = "both"
|
||||
include = [ "**/*.md" ]
|
||||
cmd = [ "./node_modules/.bin/prettier", "--no-config", "--print-width", "100", "--prose-wrap", "always" ]
|
||||
cmd = [ "prettier", "--no-config", "--print-width", "100", "--prose-wrap", "always" ]
|
||||
lint_flags = "--check"
|
||||
tidy_flags = "--write"
|
||||
ok_exit_codes = 0
|
||||
@@ -37,7 +100,7 @@ ignore_stderr = [ "Code style issues" ]
|
||||
[commands.prettier-yml]
|
||||
type = "both"
|
||||
include = [ "**/*.yml" ]
|
||||
cmd = [ "./node_modules/.bin/prettier", "--no-config" ]
|
||||
cmd = [ "prettier", "--no-config" ]
|
||||
lint_flags = "--check"
|
||||
tidy_flags = "--write"
|
||||
ok_exit_codes = 0
|
||||
|
||||
314
run-tests/Cargo.lock
generated
Normal file
314
run-tests/Cargo.lock
generated
Normal file
@@ -0,0 +1,314 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_executable"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "run-tests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"is_executable",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
9
run-tests/Cargo.toml
Normal file
9
run-tests/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "run-tests"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.23", features = ["derive"] }
|
||||
is_executable = "1.0.4"
|
||||
regex = "1.11.1"
|
||||
168
run-tests/src/main.rs
Normal file
168
run-tests/src/main.rs
Normal file
@@ -0,0 +1,168 @@
|
||||
// Mostly written by Claude.ai.
|
||||
|
||||
use clap::Parser;
|
||||
use is_executable::is_executable;
|
||||
use regex::Regex;
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(long)]
|
||||
checkout_root: String,
|
||||
#[arg(long)]
|
||||
target: String,
|
||||
#[arg(long)]
|
||||
expect_file_re: Option<String>,
|
||||
#[arg(long)]
|
||||
expect_cross: bool,
|
||||
#[arg(long)]
|
||||
expect_cross_version: Option<String>,
|
||||
#[arg(long)]
|
||||
expect_stripped: bool,
|
||||
#[arg(long)]
|
||||
is_subcrate: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let runner_temp = env::var("RUNNER_TEMP").expect("RUNNER_TEMP is not set");
|
||||
let runner_temp_path = PathBuf::from(runner_temp);
|
||||
|
||||
check_cross(
|
||||
&runner_temp_path,
|
||||
args.expect_cross,
|
||||
args.expect_cross_version.as_deref(),
|
||||
);
|
||||
|
||||
let checkout_root_path = PathBuf::from(args.checkout_root);
|
||||
let bin_paths = if args.is_subcrate {
|
||||
vec![checkout_root_path
|
||||
.join("subcrate")
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("subcrate")]
|
||||
} else {
|
||||
vec![
|
||||
checkout_root_path
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("bin1"),
|
||||
checkout_root_path
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("bin2"),
|
||||
]
|
||||
};
|
||||
|
||||
for mut bin_path in bin_paths {
|
||||
if cfg!(windows) {
|
||||
bin_path.set_extension("exe");
|
||||
}
|
||||
check_binary(
|
||||
&bin_path,
|
||||
args.expect_file_re.as_deref(),
|
||||
args.expect_stripped,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_cross(bin_dir: &Path, expect_cross: bool, expect_cross_version: Option<&str>) {
|
||||
let cross_path = bin_dir.join("cross");
|
||||
|
||||
if expect_cross {
|
||||
assert!(
|
||||
cross_path.is_file(),
|
||||
"`cross` exists at {}",
|
||||
cross_path.display()
|
||||
);
|
||||
|
||||
if let Some(expected_version) = expect_cross_version {
|
||||
let output = Command::new(&cross_path)
|
||||
.arg("--version")
|
||||
.output()
|
||||
.expect("Failed to execute `cross` command");
|
||||
let version = String::from_utf8(output.stdout)
|
||||
.expect("`cross --version` stdout was not valid UTF-8");
|
||||
assert!(
|
||||
version.contains(expected_version),
|
||||
"`cross` version matches expected version: {expected_version}",
|
||||
);
|
||||
}
|
||||
} else {
|
||||
assert!(!cross_path.exists(), "`cross` was not downloaded");
|
||||
}
|
||||
}
|
||||
|
||||
fn check_binary(bin_path: &PathBuf, expect_file_re: Option<&str>, expect_stripped: bool) {
|
||||
assert!(bin_path.exists(), "Binary at {} exists", bin_path.display());
|
||||
assert!(
|
||||
bin_path.is_file(),
|
||||
"Binary at {} is a file",
|
||||
bin_path.display()
|
||||
);
|
||||
|
||||
assert!(
|
||||
is_executable(bin_path),
|
||||
"Binary at {} is executable",
|
||||
bin_path.display()
|
||||
);
|
||||
|
||||
let output = Command::new("file")
|
||||
.arg("--brief")
|
||||
.arg(bin_path)
|
||||
.output()
|
||||
.expect("Failed to execute `file` command");
|
||||
let file_output = String::from_utf8_lossy(&output.stdout);
|
||||
println!(
|
||||
"output from `file` for {}: {file_output}",
|
||||
bin_path.display(),
|
||||
);
|
||||
|
||||
if let Some(file_re) = expect_file_re {
|
||||
let re = Regex::new(file_re).expect("Invalid regex");
|
||||
assert!(
|
||||
re.is_match(&file_output),
|
||||
"`file` output for {} matches `{file_re}`: `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
}
|
||||
|
||||
// `file` on macOS doesn't report if the binary is stripped.
|
||||
if cfg!(target_os = "macos") {
|
||||
return;
|
||||
}
|
||||
|
||||
if expect_stripped {
|
||||
assert!(
|
||||
!file_output.contains("not stripped"),
|
||||
"`file` does not report {} as 'not stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
assert!(
|
||||
file_output.contains("stripped"),
|
||||
"`file` reports {} as 'stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
} else if cfg!(windows) {
|
||||
assert!(
|
||||
!file_output.contains("stripped"),
|
||||
"`file` does not report {} as 'stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
file_output.contains("not stripped"),
|
||||
"`file` reports {} as 'not stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
}
|
||||
}
|
||||
109
set-cross-compile.py
Executable file
109
set-cross-compile.py
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Written mostly by Claude.ai based on my original bash script.
|
||||
|
||||
import sys
|
||||
import platform
|
||||
import re
|
||||
import os
|
||||
from subprocess import run, PIPE, CalledProcessError
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""
|
||||
Main function to determine cross-compilation requirements.
|
||||
|
||||
Returns:
|
||||
Exit code (0 for success)
|
||||
"""
|
||||
if len(sys.argv) < 3:
|
||||
print(
|
||||
"Error: Target architecture and force cross arguments are required",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
target = sys.argv[1]
|
||||
force_use_cross = sys.argv[2]
|
||||
if force_use_cross == "true":
|
||||
needs_cross = True
|
||||
else:
|
||||
needs_cross = check_needs_cross(target)
|
||||
|
||||
write_github_output(needs_cross)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def check_needs_cross(target: str) -> bool:
|
||||
"""
|
||||
Determine if cross-compilation is needed based on system and target.
|
||||
|
||||
Args:
|
||||
target: Target architecture string
|
||||
|
||||
Returns:
|
||||
Boolean indicating if cross-compilation is needed
|
||||
"""
|
||||
system_info = get_uname_info().lower()
|
||||
|
||||
# Check if we're on macOS or Windows
|
||||
if any(os in system_info for os in ["darwin", "msys", "windows"]):
|
||||
return False
|
||||
|
||||
target = target.lower()
|
||||
|
||||
# Check for x86_64 Linux targets on x86_64 Linux host
|
||||
if (
|
||||
re.search(r"x86_64.+linux-(?:gnu|musl)", target)
|
||||
and "x86_64" in system_info
|
||||
and "linux" in system_info
|
||||
):
|
||||
return False
|
||||
|
||||
# It's tempting to not use cross when the host is Linux x86-64 and we're compiling for Linux
|
||||
# i586 or i686. This sort of works, but if there's any C being compiled, things get weird,
|
||||
# because then we need 32-bit C headers, 32-bit C libs to link to, etc.
|
||||
|
||||
# Check if both host and target are ARM Linux. I'm assuming here that for things like
|
||||
# "arm-linux-androideabi" or "armv7-unknown-linux-ohos" we'd still need cross.
|
||||
if (
|
||||
re.search(r"(?:aarch64|arm).+linux-(?:gnu|musl)", target)
|
||||
and ("arm" in system_info or "aarch64" in system_info)
|
||||
and "linux" in system_info
|
||||
):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_uname_info() -> str:
|
||||
"""
|
||||
Get system information using uname command.
|
||||
|
||||
Returns:
|
||||
String containing system information
|
||||
"""
|
||||
try:
|
||||
result = run(["uname", "-a"], check=True, text=True, stdout=PIPE)
|
||||
return result.stdout
|
||||
except (CalledProcessError, FileNotFoundError):
|
||||
# Fallback to platform.platform() if uname is not available
|
||||
return platform.platform()
|
||||
|
||||
|
||||
def write_github_output(needs_cross: bool) -> None:
|
||||
"""
|
||||
Write the needs-cross output to GITHUB_OUTPUT environment variable file.
|
||||
|
||||
Args:
|
||||
needs_cross: Boolean indicating if cross-compilation is needed
|
||||
"""
|
||||
github_output = os.getenv("GITHUB_OUTPUT")
|
||||
if github_output:
|
||||
with open(github_output, "a") as f:
|
||||
f.write(f"needs-cross={str(needs_cross).lower()}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
TARGET="$1"
|
||||
|
||||
# On macOS and Windows, we can cross-compile to all possible targets without
|
||||
# using cross.
|
||||
if uname -a | grep --quiet --extended-regexp -i "darwin|msys|windows"; then
|
||||
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# On Linux, we should be able to cross-compile to i586 and i686, but in
|
||||
# practice this fails with some crates, notably openssl with the "vendored"
|
||||
# feature. This feature makes it compile openssl itself, which fails without
|
||||
# cross.
|
||||
if echo "$TARGET" | grep --quiet --extended-regexp -i 'x86_64.+linux-(gnu|musl)'; then
|
||||
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "needs-cross=true" >>"$GITHUB_OUTPUT"
|
||||
@@ -19,7 +19,7 @@ path = "src/bin2.rs"
|
||||
[package.metadata.cross.target.x86_64-unknown-netbsd]
|
||||
pre-build = [
|
||||
"mkdir -p /tmp/netbsd",
|
||||
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"curl https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"tar -C /tmp/netbsd -xJf base.tar.xz",
|
||||
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
|
||||
"rm base.tar.xz",
|
||||
|
||||
651
test-project/bench/Cargo.lock
generated
Normal file
651
test-project/bench/Cargo.lock
generated
Normal file
@@ -0,0 +1,651 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anes"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "bench"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "ciborium"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
|
||||
dependencies = [
|
||||
"ciborium-io",
|
||||
"ciborium-ll",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-io"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-ll"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
|
||||
dependencies = [
|
||||
"ciborium-io",
|
||||
"half",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "criterion"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb"
|
||||
dependencies = [
|
||||
"anes",
|
||||
"atty",
|
||||
"cast",
|
||||
"ciborium",
|
||||
"clap",
|
||||
"criterion-plot",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"oorandom",
|
||||
"plotters",
|
||||
"rayon",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"tinytemplate",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "criterion-plot"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||
dependencies = [
|
||||
"cast",
|
||||
"itertools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.164"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "oorandom"
|
||||
version = "11.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"plotters-backend",
|
||||
"plotters-svg",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "plotters-backend"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
|
||||
|
||||
[[package]]
|
||||
name = "plotters-svg"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670"
|
||||
dependencies = [
|
||||
"plotters-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.133"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
|
||||
|
||||
[[package]]
|
||||
name = "tinytemplate"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
11
test-project/bench/Cargo.toml
Normal file
11
test-project/bench/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "bench"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.4"
|
||||
|
||||
[[bench]]
|
||||
name = "benchmark"
|
||||
harness = false
|
||||
16
test-project/bench/benches/benchmark.rs
Normal file
16
test-project/bench/benches/benchmark.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
fn fibonacci(n: u64) -> u64 {
|
||||
match n {
|
||||
0 => 1,
|
||||
1 => 1,
|
||||
n => fibonacci(n - 1) + fibonacci(n - 2),
|
||||
}
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
1
test-project/bench/lib.rs
Normal file
1
test-project/bench/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
[package.metadata.cross.target.x86_64-unknown-netbsd]
|
||||
pre-build = [
|
||||
"mkdir -p /tmp/netbsd",
|
||||
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"curl https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"tar -C /tmp/netbsd -xJf base.tar.xz",
|
||||
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
|
||||
"rm base.tar.xz",
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use v5.30;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'experimental::signatures';
|
||||
use feature 'signatures';
|
||||
use autodie;
|
||||
|
||||
use FindBin qw( $Bin );
|
||||
use File::Spec;
|
||||
use lib File::Spec->catdir( $Bin, 'lib' );
|
||||
|
||||
use Getopt::Long;
|
||||
use IPC::System::Simple qw( capturex );
|
||||
use Path::Tiny qw( path );
|
||||
use Test::More;
|
||||
|
||||
sub main {
|
||||
my $target;
|
||||
my $expect_cross;
|
||||
my $expect_cross_version;
|
||||
my $expect_file_re;
|
||||
my $expect_stripped;
|
||||
|
||||
GetOptions(
|
||||
'target=s' => \$target,
|
||||
'expect-file-re=s' => \$expect_file_re,
|
||||
'expect-cross!' => \$expect_cross,
|
||||
'expect-cross-version=s' => \$expect_cross_version,
|
||||
'expect-stripped!' => \$expect_stripped,
|
||||
);
|
||||
|
||||
check_cross(
|
||||
path( $ENV{RUNNER_TEMP} ),
|
||||
$expect_cross,
|
||||
$expect_cross_version
|
||||
);
|
||||
|
||||
for my $bin (
|
||||
path( qw( . target ), $target, qw( debug bin1 ) ),
|
||||
path( qw( . target ), $target, qw( debug bin2 ) ),
|
||||
path( qw( . subcrate target ), $target, qw( debug subcrate ) )
|
||||
) {
|
||||
check_binary( $bin, $expect_file_re, $expect_stripped );
|
||||
}
|
||||
|
||||
done_testing();
|
||||
}
|
||||
|
||||
sub check_cross ( $bin_dir, $expect_cross, $expect_cross_version ) {
|
||||
my $cross = $bin_dir->child('cross');
|
||||
if ($expect_cross) {
|
||||
ok( $cross->is_file && -x $cross, 'found `cross` in $PATH' );
|
||||
if ($expect_cross_version) {
|
||||
my $version = capturex( $cross, '--version' );
|
||||
like(
|
||||
$version, qr/\Q$expect_cross_version/,
|
||||
'cross version matches expected version'
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ok( !$cross->exists, 'did not find `cross` in $PATH' );
|
||||
}
|
||||
}
|
||||
|
||||
sub check_binary ( $bin, $expect_file_re, $expect_stripped ) {
|
||||
ok( $bin->exists, "Binary at $bin exists" )
|
||||
or return;
|
||||
ok( $bin->is_file, "Binary at $bin is a file" )
|
||||
or return;
|
||||
ok( -x $bin, "Binary at $bin is executable" )
|
||||
or return;
|
||||
|
||||
my $file = capturex( qw( file --brief ), $bin ) // q{};
|
||||
chomp $file;
|
||||
|
||||
like(
|
||||
$file, qr/$expect_file_re/,
|
||||
"`file` output for $bin matches expected output"
|
||||
);
|
||||
|
||||
# The file command on macOS doesn't report whether the binary is stripped
|
||||
# or not.
|
||||
return if $^O eq 'darwin';
|
||||
|
||||
if ($expect_stripped) {
|
||||
unlike(
|
||||
$file, qr/not stripped/,
|
||||
"`file` does not report $bin as not stripped"
|
||||
);
|
||||
like( $file, qr/stripped/, "`file` reports $bin as stripped" );
|
||||
}
|
||||
else {
|
||||
if ( $^O eq 'MSWin32' || $^O eq 'msys' ) {
|
||||
|
||||
# On Windows, unstripped binaries don't contain the word
|
||||
# "stripped" at all.
|
||||
unlike(
|
||||
$file, qr/stripped/,
|
||||
"`file` does not report $bin as stripped"
|
||||
);
|
||||
}
|
||||
else {
|
||||
like(
|
||||
$file, qr/not stripped/,
|
||||
"`file` reports $bin as not stripped"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
229
validate-inputs.py
Executable file
229
validate-inputs.py
Executable file
@@ -0,0 +1,229 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Written by Claude.ai
|
||||
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Union
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
boolean_flags = {"cache_cross_binary", "force_use_cross", "strip", "use_rust_cache"}
|
||||
|
||||
|
||||
class InputValidator:
|
||||
"""Validate inputs for a GitHub Action."""
|
||||
|
||||
def __init__(self, repo_root: Union[str, Path]):
|
||||
"""
|
||||
Create a new InputValidator by collecting environment variables.
|
||||
|
||||
Args:
|
||||
repo_root: Path to the repository root
|
||||
"""
|
||||
self.repo_root = Path(repo_root)
|
||||
self.inputs: Dict[str, str] = {
|
||||
key.replace("INPUTS_", "").lower(): value
|
||||
for key, value in os.environ.items()
|
||||
if key.startswith("INPUTS_")
|
||||
}
|
||||
|
||||
def validate(self) -> List[str]:
|
||||
"""
|
||||
Validate all inputs according to specifications.
|
||||
|
||||
Returns:
|
||||
List of validation errors. Empty list means all inputs are valid.
|
||||
"""
|
||||
validation_errors: List[str] = []
|
||||
|
||||
# Check for required 'target' parameter
|
||||
if "target" not in self.inputs:
|
||||
validation_errors.append("'target' is a required parameter")
|
||||
|
||||
# Validate working directory if present
|
||||
if "working_directory" in self.inputs:
|
||||
path = Path(self.inputs["working_directory"])
|
||||
if not path.is_absolute():
|
||||
path = self.repo_root / path
|
||||
|
||||
if not path.exists():
|
||||
validation_errors.append(
|
||||
f"'working-directory' does not exist: {self.inputs['working_directory']}"
|
||||
)
|
||||
elif not path.is_dir():
|
||||
validation_errors.append(
|
||||
f"'working-directory' is not a directory: {self.inputs['working_directory']}"
|
||||
)
|
||||
|
||||
# Validate boolean flags
|
||||
for flag in boolean_flags:
|
||||
if flag in self.inputs and self.inputs[flag] not in {"true", "false"}:
|
||||
# Turn the underscores into dashes
|
||||
dashes = flag.replace("_", "-")
|
||||
validation_errors.append(f"'{dashes}' must be either 'true' or 'false'")
|
||||
|
||||
# Validate rust-cache-parameters JSON if present
|
||||
if "rust_cache_parameters" in self.inputs:
|
||||
try:
|
||||
json.loads(self.inputs["rust_cache_parameters"])
|
||||
except json.JSONDecodeError:
|
||||
validation_errors.append("'rust-cache-parameters' must be valid JSON")
|
||||
|
||||
return validation_errors
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Main function for running the validator."""
|
||||
import sys
|
||||
|
||||
validator = InputValidator(sys.argv[1])
|
||||
errors = validator.validate()
|
||||
|
||||
if not errors:
|
||||
print("All inputs are valid.")
|
||||
sys.exit(0)
|
||||
else:
|
||||
for error in errors:
|
||||
print(error, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class TestInputValidator(unittest.TestCase):
|
||||
"""Unit tests for the InputValidator."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
"""Set up test environment."""
|
||||
# Clear existing INPUTS_ environment variables
|
||||
for key in list(os.environ.keys()):
|
||||
if key.startswith("INPUTS_"):
|
||||
del os.environ[key]
|
||||
|
||||
def setup_env(self, inputs: Dict[str, str]) -> None:
|
||||
"""Helper function to set up environment variables for testing."""
|
||||
for key, value in inputs.items():
|
||||
env_key = f"INPUTS_{key.upper().replace('-', '_')}"
|
||||
os.environ[env_key] = value
|
||||
|
||||
def test_get_inputs_from_env(self) -> None:
|
||||
"""Test getting inputs from environment variables."""
|
||||
inputs = {
|
||||
"target": "x86_64-unknown-linux-gnu",
|
||||
"command": "build",
|
||||
"toolchain": "stable",
|
||||
"use-rust-cache": "true",
|
||||
}
|
||||
self.setup_env(inputs)
|
||||
|
||||
validator = InputValidator("/root")
|
||||
for key, value in validator.inputs.items():
|
||||
self.assertEqual(value, inputs[key.replace("_", "-")])
|
||||
|
||||
def test_validate_missing_target(self) -> None:
|
||||
"""Test validation with missing target."""
|
||||
self.setup_env({})
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
def test_validate_valid_toolchain(self) -> None:
|
||||
"""Test validation of valid toolchains."""
|
||||
valid_toolchains = [
|
||||
"stable",
|
||||
"beta",
|
||||
"nightly",
|
||||
"nightly-2025-03-17",
|
||||
"stable 8 weeks ago",
|
||||
]
|
||||
|
||||
for toolchain in valid_toolchains:
|
||||
self.setup_env(
|
||||
{"target": "x86_64-unknown-linux-gnu", "toolchain": toolchain}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertFalse(errors, f"Toolchain '{toolchain}' should be valid")
|
||||
|
||||
def test_validate_working_directory(self) -> None:
|
||||
"""Test validation of working directory."""
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
# Test with valid directory
|
||||
self.setup_env(
|
||||
{"target": "x86_64-unknown-linux-gnu", "working-directory": temp_dir}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertFalse(errors)
|
||||
|
||||
# Test with non-existent directory
|
||||
self.setup_env(
|
||||
{
|
||||
"target": "x86_64-unknown-linux-gnu",
|
||||
"working-directory": "/path/to/nonexistent/directory",
|
||||
}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
# Test with file instead of directory
|
||||
with tempfile.NamedTemporaryFile() as temp_file:
|
||||
self.setup_env(
|
||||
{
|
||||
"target": "x86_64-unknown-linux-gnu",
|
||||
"working-directory": temp_file.name,
|
||||
}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
def test_validate_boolean_flags(self) -> None:
|
||||
"""Test validation of boolean flags."""
|
||||
|
||||
# Test valid boolean values
|
||||
for flag in boolean_flags:
|
||||
for value in ["true", "false"]:
|
||||
self.setup_env({"target": "x86_64-unknown-linux-gnu", flag: value})
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertFalse(errors, f"'{flag}' with '{value}' should be valid")
|
||||
|
||||
# Test invalid boolean values
|
||||
for flag in boolean_flags:
|
||||
self.setup_env({"target": "x86_64-unknown-linux-gnu", flag: "invalid"})
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors, f"'{flag}' with 'invalid' should be invalid")
|
||||
|
||||
def test_validate_rust_cache_parameters(self) -> None:
|
||||
"""Test validation of rust cache parameters."""
|
||||
# Valid JSON
|
||||
self.setup_env(
|
||||
{
|
||||
"target": "x86_64-unknown-linux-gnu",
|
||||
"rust-cache-parameters": '{"key1":"value1","key2":"value2"}',
|
||||
}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertFalse(errors)
|
||||
|
||||
# Invalid JSON
|
||||
self.setup_env(
|
||||
{
|
||||
"target": "x86_64-unknown-linux-gnu",
|
||||
"rust-cache-parameters": "{invalid json",
|
||||
}
|
||||
)
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(os.sys.argv) > 1 and os.sys.argv[1] == "--test":
|
||||
unittest.main(argv=["unittest"])
|
||||
else:
|
||||
main()
|
||||
Reference in New Issue
Block a user