From 93c694931f68c23533501b4fd771d191887024ce Mon Sep 17 00:00:00 2001 From: Sewer56 Date: Tue, 2 Dec 2025 03:11:31 +0000 Subject: [PATCH] Added: Optional friendly target names for artifact naming - Introduced use-friendly-target-names input (default: false) for human-readable artifact names - Created mapping script with 160 explicit target-to-friendly-name transformations (O(1) lookup) - Updated artifact name generation to conditionally use friendly names (e.g., x86_64-unknown-linux-gnu -> linux-x64) - Added comprehensive test workflow covering script validation and end-to-end action behavior - Updated: Test workflows to use local action instead of remote reference - Updated: Use env vars for artifact names in symbol tests - Updated: Add missing pgo-project-path to PGO test jobs - Updated: Remove workspace-path from standalone CLI builds --- .github/workflows/test-build-workflow.yml | 145 ++++++++--- .github/workflows/test-friendly-names.yml | 55 ++++ .github/workflows/test-symbols-bundled.yml | 28 +- .github/workflows/test-symbols-separate.yml | 28 +- .github/workflows/test-unfriendly-names.yml | 51 ++++ README.MD | 51 ++-- action.yml | 15 +- scripts/get-friendly-target-name.sh | 273 ++++++++++++++++++++ 8 files changed, 570 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/test-friendly-names.yml create mode 100644 .github/workflows/test-unfriendly-names.yml create mode 100755 scripts/get-friendly-target-name.sh diff --git a/.github/workflows/test-build-workflow.yml b/.github/workflows/test-build-workflow.yml index db370da..ef9823a 100644 --- a/.github/workflows/test-build-workflow.yml +++ b/.github/workflows/test-build-workflow.yml @@ -60,33 +60,44 @@ jobs: use-cross: false runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Binary Build - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: target: ${{ matrix.target }} use-pgo: ${{ matrix.use-pgo }} use-cross: ${{ matrix.use-cross }} - rust-project-path: "tools/cli" + rust-project-path: "test-project/tools/cli" + pgo-project-path: "test-project" crate-name: "prs-rs-cli" upload-artifacts: false test-build-without-native-host-tools: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Android Armv7 Build - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli + rust-project-path: test-project/tools/cli crate-name: prs-rs-cli target: armv7-linux-androideabi use-cross: true @@ -144,13 +155,18 @@ jobs: use-tarpaulin: true runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Library Build - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs target: ${{ matrix.target }} @@ -162,31 +178,42 @@ jobs: upload-artifacts: false run-tests-and-coverage: true upload-coverage-to-codecov: false + rust-project-path: test-project + pgo-project-path: test-project + workspace-path: test-project # This tests gathering PGO data on a host, and building for a different target. test-pgo-with-cross-compile: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test PGO with Cross-Compilation (Binary) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli - pgo-project-path: . + rust-project-path: test-project/tools/cli + pgo-project-path: test-project crate-name: prs-rs-cli target: aarch64-unknown-linux-gnu # x64 host to aarch64 simulated guest use-pgo: true use-cross: true pgo-benchmark-name: my_benchmark upload-artifacts: false + - name: Test PGO with Cross-Compilation (Library) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project + pgo-project-path: test-project target: aarch64-unknown-linux-gnu # x64 host to to aarch64 simulated guest use-pgo: true use-cross: true @@ -197,15 +224,21 @@ jobs: test-library-feature-build: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Library Feature Build - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project target: x86_64-unknown-linux-gnu features: c-exports,std upload-artifacts: false @@ -214,15 +247,21 @@ jobs: test-library-no-default-features: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Library No Default Features - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project target: x86_64-unknown-linux-gnu no-default-features: true features: std @@ -232,16 +271,21 @@ jobs: test-binary-pgo-with-library: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Binary PGO with Library - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli - pgo-project-path: . + rust-project-path: test-project/tools/cli + pgo-project-path: test-project crate-name: prs-rs-cli target: x86_64-unknown-linux-gnu use-pgo: true @@ -251,15 +295,22 @@ jobs: test-library-pgo: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Library PGO - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project + pgo-project-path: test-project target: x86_64-unknown-linux-gnu use-pgo: true pgo-benchmark-name: my_benchmark @@ -269,23 +320,30 @@ jobs: test-custom-rustflags: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Custom RUSTFLAGS (Binary) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli + rust-project-path: test-project/tools/cli crate-name: prs-rs-cli target: x86_64-unknown-linux-gnu additional-rustflags: -C opt-level=3 upload-artifacts: false + - name: Test Custom RUSTFLAGS (Library) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project target: x86_64-unknown-linux-gnu additional-rustflags: -C opt-level=3 upload-artifacts: false @@ -294,24 +352,31 @@ jobs: test-custom-build-std: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Custom RUSTFLAGS (Binary) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli + rust-project-path: test-project/tools/cli crate-name: prs-rs-cli target: x86_64-unknown-linux-gnu additional-rustflags: -C opt-level=3 upload-artifacts: false size-optimized-std: true + - name: Test Custom RUSTFLAGS (Library) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: crate-name: prs-rs + rust-project-path: test-project target: x86_64-unknown-linux-gnu additional-rustflags: -C opt-level=3 upload-artifacts: false @@ -321,15 +386,20 @@ jobs: test-custom-rustc-args: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test Custom rustc Args (Binary) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli + rust-project-path: test-project/tools/cli crate-name: prs-rs-cli target: x86_64-unknown-linux-gnu additional-rustc-args: --all-features @@ -341,17 +411,21 @@ jobs: test-workspace-build: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/dxt-lossless-transform ref: d47afd9a7c2fa71495b6d942853b0fe41f258e26 + path: test-project - name: Test Workspace Build (API) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: projects/dxt-lossless-transform-api - workspace-path: "." + rust-project-path: test-project/projects/dxt-lossless-transform-api + workspace-path: "test-project" crate-name: dxt-lossless-transform-api target: x86_64-unknown-linux-gnu upload-artifacts: true @@ -359,17 +433,21 @@ jobs: test-workspace-build-2: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/dxt-lossless-transform ref: d47afd9a7c2fa71495b6d942853b0fe41f258e26 + path: test-project - name: Test Workspace Build (CLI) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: projects/dxt-lossless-transform-cli - workspace-path: "." + rust-project-path: test-project/projects/dxt-lossless-transform-cli + workspace-path: "test-project" crate-name: dxt-lossless-transform-cli target: x86_64-unknown-linux-gnu upload-artifacts: true @@ -377,15 +455,20 @@ jobs: test-specific-nightly: runs-on: ubuntu-latest steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + - name: Test with Specific Nightly - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: tools/cli + rust-project-path: test-project/tools/cli crate-name: prs-rs-cli target: x86_64-unknown-linux-gnu rust-toolchain: nightly-2025-09-11 diff --git a/.github/workflows/test-friendly-names.yml b/.github/workflows/test-friendly-names.yml new file mode 100644 index 0000000..e989cf7 --- /dev/null +++ b/.github/workflows/test-friendly-names.yml @@ -0,0 +1,55 @@ +name: Test Friendly Target Names (Enabled) + +on: + workflow_dispatch: + push: + tags: + - "v1" + - "v1-test" + paths: + - "action.yml" + - "scripts/get-friendly-target-name.sh" + - ".github/workflows/test-friendly-names.yml" + pull_request: + branches: [v1-master] + paths: + - "action.yml" + - "scripts/get-friendly-target-name.sh" + - ".github/workflows/test-friendly-names.yml" + +jobs: + test-friendly-names-enabled: + runs-on: ubuntu-latest + steps: + - name: Checkout Action + uses: actions/checkout@v4 + + - name: Checkout Test Repository + uses: actions/checkout@v4 + with: + repository: Sewer56/prs-rs + ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + + - name: Build with Friendly Names Enabled + uses: ./ + with: + rust-project-path: test-project/tools/cli + crate-name: prs-rs-cli + target: x86_64-unknown-linux-gnu + use-friendly-target-names: true + upload-artifacts: true + + - name: Verify artifact name uses friendly name + shell: bash + run: | + echo "BINARY_ARTIFACT_NAME=$BINARY_ARTIFACT_NAME" + if [[ "$BINARY_ARTIFACT_NAME" != *"linux-x64"* ]]; then + echo "::error::Expected artifact name to contain 'linux-x64' but got '$BINARY_ARTIFACT_NAME'" + exit 1 + fi + if [[ "$BINARY_ARTIFACT_NAME" == *"x86_64-unknown-linux-gnu"* ]]; then + echo "::error::Expected artifact name to NOT contain raw triple 'x86_64-unknown-linux-gnu' but got '$BINARY_ARTIFACT_NAME'" + exit 1 + fi + echo "Artifact name correctly uses friendly name: $BINARY_ARTIFACT_NAME" diff --git a/.github/workflows/test-symbols-bundled.yml b/.github/workflows/test-symbols-bundled.yml index eb19272..e49d53c 100644 --- a/.github/workflows/test-symbols-bundled.yml +++ b/.github/workflows/test-symbols-bundled.yml @@ -32,25 +32,29 @@ jobs: target: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 039d687e737c40ab7f6deb2c2489a56e105e8082 + path: test-project - name: Build Binary (upload-symbols-separately=false) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: src/cli + rust-project-path: test-project/src/cli crate-name: prs-rs-cli target: ${{ matrix.target }} - workspace-path: src + workspace-path: test-project/src upload-symbols-separately: false - name: Download Main Binary Artifact uses: actions/download-artifact@v6 with: - name: prs-rs-cli-${{ matrix.target }} + name: ${{ env.BINARY_ARTIFACT_NAME }} path: main-artifact - name: Assert Main Artifact Contains Binary and Symbols (Bundled) @@ -107,7 +111,7 @@ jobs: id: download-symbols continue-on-error: true with: - name: prs-rs-cli-${{ matrix.target }}.symbols + name: ${{ env.BINARY_ARTIFACT_NAME }}.symbols path: symbols-artifact - name: Assert Symbols Artifact Does Not Exist @@ -133,26 +137,30 @@ jobs: target: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 039d687e737c40ab7f6deb2c2489a56e105e8082 + path: test-project - name: Build Library (upload-symbols-separately=false) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: src/prs-rs + rust-project-path: test-project/src/prs-rs crate-name: prs-rs target: ${{ matrix.target }} - workspace-path: src + workspace-path: test-project/src build-library: true upload-symbols-separately: false - name: Download Main Library Artifact uses: actions/download-artifact@v6 with: - name: C-Library-prs-rs-${{ matrix.target }} + name: ${{ env.LIBRARY_ARTIFACT_NAME }} path: main-artifact - name: Assert Main Artifact Contains Library and Symbols (Bundled) @@ -217,7 +225,7 @@ jobs: id: download-symbols continue-on-error: true with: - name: C-Library-prs-rs-${{ matrix.target }}.symbols + name: ${{ env.LIBRARY_ARTIFACT_NAME }}.symbols path: symbols-artifact - name: Assert Symbols Artifact Does Not Exist diff --git a/.github/workflows/test-symbols-separate.yml b/.github/workflows/test-symbols-separate.yml index 629ff9a..cba0fdc 100644 --- a/.github/workflows/test-symbols-separate.yml +++ b/.github/workflows/test-symbols-separate.yml @@ -32,24 +32,28 @@ jobs: target: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 039d687e737c40ab7f6deb2c2489a56e105e8082 + path: test-project - name: Build Binary (default upload-symbols-separately=true) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: src/cli + rust-project-path: test-project/src/cli crate-name: prs-rs-cli target: ${{ matrix.target }} - workspace-path: src + workspace-path: test-project/src - name: Download Main Binary Artifact uses: actions/download-artifact@v6 with: - name: prs-rs-cli-${{ matrix.target }} + name: ${{ env.BINARY_ARTIFACT_NAME }} path: main-artifact - name: Assert Main Artifact Has Binary But No Symbols @@ -104,7 +108,7 @@ jobs: - name: Download Symbols Artifact uses: actions/download-artifact@v6 with: - name: prs-rs-cli-${{ matrix.target }}.symbols + name: ${{ env.BINARY_ARTIFACT_NAME }}.symbols path: symbols-artifact - name: Assert Symbols Artifact Has Symbols But No Binary @@ -167,25 +171,29 @@ jobs: target: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: + - name: Checkout Action + uses: actions/checkout@v6 + - name: Checkout Test Repository uses: actions/checkout@v6 with: repository: Sewer56/prs-rs ref: 039d687e737c40ab7f6deb2c2489a56e105e8082 + path: test-project - name: Build Library (default upload-symbols-separately=true) - uses: Reloaded-Project/devops-rust-lightweight-binary@v1-test + uses: ./ with: - rust-project-path: src/prs-rs + rust-project-path: test-project/src/prs-rs crate-name: prs-rs target: ${{ matrix.target }} - workspace-path: src + workspace-path: test-project/src build-library: true - name: Download Main Library Artifact uses: actions/download-artifact@v6 with: - name: C-Library-prs-rs-${{ matrix.target }} + name: ${{ env.LIBRARY_ARTIFACT_NAME }} path: main-artifact - name: Assert Main Artifact Has Library But No Symbols @@ -246,7 +254,7 @@ jobs: - name: Download Symbols Artifact uses: actions/download-artifact@v6 with: - name: C-Library-prs-rs-${{ matrix.target }}.symbols + name: ${{ env.LIBRARY_ARTIFACT_NAME }}.symbols path: symbols-artifact - name: Assert Symbols Artifact Has Symbols But No Library diff --git a/.github/workflows/test-unfriendly-names.yml b/.github/workflows/test-unfriendly-names.yml new file mode 100644 index 0000000..9182227 --- /dev/null +++ b/.github/workflows/test-unfriendly-names.yml @@ -0,0 +1,51 @@ +name: Test Friendly Target Names (Disabled) + +on: + workflow_dispatch: + push: + tags: + - "v1" + - "v1-test" + paths: + - "action.yml" + - "scripts/get-friendly-target-name.sh" + - ".github/workflows/test-unfriendly-names.yml" + pull_request: + branches: [v1-master] + paths: + - "action.yml" + - "scripts/get-friendly-target-name.sh" + - ".github/workflows/test-unfriendly-names.yml" + +jobs: + test-friendly-names-disabled: + runs-on: ubuntu-latest + steps: + - name: Checkout Action + uses: actions/checkout@v4 + + - name: Checkout Test Repository + uses: actions/checkout@v4 + with: + repository: Sewer56/prs-rs + ref: 149060527e685360687d7332742ac016b39af8a7 + path: test-project + + - name: Build with Friendly Names Disabled + uses: ./ + with: + rust-project-path: test-project/tools/cli + crate-name: prs-rs-cli + target: x86_64-unknown-linux-gnu + use-friendly-target-names: false + upload-artifacts: true + + - name: Verify artifact name uses raw triple + shell: bash + run: | + echo "BINARY_ARTIFACT_NAME=$BINARY_ARTIFACT_NAME" + if [[ "$BINARY_ARTIFACT_NAME" != *"x86_64-unknown-linux-gnu"* ]]; then + echo "::error::Expected artifact name to contain raw triple 'x86_64-unknown-linux-gnu' but got '$BINARY_ARTIFACT_NAME'" + exit 1 + fi + echo "Artifact name correctly uses raw triple: $BINARY_ARTIFACT_NAME" diff --git a/README.MD b/README.MD index 835f4b3..16751bb 100644 --- a/README.MD +++ b/README.MD @@ -117,29 +117,30 @@ To use this action in your own repository: These parameters are processed and used directly by the `rust-lightweight-binary` action: -| Input | Required | Default | Description | -| --------------------------- | -------- | ---------------- | ----------------------------------------------------------------------------------------------------------- | -| `rust-project-path` | No | `.` | Path to the Rust project | -| `workspace-path` | No | `.` | Workspace folder where `target` directory is. Uses `rust-project-path` if not set. | -| `pgo-project-path` | No | `.` | Path to the Rust project used for gathering PGO data. Can be same or separate project. | -| `crate-name` | Yes | | Name of the Rust crate/package. Used for naming the artifact/release asset. | -| `target` | Yes | | The target platform for the Rust compiler | -| `features` | No | `''` | Comma-separated list of features to include in the build | -| `no-default-features` | No | `false` | Do not include default features in the build | -| `use-pgo` | No | `false` | Use Profile-Guided Optimization [PGO] to build the library. | -| `pgo-benchmark-name` | No | `'my_benchmark'` | Benchmark name to use with PGO. | -| `use-cross` | No | `false` | Use cross-rs for building. If false, use cargo. | -| `additional-rustflags` | No | `''` | Additional RUSTFLAGS to pass to the Rust compiler | -| `additional-rustc-args` | No | `''` | Additional arguments to pass directly to `rustc` | -| `rust-toolchain` | No | `nightly` | The Rust toolchain to use. Can be nightly or a specific nightly version (e.g., nightly-2025-09-18). | -| `use-cache` | No | `true` | Enable or disable the build cache using `Swatinem/rust-cache`. | -| `upload-artifacts` | No | `true` | Upload the built artifacts as a GitHub Actions artifact | -| `upload-symbols-separately` | No | `true` | Upload debug symbol files (.pdb, .dwp, .dSYM) as separate artifacts instead of bundling with main artifacts | -| `abort-on-panic` | No | `true` | Abort immediately on panic. If false, the default panic handler is used. | -| `build-library` | No | `false` | Build a library instead of a binary. | -| `run-tests-and-coverage` | No | `false` | Run tests and coverage using the `devops-rust-test-and-coverage` action. | -| `size-optimized-std` | No | `false` | Builds `std` with size optimizations, such as reduced `core::fmt` footprint. | -| `additional-std-features` | No | `` | Specify extra `build-std` features. | +| Input | Required | Default | Description | +| --------------------------- | -------- | ---------------- | -------------------------------------------------------------------------------------------------------------------- | +| `rust-project-path` | No | `.` | Path to the Rust project | +| `workspace-path` | No | `.` | Workspace folder where `target` directory is. Uses `rust-project-path` if not set. | +| `pgo-project-path` | No | `.` | Path to the Rust project used for gathering PGO data. Can be same or separate project. | +| `crate-name` | Yes | | Name of the Rust crate/package. Used for naming the artifact/release asset. | +| `target` | Yes | | The target platform for the Rust compiler | +| `features` | No | `''` | Comma-separated list of features to include in the build | +| `no-default-features` | No | `false` | Do not include default features in the build | +| `use-pgo` | No | `false` | Use Profile-Guided Optimization [PGO] to build the library. | +| `pgo-benchmark-name` | No | `'my_benchmark'` | Benchmark name to use with PGO. | +| `use-cross` | No | `false` | Use cross-rs for building. If false, use cargo. | +| `additional-rustflags` | No | `''` | Additional RUSTFLAGS to pass to the Rust compiler | +| `additional-rustc-args` | No | `''` | Additional arguments to pass directly to `rustc` | +| `rust-toolchain` | No | `nightly` | The Rust toolchain to use. Can be nightly or a specific nightly version (e.g., nightly-2025-09-18). | +| `use-cache` | No | `true` | Enable or disable the build cache using `Swatinem/rust-cache`. | +| `upload-artifacts` | No | `true` | Upload the built artifacts as a GitHub Actions artifact | +| `upload-symbols-separately` | No | `true` | Upload debug symbol files (.pdb, .dwp, .dSYM) as separate artifacts instead of bundling with main artifacts | +| `abort-on-panic` | No | `true` | Abort immediately on panic. If false, the default panic handler is used. | +| `build-library` | No | `false` | Build a library instead of a binary. | +| `run-tests-and-coverage` | No | `false` | Run tests and coverage using the `devops-rust-test-and-coverage` action. | +| `size-optimized-std` | No | `false` | Builds `std` with size optimizations, such as reduced `core::fmt` footprint. | +| `additional-std-features` | No | `` | Specify extra `build-std` features. | +| `use-friendly-target-names` | No | `true` | Transform target triples to user-friendly names (e.g., `x86_64-unknown-linux-gnu` -> `linux-x64`) in artifact names. | #### Parameters Passed Through to `devops-rust-test-and-coverage` @@ -376,6 +377,10 @@ For binary builds, the artifact will be named `${{ inputs.crate-name }}-${{ inpu For library builds, the artifact will be named `C-Library-${{ inputs.crate-name }}-${{ inputs.target }}-${{ inputs.features }}`. +When `use-friendly-target-names` is enabled, the target triple in artifact names is replaced with a +user-friendly platform identifier (e.g., `x86_64-unknown-linux-gnu` becomes `linux-x64`, +`aarch64-apple-darwin` becomes `macos-arm64`). Unmapped targets fall back to the raw target triple. + When `upload-symbols-separately` is enabled (default), debug symbols are uploaded as separate artifacts: - Binary symbols: `${{ inputs.crate-name }}-${{ inputs.target }}-${{ inputs.features }}.symbols` diff --git a/action.yml b/action.yml index 6f058e1..bdfad52 100644 --- a/action.yml +++ b/action.yml @@ -131,6 +131,10 @@ inputs: description: "Additional arguments to pass to the cargo tarpaulin command" required: false default: "" + use-friendly-target-names: + description: "Transform target triples to user-friendly names (e.g., x86_64-unknown-linux-gnu -> linux-x64) in artifact names" + required: false + default: "true" runs: using: "composite" @@ -199,6 +203,13 @@ runs: - name: Generate artifact names shell: bash run: | + # Resolve target name for artifact (friendly or raw) + if [ "${{ inputs.use-friendly-target-names }}" == "true" ]; then + TARGET_FOR_ARTIFACT=$("$GITHUB_ACTION_PATH/scripts/get-friendly-target-name.sh" "${{ inputs.target }}") + else + TARGET_FOR_ARTIFACT="${{ inputs.target }}" + fi + # Generate feature suffix: -features if set, empty if not if [ -n "${{ inputs.features }}" ]; then FEATURE_SUFFIX="-${{ inputs.features }}" @@ -207,8 +218,8 @@ runs: fi # Generate full artifact names - BINARY_ARTIFACT_NAME="${{ inputs.crate-name }}-${{ inputs.target }}${FEATURE_SUFFIX}" - LIBRARY_ARTIFACT_NAME="C-Library-${{ inputs.crate-name }}-${{ inputs.target }}${FEATURE_SUFFIX}" + BINARY_ARTIFACT_NAME="${{ inputs.crate-name }}-${TARGET_FOR_ARTIFACT}${FEATURE_SUFFIX}" + LIBRARY_ARTIFACT_NAME="C-Library-${{ inputs.crate-name }}-${TARGET_FOR_ARTIFACT}${FEATURE_SUFFIX}" echo "BINARY_ARTIFACT_NAME=${BINARY_ARTIFACT_NAME}" >> $GITHUB_ENV echo "BINARY_SYMBOLS_ARTIFACT_NAME=${BINARY_ARTIFACT_NAME}.symbols" >> $GITHUB_ENV diff --git a/scripts/get-friendly-target-name.sh b/scripts/get-friendly-target-name.sh new file mode 100755 index 0000000..63ba27f --- /dev/null +++ b/scripts/get-friendly-target-name.sh @@ -0,0 +1,273 @@ +#!/usr/bin/env bash +# Transforms Rust target triples into user-friendly platform names. +# Usage: ./get-friendly-target-name.sh +# Outputs the friendly name if mapped, otherwise the original target triple. + +set -euo pipefail + +declare -A TARGET_MAP=( + # ============================================================================= + # Linux - glibc + # ============================================================================= + ["x86_64-unknown-linux-gnu"]="linux-x64" + ["i686-unknown-linux-gnu"]="linux-x86" + ["i586-unknown-linux-gnu"]="linux-i586" + ["aarch64-unknown-linux-gnu"]="linux-arm64" + ["aarch64_be-unknown-linux-gnu"]="linux-arm64-be" + ["arm-unknown-linux-gnueabi"]="linux-armv6" + ["arm-unknown-linux-gnueabihf"]="linux-armv6-hf" + ["armv5te-unknown-linux-gnueabi"]="linux-armv5te" + ["armv7-unknown-linux-gnueabi"]="linux-armv7" + ["armv7-unknown-linux-gnueabihf"]="linux-armv7-hf" + ["thumbv7neon-unknown-linux-gnueabihf"]="linux-armv7-neon-hf" + ["loongarch64-unknown-linux-gnu"]="linux-loongarch64" + ["riscv64gc-unknown-linux-gnu"]="linux-riscv64" + ["riscv32gc-unknown-linux-gnu"]="linux-riscv32" + ["powerpc-unknown-linux-gnu"]="linux-ppc" + ["powerpc64-unknown-linux-gnu"]="linux-ppc64" + ["powerpc64le-unknown-linux-gnu"]="linux-ppc64le" + ["s390x-unknown-linux-gnu"]="linux-s390x" + ["sparc64-unknown-linux-gnu"]="linux-sparc64" + ["mips-unknown-linux-gnu"]="linux-mips" + ["mipsel-unknown-linux-gnu"]="linux-mipsel" + ["mips64-unknown-linux-gnuabi64"]="linux-mips64" + ["mips64el-unknown-linux-gnuabi64"]="linux-mips64el" + + # ============================================================================= + # Linux - musl + # ============================================================================= + ["x86_64-unknown-linux-musl"]="linux-x64-musl" + ["i686-unknown-linux-musl"]="linux-x86-musl" + ["i586-unknown-linux-musl"]="linux-i586-musl" + ["aarch64-unknown-linux-musl"]="linux-arm64-musl" + ["aarch64_be-unknown-linux-musl"]="linux-arm64-be-musl" + ["arm-unknown-linux-musleabi"]="linux-armv6-musl" + ["arm-unknown-linux-musleabihf"]="linux-armv6-hf-musl" + ["armv5te-unknown-linux-musleabi"]="linux-armv5te-musl" + ["armv7-unknown-linux-musleabi"]="linux-armv7-musl" + ["armv7-unknown-linux-musleabihf"]="linux-armv7-hf-musl" + ["loongarch64-unknown-linux-musl"]="linux-loongarch64-musl" + ["riscv64gc-unknown-linux-musl"]="linux-riscv64-musl" + ["powerpc64le-unknown-linux-musl"]="linux-ppc64le-musl" + ["s390x-unknown-linux-musl"]="linux-s390x-musl" + ["mips-unknown-linux-musl"]="linux-mips-musl" + ["mipsel-unknown-linux-musl"]="linux-mipsel-musl" + ["mips64-unknown-linux-muslabi64"]="linux-mips64-musl" + ["mips64el-unknown-linux-muslabi64"]="linux-mips64el-musl" + ["hexagon-unknown-linux-musl"]="linux-hexagon-musl" + + # ============================================================================= + # Windows - MSVC + # ============================================================================= + ["x86_64-pc-windows-msvc"]="windows-x64" + ["i686-pc-windows-msvc"]="windows-x86" + ["aarch64-pc-windows-msvc"]="windows-arm64" + ["arm64ec-pc-windows-msvc"]="windows-arm64ec" + ["thumbv7a-pc-windows-msvc"]="windows-thumbv7a" + + # ============================================================================= + # Windows - GNU (MinGW) + # ============================================================================= + ["x86_64-pc-windows-gnu"]="windows-x64-gnu" + ["i686-pc-windows-gnu"]="windows-x86-gnu" + ["x86_64-pc-windows-gnullvm"]="windows-x64-gnullvm" + ["i686-pc-windows-gnullvm"]="windows-x86-gnullvm" + ["aarch64-pc-windows-gnullvm"]="windows-arm64-gnullvm" + + # ============================================================================= + # macOS / Darwin + # ============================================================================= + ["x86_64-apple-darwin"]="macos-x64" + ["aarch64-apple-darwin"]="macos-arm64" + ["arm64e-apple-darwin"]="macos-arm64e" + ["i686-apple-darwin"]="macos-x86" + ["x86_64h-apple-darwin"]="macos-x64-haswell" + + # ============================================================================= + # iOS + # ============================================================================= + ["aarch64-apple-ios"]="ios-arm64" + ["aarch64-apple-ios-sim"]="ios-arm64-sim" + ["aarch64-apple-ios-macabi"]="ios-arm64-catalyst" + ["arm64e-apple-ios"]="ios-arm64e" + ["armv7s-apple-ios"]="ios-armv7s" + ["x86_64-apple-ios"]="ios-x64" + ["x86_64-apple-ios-macabi"]="ios-x64-catalyst" + ["i386-apple-ios"]="ios-x86" + + # ============================================================================= + # tvOS + # ============================================================================= + ["aarch64-apple-tvos"]="tvos-arm64" + ["aarch64-apple-tvos-sim"]="tvos-arm64-sim" + ["arm64e-apple-tvos"]="tvos-arm64e" + ["x86_64-apple-tvos"]="tvos-x64" + + # ============================================================================= + # watchOS + # ============================================================================= + ["aarch64-apple-watchos"]="watchos-arm64" + ["aarch64-apple-watchos-sim"]="watchos-arm64-sim" + ["arm64_32-apple-watchos"]="watchos-arm64_32" + ["armv7k-apple-watchos"]="watchos-armv7k" + ["x86_64-apple-watchos-sim"]="watchos-x64-sim" + + # ============================================================================= + # visionOS + # ============================================================================= + ["aarch64-apple-visionos"]="visionos-arm64" + ["aarch64-apple-visionos-sim"]="visionos-arm64-sim" + + # ============================================================================= + # Android + # ============================================================================= + ["aarch64-linux-android"]="android-arm64" + ["armv7-linux-androideabi"]="android-armv7" + ["arm-linux-androideabi"]="android-armv6" + ["thumbv7neon-linux-androideabi"]="android-armv7-neon" + ["x86_64-linux-android"]="android-x64" + ["i686-linux-android"]="android-x86" + ["riscv64-linux-android"]="android-riscv64" + + # ============================================================================= + # Game Consoles + # ============================================================================= + ["aarch64-nintendo-switch-freestanding"]="switch-arm64" + ["armv6k-nintendo-3ds"]="3ds-armv6k" + ["armv7-sony-vita-newlibeabihf"]="psvita-armv7-hf" + ["mipsel-sony-psp"]="psp-mipsel" + ["mipsel-sony-psx"]="ps1-mipsel" + + # ============================================================================= + # BSD Family + # ============================================================================= + ["x86_64-unknown-freebsd"]="freebsd-x64" + ["i686-unknown-freebsd"]="freebsd-x86" + ["aarch64-unknown-freebsd"]="freebsd-arm64" + ["armv6-unknown-freebsd"]="freebsd-armv6" + ["armv7-unknown-freebsd"]="freebsd-armv7" + ["powerpc64-unknown-freebsd"]="freebsd-ppc64" + ["powerpc64le-unknown-freebsd"]="freebsd-ppc64le" + ["riscv64gc-unknown-freebsd"]="freebsd-riscv64" + + ["x86_64-unknown-netbsd"]="netbsd-x64" + ["i686-unknown-netbsd"]="netbsd-x86" + ["aarch64-unknown-netbsd"]="netbsd-arm64" + ["armv6-unknown-netbsd-eabihf"]="netbsd-armv6-hf" + ["armv7-unknown-netbsd-eabihf"]="netbsd-armv7-hf" + ["sparc64-unknown-netbsd"]="netbsd-sparc64" + ["riscv64gc-unknown-netbsd"]="netbsd-riscv64" + ["mipsel-unknown-netbsd"]="netbsd-mipsel" + ["powerpc-unknown-netbsd"]="netbsd-ppc" + + ["x86_64-unknown-openbsd"]="openbsd-x64" + ["i686-unknown-openbsd"]="openbsd-x86" + ["aarch64-unknown-openbsd"]="openbsd-arm64" + ["sparc64-unknown-openbsd"]="openbsd-sparc64" + ["powerpc64-unknown-openbsd"]="openbsd-ppc64" + ["riscv64gc-unknown-openbsd"]="openbsd-riscv64" + + ["x86_64-unknown-dragonfly"]="dragonfly-x64" + + # ============================================================================= + # Solaris / illumos + # ============================================================================= + ["x86_64-pc-solaris"]="solaris-x64" + ["sparcv9-sun-solaris"]="solaris-sparc64" + ["x86_64-unknown-illumos"]="illumos-x64" + ["aarch64-unknown-illumos"]="illumos-arm64" + + # ============================================================================= + # Redox OS + # ============================================================================= + ["x86_64-unknown-redox"]="redox-x64" + ["aarch64-unknown-redox"]="redox-arm64" + ["i586-unknown-redox"]="redox-i586" + + # ============================================================================= + # Fuchsia + # ============================================================================= + ["x86_64-unknown-fuchsia"]="fuchsia-x64" + ["aarch64-unknown-fuchsia"]="fuchsia-arm64" + ["riscv64gc-unknown-fuchsia"]="fuchsia-riscv64" + + # ============================================================================= + # Haiku + # ============================================================================= + ["x86_64-unknown-haiku"]="haiku-x64" + ["i686-unknown-haiku"]="haiku-x86" + + # ============================================================================= + # WebAssembly + # ============================================================================= + ["wasm32-unknown-unknown"]="wasm32" + ["wasm32-unknown-emscripten"]="wasm32-emscripten" + ["wasm32-wasip1"]="wasm32-wasip1" + ["wasm32-wasip1-threads"]="wasm32-wasip1-threads" + ["wasm32-wasip2"]="wasm32-wasip2" + ["wasm32-wasip3"]="wasm32-wasip3" + ["wasm32v1-none"]="wasm32v1" + ["wasm64-unknown-unknown"]="wasm64" + + # ============================================================================= + # UEFI + # ============================================================================= + ["x86_64-unknown-uefi"]="uefi-x64" + ["i686-unknown-uefi"]="uefi-x86" + ["aarch64-unknown-uefi"]="uefi-arm64" + + # ============================================================================= + # QNX Neutrino RTOS + # ============================================================================= + ["aarch64-unknown-nto-qnx710"]="qnx710-arm64" + ["aarch64-unknown-nto-qnx800"]="qnx800-arm64" + ["x86_64-pc-nto-qnx710"]="qnx710-x64" + ["x86_64-pc-nto-qnx800"]="qnx800-x64" + ["i686-pc-nto-qnx700"]="qnx700-x86" + + # ============================================================================= + # VxWorks RTOS + # ============================================================================= + ["x86_64-wrs-vxworks"]="vxworks-x64" + ["i686-wrs-vxworks"]="vxworks-x86" + ["aarch64-wrs-vxworks"]="vxworks-arm64" + ["armv7-wrs-vxworks-eabihf"]="vxworks-armv7-hf" + ["powerpc-wrs-vxworks"]="vxworks-ppc" + ["powerpc64-wrs-vxworks"]="vxworks-ppc64" + ["riscv32-wrs-vxworks"]="vxworks-riscv32" + ["riscv64-wrs-vxworks"]="vxworks-riscv64" + + # ============================================================================= + # ESP32 / Xtensa + # ============================================================================= + ["xtensa-esp32-espidf"]="esp32" + ["xtensa-esp32-none-elf"]="esp32-baremetal" + ["xtensa-esp32s2-espidf"]="esp32s2" + ["xtensa-esp32s2-none-elf"]="esp32s2-baremetal" + ["xtensa-esp32s3-espidf"]="esp32s3" + ["xtensa-esp32s3-none-elf"]="esp32s3-baremetal" + ["riscv32imc-esp-espidf"]="esp32c3" + ["riscv32imac-esp-espidf"]="esp32c6" + + # ============================================================================= + # NVIDIA GPU (PTX) + # ============================================================================= + ["nvptx64-nvidia-cuda"]="cuda-ptx64" + + # ============================================================================= + # Hermit Unikernel + # ============================================================================= + ["x86_64-unknown-hermit"]="hermit-x64" + ["aarch64-unknown-hermit"]="hermit-arm64" + ["riscv64gc-unknown-hermit"]="hermit-riscv64" +) + +TARGET="${1:-}" +if [[ -z "$TARGET" ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +# Lookup in map, fallback to original if not found +FRIENDLY_NAME="${TARGET_MAP[$TARGET]:-$TARGET}" +echo "$FRIENDLY_NAME"