diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a03de9..4c4e413 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -126,3 +126,45 @@ jobs: run: | [[ -d "test/hello_world/target/aarch64-unknown-linux-gnu/debug" ]] || (echo "debug is missing" && exit 1); [[ -d "test/hello_world/target/aarch64-unknown-linux-gnu/release" ]] || (echo "release is missing" && exit 1); + + test-git-cross: + name: "Test using git versions of cross" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: aarch64-unknown-linux-gnu + + - name: Enable Rust cache + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # 2.2.1 + with: + cache-on-failure: true + workspaces: "./test/hello_world -> target" + + - name: Test main branch + uses: ./ + with: + command: build + args: --target aarch64-unknown-linux-gnu + use-cross: true + cross-version: main + directory: test/hello_world + + - name: Uninstall cargo cross + shell: bash + run: | + cargo uninstall cross || true + + - name: Test git hash + uses: ./ + with: + command: build + args: --target aarch64-unknown-linux-gnu + use-cross: true + cross-version: "git:d6511b7b166c18640f81b8f6a74d9eef380f7ded" + directory: test/hello_world diff --git a/README.md b/README.md index b0b3c4c..e61a21f 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ Note - this action does not install Rust for you, you will want to install a too **Note: Inputs aren't necessarily checked to be valid by this action!** -| Name | Description | -| --------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `command` | The `cargo` command to run (e.g. `build`, `test`). Required. | -| `toolchain` | The toolchain to use. Do not include the `+` sign (e.g. `nightly`, `beta`). Defaults to stable. | -| `args` | What arguments to pass to the cargo/cross command. | -| `use-cross` | Whether to use cross instead of using cargo. If enabled, cross will automatically be installed if needed. | -| `cross-version` | The cross version to use. Only used if `use-cross` is enabled. If not set, defaults to the newest stable version of cross. | -| `directory` | Change to the specified directory prior to execution. Useful if your repo's base folder does not contain your Rust project. | +| Name | Description | +| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `command` | The `cargo` command to run (e.g. `build`, `test`). Required. | +| `toolchain` | The toolchain to use. Do not include the `+` sign (e.g. `nightly`, `beta`). Defaults to stable. | +| `args` | What arguments to pass to the cargo/cross command. | +| `use-cross` | Whether to use cross instead of using cargo. If enabled, cross will automatically be installed if needed. | +| `cross-version` | The cross version to use. Only used if `use-cross` is enabled. If this is not set, it will default to the newest stable version of cross. `main` or `git:XYZ` are also valid options. | +| `directory` | Change to the specified directory prior to execution. Useful if your repo's base folder does not contain your Rust project. | ## Example diff --git a/action.yml b/action.yml index 77b8a7c..2a8256d 100644 --- a/action.yml +++ b/action.yml @@ -27,8 +27,11 @@ inputs: cross-version: description: > - The cross version to use. Only used if `use-cross` is enabled. If not set, defaults to the newest stable - version of cross. + The cross version to use. This is only used if `use-cross` is enabled. If it is not set, defaults to the newest + stable version of cross. + + You can also set the special versions of "main" or "git:xyz" to specify a specific git hash or the current main + branch head of cross. required: false default: "" @@ -63,9 +66,17 @@ runs: run: | # Install cross if [[ -n "${{inputs.cross-version}}" ]]; then - CROSS_VERSION_ARG="--version=${{inputs.cross-version}}"; + if [[ "${{inputs.cross-version}}" == "main" ]]; then + cargo install cross --git https://github.com/cross-rs/cross --branch main + elif [[ "${{inputs.cross-version}}" == "git:"* ]]; then + CROSS_VERSION_ARG="${{inputs.cross-version}}" + CROSS_HASH="${CROSS_VERSION_ARG:4}" + cargo install cross --git https://github.com/cross-rs/cross --rev ${CROSS_HASH} + else + CROSS_VERSION_ARG="--version=${{inputs.cross-version}}"; + cargo install cross --locked ${CROSS_VERSION_ARG}; + fi fi - cargo install cross --locked ${CROSS_VERSION_ARG}; - name: Execute the cargo/cross command. shell: bash