| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| # ------------------------------------------------------------- |
| # |
| # CI Test Rust Workflow |
| # |
| # This workflow runs tests for Rust code. |
| # All tests are run on multiple targets: |
| # - x86_64-unknown-linux-musl |
| # - x86_64-unknown-linux-gnu |
| # - x86_64-pc-windows-msvc |
| # |
| # This workflow can be triggered manually or by other workflows. |
| # |
| name: ci-test-rust |
| |
| on: |
| workflow_dispatch: |
| workflow_call: |
| |
| env: |
| RUST_BACKTRACE: 1 |
| CARGO_TERM_COLOR: always |
| IGGY_CI_BUILD: true |
| |
| jobs: |
| x86_64-unknown-linux: |
| name: ${{ matrix.target }} |
| runs-on: ubuntu-latest |
| timeout-minutes: 30 |
| strategy: |
| matrix: |
| target: [x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu] |
| steps: |
| - name: Checkout code |
| uses: actions/checkout@v4 |
| - name: Cache cargo & target directories |
| uses: Swatinem/rust-cache@v2 |
| with: |
| key: "${{ matrix.target }}" |
| - name: Install musl-tools, gnome-keyring and keyutils |
| run: | |
| sudo apt-get update --yes && sudo apt-get install --yes musl-tools gnome-keyring keyutils |
| rm -f $HOME/.local/share/keyrings/* |
| echo -n "test" | gnome-keyring-daemon --unlock |
| - name: Prepare ${{ matrix.target }} toolchain |
| run: | |
| rustup toolchain add --profile=minimal stable |
| rustup target add --toolchain=stable ${{ matrix.target }} |
| rustup override set stable |
| - name: Set verbose flag |
| shell: bash |
| run: echo "VERBOSE_FLAG=$([[ "${RUNNER_DEBUG}" = "1" ]] && echo "--verbose" || echo "")" >> $GITHUB_ENV |
| - name: Build binary ${{ matrix.target }} |
| run: cargo build ${{ env.VERBOSE_FLAG }} --target ${{ matrix.target }} |
| - name: Run tests ${{ matrix.target }} |
| run: cargo test ${{ env.VERBOSE_FLAG }} --target ${{ matrix.target }} |
| - name: Check CLI examples from README |
| run: ./scripts/run-rust-examples-from-readme.sh ${{ matrix.target }} |
| - name: Check if workspace is clean |
| run: git status --porcelain |
| |
| x86_64-pc-windows-msvc: |
| name: x86_64-pc-windows-msvc |
| runs-on: windows-latest |
| timeout-minutes: 30 |
| steps: |
| - name: Checkout code |
| uses: actions/checkout@v4 |
| - name: Cache cargo & target directories |
| uses: Swatinem/rust-cache@v2 |
| with: |
| key: "x86_64-pc-windows-msvc" |
| - name: Prepare x86_64-pc-windows-msvc toolchain |
| run: | |
| rustup toolchain add --profile=minimal stable |
| rustup target add --toolchain=stable x86_64-pc-windows-msvc |
| rustup override set stable |
| - name: Set verbose flag |
| shell: pwsh |
| run: | |
| if ($env:RUNNER_DEBUG -eq "1") { |
| echo "VERBOSE_FLAG=--verbose" >> $env:GITHUB_ENV |
| } else { |
| echo "VERBOSE_FLAG=" >> $env:GITHUB_ENV |
| } |
| - name: Build iggy package |
| run: cargo build ${{ env.VERBOSE_FLAG }} --target x86_64-pc-windows-msvc -p iggy |
| - name: Build iggy-cli binary |
| run: cargo build ${{ env.VERBOSE_FLAG }} --target x86_64-pc-windows-msvc --bin iggy |
| - name: Check if workspace is clean |
| run: git status --porcelain |