blob: da2cfcfdc3c27d50d5e124a0daa48dec99928124 [file] [edit]
name: CI - Rust
on:
workflow_call:
inputs:
release:
required: false
type: boolean
default: false
branch:
required: false
type: string
default: trunk
secrets:
SELENIUM_CI_TOKEN:
required: true
workflow_dispatch:
permissions:
contents: read
env:
# Keep in sync with the rust_toolchains version in MODULE.bazel
RUST_VERSION: "1.98.1"
jobs:
tests:
name: Tests
if: ${{ !inputs.release }}
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
matrix:
include:
- os: macos
- os: ubuntu
- os: ubuntu-24.04-arm
- os: windows
with:
name: Tests (${{ matrix.os }})
os: ${{ matrix.os }}
rerun-with-debug: true
run: bazel test --test_env=RUST_BACKTRACE=full --test_env=RUST_TEST_NOCAPTURE=1 --flaky_test_attempts=3 //rust/...
windows-stable:
name: "Windows Stable"
runs-on: windows-latest
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' }}
env:
RUSTFLAGS: '-Ctarget-feature=+crt-static'
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}-i686-pc-windows-msvc
rustup default ${{ env.RUST_VERSION }}-i686-pc-windows-msvc
rustc -vV
- name: "Build release binary"
run: cargo build --release
working-directory: rust
- name: "Rename binary"
run: mv rust/target/release/selenium-manager.exe selenium-manager-windows.exe
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: selenium-manager-windows
path: selenium-manager-windows.exe
retention-days: 6
windows-debug:
name: "Windows Debug"
runs-on: windows-latest
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' && github.event.repository.fork == false && (github.ref == 'refs/heads/trunk' || inputs.release) }}
env:
RUSTFLAGS: '-Ctarget-feature=+crt-static'
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}-i686-pc-windows-msvc
rustup default ${{ env.RUST_VERSION }}-i686-pc-windows-msvc
rustc -vV
- name: "Build release binary"
run: cargo build --profile dev
working-directory: rust
- name: "Rename binary"
run: mv rust/target/debug/selenium-manager.exe selenium-manager-windows-debug.exe
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: selenium-manager-windows-debug
path: selenium-manager-windows-debug.exe
retention-days: 6
linux-stable:
name: "Linux Stable (${{ matrix.arch }})"
runs-on: ${{ matrix.runner }}
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: selenium-manager-linux-x86_64
- arch: aarch64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
artifact: selenium-manager-linux-arm64
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install musl toolchain"
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}
rustup default ${{ env.RUST_VERSION }}
rustup target add ${{ matrix.target }}
rustc -vV
- name: "Build release binary"
run: cargo build --target ${{ matrix.target }} --release
working-directory: rust
env:
TARGET_CC: musl-gcc
- name: "Rename binary"
run: mv rust/target/${{ matrix.target }}/release/selenium-manager ${{ matrix.artifact }}
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
retention-days: 6
linux-debug:
name: "Linux Debug (${{ matrix.arch }})"
runs-on: ${{ matrix.runner }}
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' && github.event.repository.fork == false && (github.ref == 'refs/heads/trunk' || inputs.release) }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: selenium-manager-linux-x86_64-debug
- arch: aarch64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
artifact: selenium-manager-linux-arm64-debug
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install musl toolchain"
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}
rustup default ${{ env.RUST_VERSION }}
rustup target add ${{ matrix.target }}
rustc -vV
- name: "Build release binary"
run: |
cargo build --target ${{ matrix.target }} --profile dev
cd target/${{ matrix.target }}/debug
tar -cvf ../../../../${{ matrix.artifact }}.tar selenium-manager
working-directory: rust
env:
TARGET_CC: musl-gcc
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.tar
retention-days: 6
macos-stable:
name: "MacOS Stable"
runs-on: macos-latest
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' }}
env:
RUSTFLAGS: '-Ctarget-feature=+crt-static'
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}
rustup default ${{ env.RUST_VERSION }}
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustc -vV
- name: "Build release binary"
run: |
cargo build --target x86_64-apple-darwin --release
cargo build --target aarch64-apple-darwin --release
lipo -create -output target/selenium-manager-macos \
target/aarch64-apple-darwin/release/selenium-manager \
target/x86_64-apple-darwin/release/selenium-manager
working-directory: rust
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: selenium-manager-macos
path: rust/target/selenium-manager-macos
retention-days: 6
macos-debug:
name: "MacOS Debug"
runs-on: macos-latest
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' && github.event.repository.fork == false && (github.ref == 'refs/heads/trunk' || inputs.release) }}
env:
RUSTFLAGS: '-Ctarget-feature=+crt-static'
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}
rustup default ${{ env.RUST_VERSION }}
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustc -vV
- name: "Build release binary"
run: |
cargo build --target x86_64-apple-darwin --profile dev
cargo build --target aarch64-apple-darwin --profile dev
lipo -create -output target/selenium-manager \
target/aarch64-apple-darwin/debug/selenium-manager \
target/x86_64-apple-darwin/debug/selenium-manager
cd target
tar -cvf ../../selenium-manager-macos-debug.tar selenium-manager
working-directory: rust
- name: "Upload release binary"
uses: actions/upload-artifact@v7
with:
name: selenium-manager-macos-debug
path: selenium-manager-macos-debug.tar
retention-days: 6
sbom:
name: "SBOM and Notices"
runs-on: ubuntu-latest
needs: tests
if: ${{ !cancelled() && needs.tests.result != 'failure' && github.event_name != 'schedule' && github.event.repository.fork == false && (github.ref == 'refs/heads/trunk' || inputs.release) }}
steps:
- name: "Checkout project"
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: "Install Rust toolchain"
run: |
rustup toolchain install ${{ env.RUST_VERSION }}
rustup default ${{ env.RUST_VERSION }}
rustc -vV
- name: "Install SBOM tools"
run: cargo install --locked cargo-cyclonedx@0.5.7 cargo-about@0.6.6
- name: "Generate SBOM and third-party notices"
working-directory: rust
run: |
# --target all includes target-gated crates for every platform, not just the host.
cargo cyclonedx --format json --all-features --target all
cargo about generate about.hbs > selenium-manager-THIRD-PARTY-NOTICES.txt
- name: "Upload SBOM and notices"
uses: actions/upload-artifact@v7
with:
name: selenium-manager-sbom
path: |
rust/selenium-manager.cdx.json
rust/selenium-manager-THIRD-PARTY-NOTICES.txt
retention-days: 6
release:
name: "Release Binaries"
runs-on: ubuntu-latest
needs: [ macos-stable, linux-stable, windows-stable, macos-debug, linux-debug, windows-debug, sbom ]
if: github.event_name != 'schedule' && github.event.repository.fork == false && (github.ref == 'refs/heads/trunk' || inputs.release)
steps:
- name: "Checkout selenium_manager_artifacts"
uses: actions/checkout@v6
with:
token: ${{ secrets.SELENIUM_CI_TOKEN }}
repository: SeleniumHQ/selenium_manager_artifacts
- name: "Download Artifacts"
uses: actions/download-artifact@v8
with:
path: artifacts
- name: "Prepare and Commit"
run: |
linux_x86_64_sha=$(shasum -a 256 artifacts/selenium-manager-linux-x86_64/selenium-manager-linux-x86_64 | awk '{print $1}')
linux_arm64_sha=$(shasum -a 256 artifacts/selenium-manager-linux-arm64/selenium-manager-linux-arm64 | awk '{print $1}')
macos_sha=$(shasum -a 256 artifacts/selenium-manager-macos/selenium-manager-macos | awk '{print $1}')
windows_sha=$(shasum -a 256 artifacts/selenium-manager-windows/selenium-manager-windows.exe | awk '{print $1}')
sbom_sha=$(shasum -a 256 artifacts/selenium-manager-sbom/selenium-manager.cdx.json | awk '{print $1}')
notice_sha=$(shasum -a 256 artifacts/selenium-manager-sbom/selenium-manager-THIRD-PARTY-NOTICES.txt | awk '{print $1}')
echo "{\"macos\": \"$macos_sha\", \"windows\": \"$windows_sha\", \"linux-x86_64\": \"$linux_x86_64_sha\", \"linux-arm64\": \"$linux_arm64_sha\", \"sbom\": \"$sbom_sha\", \"notice\": \"$notice_sha\"}" > latest.json
git config --local user.email "selenium-ci@users.noreply.github.com"
git config --local user.name "Selenium CI Bot"
git add latest.json
git commit -m "Update hash values for latest binaries"
short_hash=$(git rev-parse --short HEAD)
echo "TAG_NAME=selenium-manager-$short_hash" >> "$GITHUB_ENV"
git tag "selenium-manager-$short_hash"
git push && git push --tags
- name: "Release"
uses: softprops/action-gh-release@v3
with:
token: ${{ secrets.SELENIUM_CI_TOKEN }}
repository: SeleniumHQ/selenium_manager_artifacts
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
artifacts/selenium-manager-linux-x86_64/selenium-manager-linux-x86_64
artifacts/selenium-manager-linux-arm64/selenium-manager-linux-arm64
artifacts/selenium-manager-macos/selenium-manager-macos
artifacts/selenium-manager-windows/selenium-manager-windows.exe
artifacts/selenium-manager-linux-x86_64-debug/selenium-manager-linux-x86_64-debug.tar
artifacts/selenium-manager-linux-arm64-debug/selenium-manager-linux-arm64-debug.tar
artifacts/selenium-manager-macos-debug/selenium-manager-macos-debug.tar
artifacts/selenium-manager-windows-debug/selenium-manager-windows-debug.exe
artifacts/selenium-manager-sbom/selenium-manager.cdx.json
artifacts/selenium-manager-sbom/selenium-manager-THIRD-PARTY-NOTICES.txt