Skip to content

ci(test): migrate to two-stage smoke tests #1992

ci(test): migrate to two-stage smoke tests

ci(test): migrate to two-stage smoke tests #1992

Workflow file for this run

name: test
on:
pull_request:
push:
branches:
- master
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# https://users.rust-lang.org/t/cross-compiling-how-to-statically-link-glibc/83907/2
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
jobs:
skip-check:
continue-on-error: false
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
concurrent_skipping: same_content
do_not_skip: '["pull_request"]'
build:
name: Build test binaries for ${{ matrix.target }}
needs: skip-check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
target2: aarch64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
target2: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
target2: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v3
- name: Setup extra build tools
if: matrix.target2 == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }},${{ matrix.target2 }}
- id: cache_build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
- name: Build
if: ${{ !steps.cache_build.outputs.cache-hit }}
run: |
cargo build --verbose --all-targets --target=${{ matrix.target }}
cargo build --verbose --release --locked --target=${{ matrix.target2 }}
choco-test:
runs-on: windows-latest
needs: build
if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Download cached build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
save-if: false
- name: Build and run tests
env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
run: |
cargo build --verbose
cargo test --features=test tests
cargo test --features=test choco -- --test-threads=1
cargo test --features=test choco -- --ignored --test-threads=1
scoop-winget-test:
runs-on: windows-latest
needs: build
if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Download cached build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
save-if: false
- name: Install scoop
shell: powershell
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
iwr -useb 'https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1' -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
(Resolve-Path ~\scoop\shims).Path >> $Env:GITHUB_PATH
- name: Verity scoop installation
run: |
Get-Command scoop
powershell scoop help
# Ironically, to install winget we need to install scoop first :D
# See: https://github.com/microsoft/winget-cli/issues/1328#issuecomment-1208640211
- name: Install winget
shell: powershell
run: scoop install winget
- name: Verity winget installation
run: |
Get-Command winget
winget --info
- name: Build and run tests
env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
run: |
cargo build --verbose
cargo test --features=test tests
cargo test --features=test scoop
cargo test --features=test winget
cargo test --features=test scoop -- --ignored
cargo test --features=test winget -- --ignored
brew-test:
runs-on: macos-latest
needs: build
if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Download cached build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
save-if: false
- name: Build and run tests
env:
CARGO_BUILD_TARGET: x86_64-apple-darwin
run: |
cargo build --verbose
cargo test --features=test tests
cargo test --features=test brew
cargo test --features=test brew -- --ignored
port-test:
runs-on: macos-latest
needs: build
if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Get OS build
run: |
sw_vers > macos_build.txt
cat macos_build.txt
# https://github.com/actions/cache/issues/629#issuecomment-1189184648
- name: Create gtar wrapper
uses: fertrig/[email protected]
with:
path: target
file: gtar
content: |
#!/bin/sh
exec sudo /usr/local/bin/gtar.orig "$@"
- name: Install gtar wrapper
run: |
sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig
sudo mv target/gtar /usr/local/bin/gtar
sudo chmod +x /usr/local/bin/gtar
- name: Cache MacPorts
id: cache-macports
uses: actions/cache@v3
with:
path: /opt/local/
key: ${{ runner.os }}-macports-${{ hashFiles('macos_build.txt') }}
- name: Restore MacPorts PATH
if: steps.cache-macports.outputs.cache-hit == 'true'
run: echo "/opt/local/bin" >> "$GITHUB_PATH"
- name: Install MacPorts
if: steps.cache-macports.outputs.cache-hit != 'true'
run: |
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
source ./macports-ci install
sudo port install wget
port installed
- name: Download cached build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
save-if: false
- name: Build and run tests
env:
CARGO_BUILD_TARGET: x86_64-apple-darwin
run: |
cargo build --verbose
cargo test --features=test tests
cargo test --features=test port
cargo test --features=test port -- --ignored
apt-test:
runs-on: ubuntu-latest
needs: build
if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Download cached build
uses: Swatinem/rust-cache@v2
with:
shared-key: pacaptr-test-${{ runner.os }}-${{ runner.arch }}
save-if: false
- name: Build and run tests
env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
run: |
cargo build --verbose
cargo test --features=test tests
cargo test --features=test apt
cargo test --features=test apt -- --ignored
# dnf-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# container:
# image: fedora:latest
# steps:
# - uses: actions/checkout@v3
# - run: dnf install -y make automake gcc gcc-c++ kernel-devel
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - name: Build
# run: cargo build --verbose
# - name: Run unit tests
# run: cargo test --features=test tests
# - name: Run smoke tests
# run: cargo test --features=test dnf
# - name: Run heavy tests
# run: cargo test --features=test dnf -- --ignored
# emerge-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# container:
# image: gentoo/stage3
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# # `pacaptr -Ss` might fail without this line.
# - run: emerge --sync || true
# - name: Build
# run: cargo build --verbose
# - name: Run unit tests
# run: cargo test --features=test tests
# - name: Run smoke tests
# run: cargo test --features=test emerge
# - name: Run heavy tests
# run: cargo test --features=test emerge -- --ignored
# xbps-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# container:
# image: voidlinux/voidlinux:latest
# steps:
# - name: Install required packages
# run: |
# xbps-install -y -Su || (xbps-install -y -u xbps && xbps-install -y -Su)
# xbps-install -y base-devel curl bash
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - name: Build
# run: cargo build --verbose
# - name: Run unit tests
# run: cargo test --features=test tests
# - name: Run smoke tests
# run: cargo test --features=test xbps
# - name: Run heavy tests
# run: cargo test --features=test xbps -- --ignored
# zypper-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# container:
# image: opensuse/leap:latest
# steps:
# - run: zypper install -y tar gzip curl gcc bash
# - uses: actions/checkout@v3
# # uses: dtolnay/rust-toolchain@stable
# - name: Set up Rust environment manually
# run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# - uses: Swatinem/rust-cache@v2
# - name: Build
# run: $HOME/.cargo/bin/cargo build --verbose
# - name: Run unit tests
# run: $HOME/.cargo/bin/cargo test --features=test tests
# - name: Run smoke tests
# run: $HOME/.cargo/bin/cargo test --features=test zypper -- --test-threads=1
# - name: Run heavy tests
# run: $HOME/.cargo/bin/cargo test --features=test zypper -- --ignored --test-threads=1
# apk-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# container:
# image: rust:alpine
# env:
# RUSTFLAGS: "-C target-feature=-crt-static"
# steps:
# - uses: actions/checkout@v3
# - run: apk add -U build-base tar bash
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - name: Build
# run: cargo build --verbose
# - name: Run unit tests
# run: cargo test --features=test tests
# - name: Run smoke tests
# run: cargo test --features=test apk
# - name: Run heavy tests
# run: cargo test --features=test apk -- --ignored
# pkcon-pip-conda-test:
# runs-on: ubuntu-latest
# needs: skip-check
# if: ${{ needs.skip-check.outputs.should_skip != 'true' }}
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - run: |
# sudo apt update
# sudo apt install -y packagekit packagekit-tools
# - name: Build
# run: cargo build --verbose
# - name: Run smoke tests
# run: |
# cargo test --features=test pkcon
# cargo test --features=test pip
# cargo test --features=test conda
# - name: Run heavy tests
# run: |
# cargo test --features=test pkcon -- --ignored
# cargo test --features=test pip -- --ignored
# cargo test --features=test conda -- --ignored