Add support for a "working-directory" parameter
This commit updates the tests to check that this works and also rewrites the test script from Bash to Perl. Co-authored-by: Dave Rolsky <autarch@urth.org>
This commit is contained in:
parent
77a5caf54b
commit
42fe96a4c1
133
.github/workflows/test.yml
vendored
133
.github/workflows/test.yml
vendored
@ -14,161 +14,160 @@ jobs:
|
|||||||
- platform_name: FreeBSD-x86_64
|
- platform_name: FreeBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
expect_cross: true
|
expect_file_re: "x86-64.+FreeBSD"
|
||||||
expect_file: "x86-64.+FreeBSD"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Linux-x86_64
|
- platform_name: Linux-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
expect_cross: false
|
expect_file_re: "ELF.+x86-64"
|
||||||
expect_file: "ELF.+x86-64"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: true
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64
|
- platform_name: Linux-aarch64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
expect_cross: true
|
expect_file_re: "aarch64"
|
||||||
expect_file: "aarch64"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-arm
|
- platform_name: Linux-arm
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: arm-unknown-linux-musleabi
|
target: arm-unknown-linux-musleabi
|
||||||
expect_cross: true
|
expect_file_re: "32.+ARM"
|
||||||
expect_file: "32.+ARM"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-i586
|
- platform_name: Linux-i586
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: i586-unknown-linux-musl
|
target: i586-unknown-linux-musl
|
||||||
expect_cross: false
|
expect_file_re: "ELF.+80386"
|
||||||
expect_file: "ELF.+80386"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: true
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips
|
- platform_name: Linux-mips
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips-unknown-linux-musl
|
target: mips-unknown-linux-musl
|
||||||
expect_cross: true
|
expect_file_re: "MIPS32.+mips-"
|
||||||
expect_file: "MIPS32.+mips-"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mipsel
|
- platform_name: Linux-mipsel
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mipsel-unknown-linux-musl
|
target: mipsel-unknown-linux-musl
|
||||||
expect_cross: true
|
expect_file_re: "MIPS32.+mipsel-"
|
||||||
expect_file: "MIPS32.+mipsel-"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64
|
- platform_name: Linux-mips64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64-unknown-linux-muslabi64
|
target: mips64-unknown-linux-muslabi64
|
||||||
expect_cross: true
|
expect_file_re: "MIPS64"
|
||||||
expect_file: "MIPS64"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64el
|
- platform_name: Linux-mips64el
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64el-unknown-linux-muslabi64
|
target: mips64el-unknown-linux-muslabi64
|
||||||
expect_cross: true
|
expect_file_re: "MIPS64"
|
||||||
expect_file: "MIPS64"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc
|
- platform_name: Linux-powerpc
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc-unknown-linux-gnu
|
target: powerpc-unknown-linux-gnu
|
||||||
expect_cross: true
|
expect_file_re: "32.+PowerPC"
|
||||||
expect_file: "32.+PowerPC"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64
|
- platform_name: Linux-powerpc64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64-unknown-linux-gnu
|
target: powerpc64-unknown-linux-gnu
|
||||||
expect_cross: true
|
expect_file_re: "64.+PowerPC"
|
||||||
expect_file: "64.+PowerPC"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64le
|
- platform_name: Linux-powerpc64le
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64le-unknown-linux-gnu
|
target: powerpc64le-unknown-linux-gnu
|
||||||
expect_cross: true
|
expect_file_re: "64.+PowerPC"
|
||||||
expect_file: "64.+PowerPC"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-riscv64
|
- platform_name: Linux-riscv64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: riscv64gc-unknown-linux-gnu
|
target: riscv64gc-unknown-linux-gnu
|
||||||
expect_cross: true
|
expect_file_re: "64.+RISC-V"
|
||||||
expect_file: "64.+RISC-V"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-s390x
|
- platform_name: Linux-s390x
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: s390x-unknown-linux-gnu
|
target: s390x-unknown-linux-gnu
|
||||||
expect_cross: true
|
expect_file_re: "64.+S/390"
|
||||||
expect_file: "64.+S/390"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: NetBSD-x86_64
|
- platform_name: NetBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-netbsd
|
target: x86_64-unknown-netbsd
|
||||||
expect_cross: true
|
expect_file_re: "x86-64.+NetBSD"
|
||||||
expect_file: "x86-64.+NetBSD"
|
expect_cross: "--expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-aarch64
|
- platform_name: Windows-aarch64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: aarch64-pc-windows-msvc
|
target: aarch64-pc-windows-msvc
|
||||||
expect_cross: false
|
expect_file_re: "Aarch64.+Windows"
|
||||||
expect_file: "Aarch64.+Windows"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: false
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-i686
|
- platform_name: Windows-i686
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: i686-pc-windows-msvc
|
target: i686-pc-windows-msvc
|
||||||
expect_cross: false
|
expect_file_re: "80386.+Windows"
|
||||||
expect_file: "80386.+Windows"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: true
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Windows-x86_64
|
- platform_name: Windows-x86_64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
expect_cross: false
|
expect_file_re: "x86-64.+Windows"
|
||||||
expect_file: "x86-64.+Windows"
|
expect_stripped: "--expect-stripped"
|
||||||
expect_stripped: true
|
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-x86_64
|
- platform_name: macOS-x86_64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
expect_cross: false
|
expect_file_re: "Mach-O.+x86_64"
|
||||||
expect_file: "Mach-O.+x86_64"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: true
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-aarch64
|
- platform_name: macOS-aarch64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
expect_cross: false
|
expect_file_re: "Mach-O.+arm64"
|
||||||
expect_file: "Mach-O.+arm64"
|
expect_cross: "--no-expect-cross"
|
||||||
expect_stripped: true
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform.os }}
|
runs-on: ${{ matrix.platform.os }}
|
||||||
@ -201,7 +200,19 @@ jobs:
|
|||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
strip: true
|
strip: true
|
||||||
|
- name: Run build command for subdir
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
working-directory: subcrate
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
strip: true
|
||||||
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
tests/check-binary.sh "${{ matrix.platform.target }}" "${{ matrix.platform.expect_cross }}" "${{ matrix.platform.expect_file }}" "${{ matrix.platform.expect_stripped }}"
|
tests/check-binary.pl \
|
||||||
|
--target "${{ matrix.platform.target }}" \
|
||||||
|
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
|
||||||
|
${{ matrix.platform.expect_cross }} \
|
||||||
|
${{ matrix.platform.expect_stripped }}
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@
|
|||||||
/package.json
|
/package.json
|
||||||
.\#*
|
.\#*
|
||||||
\#*\#
|
\#*\#
|
||||||
test-project/target/**
|
test-project/**/target/**
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
## 0.0.9 - 2023-09-10
|
||||||
|
|
||||||
|
- Added a `working-directory` parameter. By default this is the current directory (`.`) but you can
|
||||||
|
set it to something else to compile a single crate or workspace in a subdirectory of the repo.
|
||||||
|
This allows you to use this action with monorepos with multiple crates. Based on GH #7 by
|
||||||
|
@aaronvg.
|
||||||
|
|
||||||
## 0.0.8 - 2023-07-22
|
## 0.0.8 - 2023-07-22
|
||||||
|
|
||||||
- For builds that need the `cross` binary, this binary is now cached. A cache hit saves about 20
|
- For builds that need the `cross` binary, this binary is now cached. A cache hit saves about 20
|
||||||
|
|||||||
@ -56,10 +56,11 @@ jobs:
|
|||||||
This action takes the following parameters:
|
This action takes the following parameters:
|
||||||
|
|
||||||
| Key | Type | Required? | Description |
|
| 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 fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
|
| `command` | string (one of `build`, `test`, or `both`) | no | The command(s) to run. The default is `build`. Running the `test` command will fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
|
||||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
||||||
| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable` |
|
| `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 }}`. |
|
| `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`. |
|
| `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 binary will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
| `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binary will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||||
|
|||||||
12
action.yml
12
action.yml
@ -1,4 +1,4 @@
|
|||||||
name: "Build Rust Projects with Cross"
|
name: "Build Rust Projects with Cross - Monorepo friendly"
|
||||||
author: "Dave Rolsky <autarch@urth.org>"
|
author: "Dave Rolsky <autarch@urth.org>"
|
||||||
branding:
|
branding:
|
||||||
icon: home
|
icon: home
|
||||||
@ -6,6 +6,9 @@ branding:
|
|||||||
description: |
|
description: |
|
||||||
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
||||||
inputs:
|
inputs:
|
||||||
|
working-directory:
|
||||||
|
description: The working directory for each step
|
||||||
|
default: "."
|
||||||
command:
|
command:
|
||||||
description: |
|
description: |
|
||||||
The commands to run (one of "build", "test", or "both").
|
The commands to run (one of "build", "test", or "both").
|
||||||
@ -19,7 +22,7 @@ inputs:
|
|||||||
default: stable
|
default: stable
|
||||||
GITHUB_TOKEN:
|
GITHUB_TOKEN:
|
||||||
description: |
|
description: |
|
||||||
A GitHub token, available in the secrets.GITHUB_TOKEN context variable.
|
A GitHub token, available in the secrets.GITHUB_TOKEN working-directory variable.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
args:
|
args:
|
||||||
description: |
|
description: |
|
||||||
@ -76,6 +79,7 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||||
- name: Run tests (*nix)
|
- name: Run tests (*nix)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
@ -85,21 +89,25 @@ runs:
|
|||||||
# msys, notably OpenSSL, which is compiled locally when using the
|
# msys, notably OpenSSL, which is compiled locally when using the
|
||||||
# `openssl` crate with the `vendored` feature.
|
# `openssl` crate with the `vendored` feature.
|
||||||
- name: Run tests (Windows)
|
- name: Run tests (Windows)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||||
- name: Build binary (*nix)
|
- name: Build binary (*nix)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
||||||
- name: Build binary (Windows)
|
- name: Build binary (Windows)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||||
- name: Strip binary
|
- name: Strip binary
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: strip-binary.sh ${{ inputs.target }}
|
run: strip-binary.sh ${{ inputs.target }}
|
||||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||||
|
|||||||
@ -14,6 +14,9 @@ function install_tools () {
|
|||||||
run "ubi --project houseabsolute/precious --in ~/bin"
|
run "ubi --project houseabsolute/precious --in ~/bin"
|
||||||
run "ubi --project houseabsolute/omegasort --in ~/bin"
|
run "ubi --project houseabsolute/omegasort --in ~/bin"
|
||||||
run "npm install prettier"
|
run "npm install prettier"
|
||||||
|
run "curl -L https://cpanmin.us/ -o ~/bin/cpanm"
|
||||||
|
run "chmod 0755 ~/bin/cpanm"
|
||||||
|
run "~/bin/cpanm --sudo --notest Perl::Tidy"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" == "-v" ]; then
|
if [ "$1" == "-v" ]; then
|
||||||
|
|||||||
22
perltidyrc
Normal file
22
perltidyrc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
-l=78
|
||||||
|
-i=4
|
||||||
|
-ci=4
|
||||||
|
-se
|
||||||
|
-b
|
||||||
|
-bar
|
||||||
|
-boc
|
||||||
|
-vt=0
|
||||||
|
-vtc=0
|
||||||
|
-cti=0
|
||||||
|
-pt=1
|
||||||
|
-bt=1
|
||||||
|
-sbt=1
|
||||||
|
-bbt=1
|
||||||
|
-nolq
|
||||||
|
-npro
|
||||||
|
-nsfs
|
||||||
|
--blank-lines-before-packages=0
|
||||||
|
--opening-hash-brace-right
|
||||||
|
--no-outdent-long-comments
|
||||||
|
--iterations=2
|
||||||
|
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
|
||||||
@ -2,6 +2,17 @@ exclude = [
|
|||||||
"target",
|
"target",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[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]
|
[commands.prettier-md]
|
||||||
type = "both"
|
type = "both"
|
||||||
include = [ "**/*.md" ]
|
include = [ "**/*.md" ]
|
||||||
|
|||||||
7
test-project/subcrate/Cargo.lock
generated
Normal file
7
test-project/subcrate/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "subcrate"
|
||||||
|
version = "0.1.0"
|
||||||
8
test-project/subcrate/Cargo.toml
Normal file
8
test-project/subcrate/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "subcrate"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
3
test-project/subcrate/src/main.rs
Normal file
3
test-project/subcrate/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world (subcrate)!");
|
||||||
|
}
|
||||||
100
tests/check-binary.pl
Executable file
100
tests/check-binary.pl
Executable file
@ -0,0 +1,100 @@
|
|||||||
|
#!/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_file_re;
|
||||||
|
my $expect_stripped;
|
||||||
|
|
||||||
|
GetOptions(
|
||||||
|
'target=s' => \$target,
|
||||||
|
'expect-file-re=s' => \$expect_file_re,
|
||||||
|
'expect-cross!' => \$expect_cross,
|
||||||
|
'expect-stripped!' => \$expect_stripped,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_cross( path( $ENV{RUNNER_TEMP} ), $expect_cross );
|
||||||
|
|
||||||
|
for my $bin (
|
||||||
|
path( qw( . target ), $target, qw( debug test-project ) ),
|
||||||
|
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 ) {
|
||||||
|
my $cross = $bin_dir->child('cross');
|
||||||
|
if ($expect_cross) {
|
||||||
|
ok( $cross->is_file && -x $cross, 'found `cross` in $PATH' );
|
||||||
|
}
|
||||||
|
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();
|
||||||
1115
tests/lib/IPC/System/Simple.pm
Normal file
1115
tests/lib/IPC/System/Simple.pm
Normal file
File diff suppressed because it is too large
Load Diff
3880
tests/lib/Path/Tiny.pm
Normal file
3880
tests/lib/Path/Tiny.pm
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user