Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Re-use CI logic through make #2901

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 12 additions & 33 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,12 @@ jobs:
run: exit 0
test-minimal:
name: Tests (Minimal)
env:
FLAGS: --no-default-features --features 'std cargo'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Cache Builds
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2
- name: Compile
run: cargo test --no-run ${{ env.FLAGS }}
- name: Test
run: cargo test ${{ env.FLAGS }}
test-full:
name: Tests (Full)
env:
FLAGS: --features 'wrap_help yaml regex unstable-replace'
strategy:
fail-fast: false
matrix:
features: [minimal, full]
os: [ubuntu-latest, windows-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- name: Install rust
Expand All @@ -59,10 +33,11 @@ jobs:
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2

- name: Compile
run: cargo test --no-run ${{ env.FLAGS }}
run: make build-${{ matrix.features}
- name: Test
run: cargo test ${{ env.FLAGS }}
run: make test-${{ matrix.features}
msrv:
name: "Check MSRV: 1.54.0"
runs-on: ubuntu-latest
Expand All @@ -77,11 +52,15 @@ jobs:
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2

- name: Minimal features
run: make check-minimal

- name: Default features
run: cargo check --all-targets
run: make check-default

- name: All features + Debug
run: cargo check --all-targets --features "wrap_help yaml regex unstable-replace debug"
- name: No features
run: cargo check --all-targets --no-default-features --features "std cargo"
run: make check-debug

- name: UI Tests
run: cargo test --package clap_derive -- ui
81 changes: 22 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
rust: [1.54.0, stable, beta]
features: [minimal, full, release]
os: [windows-latest, macos-latest, ubuntu-latest]
target:
- i686-pc-windows-msvc
Expand All @@ -25,10 +26,6 @@ jobs:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- x86_64-apple-darwin
features:
- none
- all
- release
exclude:
- features: release
rust: stable
Expand Down Expand Up @@ -71,6 +68,8 @@ jobs:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Cache Builds
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2
- name: Install linker
Expand All @@ -86,72 +85,37 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: Test almost no features
uses: actions-rs/cargo@v1
if: matrix.features == 'none'
with:
command: test
args: --target ${{ matrix.target }} --no-default-features --features "std cargo" -p clap:3.0.0-beta.4
- name: Test all features
uses: actions-rs/cargo@v1
if: matrix.features == 'all'
with:
command: test
args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace"
- name: Check debug
uses: actions-rs/cargo@v1
if: matrix.features == 'all'
with:
command: check
args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace debug"
- name: Test release
uses: actions-rs/cargo@v1

- name: Check Debug
if: matrix.features == 'release'
with:
command: test
args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace" --release
run: make check-debug TOOLCHAIN_TARGET=${{matrix.target}

- name: Compile
run: make build-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target}
- name: Test
run: make test-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target}
nightly:
name: Nightly Tests
strategy:
fail-fast: false
matrix:
features:
- none
- all
- release
features: [minimal, full, release]
runs-on: ubuntu-latest
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Cache Builds
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2
- name: Test almost no features
uses: actions-rs/cargo@v1
if: matrix.features == 'none'
with:
command: test
args: --no-default-features --features "std cargo" -p clap:3.0.0-beta.4
- name: Test all features
uses: actions-rs/cargo@v1
if: matrix.features == 'all'
with:
command: test
args: --features "wrap_help yaml regex unstable-replace"
- name: Check debug
uses: actions-rs/cargo@v1
if: matrix.features == 'all'
with:
command: check
args: --features "wrap_help yaml regex unstable-replace debug"
- name: Test release
uses: actions-rs/cargo@v1
if: matrix.features == 'release'
with:
command: test
args: --features "wrap_help yaml regex unstable-replace" --release

- name: Compile
run: make build-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target}
- name: Test
run: make test-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target}
wasm:
name: Wasm Check
runs-on: ubuntu-latest
Expand All @@ -166,10 +130,9 @@ jobs:
toolchain: 1.54.0
target: ${{ matrix.target }}
override: true
- name: Cache Builds
uses: Swatinem/rust-cache@v1
- name: Checkout
uses: actions/checkout@v2
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --target ${{ matrix.target }} --features "yaml regex unstable-replace"
run: make check-wasm TOOLCHAIN_TARGET=${{matrix.target}
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# CI Steps
#
# Considerations
# - Easy to debug: show the command being run
# - Leverage CI features: Only run individual steps so we can use features like reporting elapsed time per step

TOOLCHAIN_TARGET ?=
ifneq (${TOOLCHAIN_TARGET},)
_TARGET_ARG =--target ${TOOLCHAIN_TARGET}
endif
_TARGET_ARG ?=

_FEATURES = minimal default wasm full release
_FEATURES_minimal = --no-default-features --features "std cargo"
_FEATURES_default =
_FEATURES_wasm = --features "yaml regex unstable-replace"
_FEATURES_full = --features "yaml regex unstable-replace wrap_help"
_FEATURES_debug = ${_FEATURES_full} --features debug
_FEATURES_release = ${_FEATURES_full} --release

check-%:
cargo check --all-targets ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:check-%=%}}

build-%:
cargo test --no-run ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:build-%=%}}

test-%:
cargo test ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:test-%=%}}
41 changes: 0 additions & 41 deletions justfile

This file was deleted.