| # 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. |
| |
| # TODO: |
| # - generate shasum for each published zip, include it in metadata.yaml and in the release description |
| # - consider stripping debug symbols from binaries |
| # - generate RELEASE.md changelog |
| # - change ubuntu to alpine in Dockerfile.ci and Dockerfile |
| # - merge Docker meta into one step |
| |
| name: test_pr |
| on: |
| workflow_dispatch: |
| workflow_call: |
| pull_request: |
| branches: |
| - master |
| types: [ opened, synchronize, reopened ] |
| |
| env: |
| CRATE_NAME: iggy |
| GITHUB_TOKEN: ${{ github.token }} |
| RUST_BACKTRACE: 1 |
| CARGO_TERM_COLOR: always |
| IGGY_CI_BUILD: true |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| sanity: |
| name: check |
| uses: ./.github/workflows/sanity.yml |
| |
| coverage: |
| name: Code coverage |
| if: | |
| (github.event_name == 'pull_request' && |
| (contains(github.event.pull_request.changed_files, '.rs') || |
| contains(github.event.pull_request.changed_files, 'Cargo.toml') || |
| contains(github.event.pull_request.changed_files, 'Cargo.lock'))) |
| || |
| (github.event_name == 'push' && |
| (contains(github.event.head_commit.modified, '.rs') || |
| contains(github.event.head_commit.modified, 'Cargo.toml') || |
| contains(github.event.head_commit.modified, 'Cargo.lock'))) |
| uses: ./.github/workflows/ci-coverage-rust.yml |
| needs: sanity |
| |
| backwards_compatibility: |
| name: Backwards compatibility |
| uses: ./.github/workflows/ci-compatibility-rust.yml |
| needs: sanity |
| with: |
| pr_body: ${{ github.event.pull_request.body }} |
| |
| build_and_test: |
| needs: sanity |
| name: 'build and test Linux-x86_64-musl' |
| runs-on: ubuntu-latest |
| timeout-minutes: 45 |
| strategy: |
| fail-fast: false |
| |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - name: Cache cargo & target directories |
| uses: Swatinem/rust-cache@v2 |
| with: |
| key: "test-pr-x86_64-unknown-linux-musl" |
| |
| - name: Install musl-tools, gnome-keyring and keyutils on Linux |
| 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 x86_64-unknown-linux-musl toolchain |
| uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| override: true |
| target: x86_64-unknown-linux-musl |
| |
| - name: Install cross |
| uses: taiki-e/install-action@v2 |
| with: |
| tool: cross |
| |
| - name: Build binary x86_64-unknown-linux-musl |
| run: cross +stable build --verbose --target x86_64-unknown-linux-musl |
| |
| - name: Run tests x86_64-unknown-linux-musl |
| run: cross +stable test --verbose --target x86_64-unknown-linux-musl |
| |
| - name: Check CLI examples from README |
| run: ./scripts/run-examples-from-readme.sh |
| |
| - name: Check if workspace is clean |
| run: git status | grep "working tree clean" || { git status ; exit 1; } |
| |
| # TODO: below job is non-blocking: temporary solution until we decide whether |
| # we want to use the new M1 macs for CI, determine cost and performance |
| build_and_test_macos: |
| needs: sanity |
| name: build and test macOS-aarch64 |
| runs-on: macos-latest |
| timeout-minutes: 30 |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| override: true |
| |
| - name: Cache cargo & target directories |
| uses: Swatinem/rust-cache@v2 |
| with: |
| key: "test-pr-aarch64-apple-darwin" |
| |
| - name: Build binary |
| run: cargo build --verbose --target aarch64-apple-darwin |
| |
| - name: Run cargo clippy |
| run: cargo clippy --all-targets --all-features -- -D warnings |
| |
| - name: Run tests |
| run: cargo test --verbose --target aarch64-apple-darwin |
| |
| build_windows: |
| needs: sanity |
| name: build Windows |
| runs-on: windows-latest |
| timeout-minutes: 30 |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| override: true |
| |
| - name: Cache cargo & target directories |
| uses: Swatinem/rust-cache@v2 |
| with: |
| key: "test-pr-x86_64-pc-windows-msvc" |
| |
| - name: Build iggy package |
| run: cargo build --verbose --target x86_64-pc-windows-msvc -p iggy |
| |
| - name: Build iggy-cli binary |
| run: cargo build --verbose --target x86_64-pc-windows-msvc --bin iggy |
| |
| finalize_pr: |
| runs-on: ubuntu-latest |
| needs: |
| - sanity |
| - coverage |
| - backwards_compatibility |
| - build_windows |
| - build_and_test |
| if: always() |
| steps: |
| - name: Everything is fine |
| if: ${{ !(contains(needs.*.result, 'failure')) }} |
| run: exit 0 |
| |
| - name: Some tests failed |
| if: ${{ contains(needs.*.result, 'failure') }} |
| run: exit 1 |