Skip to content

Add packages input for selective package testing #3

Add packages input for selective package testing

Add packages input for selective package testing #3

name: Test Packages Input
# This workflow is a black-box integration test for the action's `packages` input.
#
# The fixture workspace contains three crates (package-a/package-b/package-c). Each crate writes a
# marker file (marker-package-*) when its tests run. We assert marker presence/absence to prove
# that:
# - when `packages` is empty, the action runs the whole workspace (`--all`)
# - when `packages` is provided, the action uses `-p <pkg>` and only runs those packages
#
# The fixture workspace also sets `default-members = ["package-a"]` to catch regressions where
# the action accidentally stops passing `--all` for the default (empty packages) case.
on:
workflow_dispatch:
pull_request:
branches: [v1-master]
paths:
- "action.yml"
- "README.MD"
- ".github/workflows/test-packages-input.yml"
- "tests/fixtures/packages-input-workspace/**"
jobs:
cargo-packages-input:
name: Cargo - packages input (${{ matrix.scenario }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- scenario: empty (default all)
packages: ""
expect: "marker-package-a marker-package-b marker-package-c"
forbid: ""
- scenario: single package
packages: |
package-b
expect: "marker-package-b"
forbid: "marker-package-a marker-package-c"
- scenario: multiple packages
packages: |
package-a
package-c
expect: "marker-package-a marker-package-c"
forbid: "marker-package-b"
steps:
- name: Checkout Action Repository
uses: actions/checkout@v6
- name: Clean package markers
shell: bash
run: rm -f tests/fixtures/packages-input-workspace/marker-package-*
- name: Run action (cargo)
uses: ./
with:
rust-project-path: tests/fixtures/packages-input-workspace
rust-toolchain: stable
target: x86_64-unknown-linux-gnu
use-cross: false
use-tarpaulin: false
upload-coverage: false
packages: ${{ matrix.packages }}
- name: Assert markers
shell: bash
run: |
set -euo pipefail
root="tests/fixtures/packages-input-workspace"
for f in ${{ matrix.expect }}; do
test -f "$root/$f" || { echo "Missing marker: $f"; exit 1; }
done
for f in ${{ matrix.forbid }}; do
test ! -f "$root/$f" || { echo "Unexpected marker: $f"; exit 1; }
done
cross-packages-input:
name: Cross - packages input
runs-on: ubuntu-latest
steps:
- name: Checkout Action Repository
uses: actions/checkout@v6
- name: Clean package markers
shell: bash
run: rm -f tests/fixtures/packages-input-workspace/marker-package-*
- name: Run action (cross)
uses: ./
with:
rust-project-path: tests/fixtures/packages-input-workspace
rust-toolchain: stable
target: aarch64-unknown-linux-gnu
use-cross: true
use-tarpaulin: false
upload-coverage: false
packages: |
package-a
package-c
- name: Assert markers
shell: bash
run: |
set -euo pipefail
root="tests/fixtures/packages-input-workspace"
test -f "$root/marker-package-a" || { echo "Missing marker: marker-package-a"; exit 1; }
test -f "$root/marker-package-c" || { echo "Missing marker: marker-package-c"; exit 1; }
test ! -f "$root/marker-package-b" || { echo "Unexpected marker: marker-package-b"; exit 1; }
tarpaulin-packages-input:
name: Tarpaulin - packages input
runs-on: ubuntu-latest
steps:
- name: Checkout Action Repository
uses: actions/checkout@v6
- name: Clean package markers
shell: bash
run: rm -f tests/fixtures/packages-input-workspace/marker-package-*
- name: Run action (tarpaulin)
uses: ./
with:
rust-project-path: tests/fixtures/packages-input-workspace
rust-toolchain: stable
target: x86_64-unknown-linux-gnu
use-cross: false
use-tarpaulin: true
upload-coverage: false
packages: |
package-b
- name: Assert markers
shell: bash
run: |
set -euo pipefail
root="tests/fixtures/packages-input-workspace"
test -f "$root/marker-package-b" || { echo "Missing marker: marker-package-b"; exit 1; }
test ! -f "$root/marker-package-a" || { echo "Unexpected marker: marker-package-a"; exit 1; }
test ! -f "$root/marker-package-c" || { echo "Unexpected marker: marker-package-c"; exit 1; }