diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml deleted file mode 100644 index 948800ce..00000000 --- a/.github/workflows/ci-pr.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: CI-PR -on: - pull_request: - branches: [main] -concurrency: - group: ci-pr-${{ github.ref }} - cancel-in-progress: true -jobs: - ci-pr: - name: CI-PR - needs: [test-minimal, test-full, msrv] - runs-on: ubuntu-latest - steps: - - name: Done - 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 unstable-multicall unstable-grouped' - 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 }} - msrv: - name: "Check MSRV: 1.54.0" - runs-on: ubuntu-latest - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.54.0 # MSRV - override: true - - name: Cache Builds - uses: Swatinem/rust-cache@v1 - - name: Checkout - uses: actions/checkout@v2 - - name: Default features - run: cargo check --all-targets - - name: All features + Debug - run: cargo check --all-targets --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped debug" - - name: No features - run: cargo check --all-targets --no-default-features --features "std cargo" - - name: UI Tests - run: cargo test --package clap_derive -- ui diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ddab578..ef6f71df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,175 +1,181 @@ name: CI on: + pull_request: + paths: + - '**' + - '!/*.md' + - '!/docs/**' + - "!/LICENSE-*" push: - branches: [main] + branches: + - master + paths: + - '**' + - '!/*.md' + - '!/docs/**' + - "!/LICENSE-*" + schedule: + - cron: '3 3 3 * *' jobs: ci: name: CI - needs: [test, wasm] + needs: [smoke, test, check, docs, rustfmt, clippy] runs-on: ubuntu-latest steps: - name: Done run: exit 0 + smoke: + name: Quick Check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - uses: Swatinem/rust-cache@v1 + - name: Default features + run: make check-default test: - name: Tests + name: Test + needs: smoke + strategy: + matrix: + build: [linux, windows, mac, minimal, default] + include: + - build: linux + os: ubuntu-latest + rust: "stable" + features: "full" + - build: windows + os: windows-latest + rust: "stable" + features: "full" + - build: mac + os: macos-latest + rust: "stable" + features: "full" + - build: minimal + os: ubuntu-latest + rust: "stable" + features: "minimal" + - build: default + os: ubuntu-latest + rust: "stable" + features: "default" + continue-on-error: ${{ matrix.rust != 'stable' }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + - uses: Swatinem/rust-cache@v1 + - name: Build + run: make build-${{matrix.features}} + - name: Test + run: make test-${{matrix.features}} + check: + name: Check + needs: smoke + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - rust: [1.54.0, stable, beta] - os: [windows-latest, macos-latest, ubuntu-latest] - target: - - i686-pc-windows-msvc - - x86_64-pc-windows-msvc - - i686-pc-windows-gnu - - x86_64-pc-windows-gnu - - x86_64-unknown-linux-gnu - - i686-unknown-linux-gnu - - x86_64-apple-darwin - features: - - none - - all - - release - exclude: - - features: release + build: [msrv, wasm, wasm-wasi, debug, release] + include: + - build: msrv + rust: 1.54.0 # MSRV + target: x86_64-unknown-linux-gnu + features: full + - build: wasm + rust: stable + target: wasm32-unknown-unknown + features: wasm + - build: wasm-wasi + rust: stable + target: wasm32-wasi + features: wasm + - build: debug rust: stable - - features: release - rust: beta - - os: windows-latest - target: x86_64-apple-darwin - - os: windows-latest target: x86_64-unknown-linux-gnu - - os: windows-latest - target: i686-unknown-linux-gnu - - os: macos-latest - target: i686-pc-windows-msvc - - os: macos-latest - target: x86_64-pc-windows-msvc - - os: macos-latest - target: i686-pc-windows-gnu - - os: macos-latest - target: x86_64-pc-windows-gnu - - os: macos-latest + features: debug + - build: release + rust: stable target: x86_64-unknown-linux-gnu - - os: macos-latest - target: i686-unknown-linux-gnu - - os: ubuntu-latest - target: i686-pc-windows-msvc - - os: ubuntu-latest - target: x86_64-pc-windows-msvc - - os: ubuntu-latest - target: i686-pc-windows-gnu - - os: ubuntu-latest - target: x86_64-pc-windows-gnu - - os: ubuntu-latest - target: x86_64-apple-darwin - runs-on: ${{ matrix.os }} + features: release steps: + - name: Checkout repository + uses: actions/checkout@v2 - name: Install rust uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - name: Checkout - uses: actions/checkout@v2 - - name: Install linker - if: matrix.target == 'i686-pc-windows-gnu' - uses: egor-tensin/setup-mingw@v2 - with: - platform: x86 - - name: Install linker - if: matrix.target == 'x86_64-pc-windows-gnu' - uses: egor-tensin/setup-mingw@v2 - - name: Install linker - if: matrix.target == 'i686-unknown-linux-gnu' - 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.5 - - 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 unstable-multicall unstable-grouped" - - 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 unstable-multicall unstable-grouped debug" - - name: Test release - uses: actions-rs/cargo@v1 - if: matrix.features == 'release' - with: - command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --release - nightly: - name: Nightly Tests - strategy: - fail-fast: false - matrix: - features: - - none - - all - - release - runs-on: ubuntu-latest - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - 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.5 - - name: Test all features - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: test - args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" - - name: Check debug - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: check - args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped debug" - - name: Test release - uses: actions-rs/cargo@v1 - if: matrix.features == 'release' - with: - command: test - args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --release - wasm: - name: Wasm Check - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - target: [wasm32-unknown-unknown, wasm32-wasi] - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.54.0 - target: ${{ matrix.target }} - override: true + - 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 unstable-multicall unstable-grouped" + run: make check-${{ matrix.features }} + docs: + name: Docs + needs: smoke + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - uses: Swatinem/rust-cache@v1 + - name: Check documentation + env: + RUSTDOCFLAGS: -D warnings + run: cargo doc --workspace --all-features --no-deps --document-private-items + rustfmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + # Not MSRV because its harder to jump between versions and people are + # more likely to have stable + toolchain: stable + profile: minimal + override: true + components: rustfmt + - uses: Swatinem/rust-cache@v1 + - name: Check formatting + run: cargo fmt --all -- --check + clippy: + name: clippy + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.54.0 # MSRV + profile: minimal + override: true + components: clippy + - uses: Swatinem/rust-cache@v1 + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --workspace --all-features --all-targets -- -D warnings diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index f7b58c6a..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Coverage -on: - pull_request: - branches: [main] - push: - branches: [main] -concurrency: - group: coverage-${{ github.ref }} - cancel-in-progress: true -jobs: - coverage: - name: Coverage - continue-on-error: true - runs-on: ubuntu-latest - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: llvm-tools-preview - override: true - - name: Checkout - uses: actions/checkout@v2 - - name: Install llvm-cov - uses: actions-rs/install@v0.1 - with: - crate: cargo-llvm-cov - version: 0.1.0-alpha.4 - use-tool-cache: true - - name: Coverage - uses: actions-rs/cargo@v1 - with: - command: llvm-cov - args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --lcov --output-path lcov.info - - name: Coveralls - uses: coverallsapp/github-action@master - with: - path-to-lcov: lcov.info - github-token: ${{ secrets.github_token }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index e4da7634..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Lint -on: - pull_request: - branches: [main] - push: - branches: [main] -concurrency: - group: lint-${{ github.ref }} - cancel-in-progress: true -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt, clippy - - name: Cache Builds - uses: Swatinem/rust-cache@v1 - - name: Checkout - uses: actions/checkout@v2 - - name: Clippy for almost no features - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --no-default-features --features "std cargo" - - name: Clippy for all features - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" -- -D warnings - - name: Format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml new file mode 100644 index 00000000..3cefd960 --- /dev/null +++ b/.github/workflows/rust-next.yml @@ -0,0 +1,101 @@ +name: rust-next +on: + schedule: + - cron: '3 3 3 * *' +jobs: + test: + name: Test + strategy: + matrix: + build: [linux, windows, mac, beta, nightly, minimal, default] + include: + - build: linux + os: ubuntu-latest + rust: "stable" + features: "full" + - build: windows + os: windows-latest + rust: "stable" + features: "full" + - build: mac + os: macos-latest + rust: "stable" + features: "full" + - build: beta + os: ubuntu-latest + rust: "beta" + features: "full" + - build: nightly + os: ubuntu-latest + rust: "nightly" + features: "full" + - build: minimal + os: ubuntu-latest + rust: "stable" + features: "minimal" + - build: default + os: ubuntu-latest + rust: "stable" + features: "default" + continue-on-error: ${{ matrix.rust != 'stable' }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + - uses: Swatinem/rust-cache@v1 + - name: Build + run: make build-${{matrix.features}} + - name: Test + run: make test-${{matrix.features}} + rustfmt: + name: rustfmt + strategy: + matrix: + rust: + - stable + - beta + continue-on-error: ${{ matrix.rust != 'stable' }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + components: rustfmt + - uses: Swatinem/rust-cache@v1 + - name: Check formatting + run: cargo fmt --all -- --check + clippy: + name: clippy + strategy: + matrix: + rust: + - 1.54.0 # MSRV + - stable + continue-on-error: ${{ matrix.rust != '1.54.0' }} # MSRV + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + components: clippy + - uses: Swatinem/rust-cache@v1 + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --workspace --all-features --all-targets -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index a4896fb6..6f3956f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,9 +137,3 @@ members = [ "clap_generate", "clap_generate_fig", ] -default-members = [ - ".", - "clap_derive", - "clap_generate", - "clap_generate_fig", -] diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..9c2922c6 --- /dev/null +++ b/Makefile @@ -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 + +ARGS?= +TOOLCHAIN_TARGET ?= +ifneq (${TOOLCHAIN_TARGET},) + ARGS+=--target ${TOOLCHAIN_TARGET} +endif + +_FEATURES = minimal default wasm full release +_FEATURES_minimal = --no-default-features --features "std cargo" +_FEATURES_default = +_FEATURES_wasm = --features "yaml regex unstable-replace unstable-multicall unstable-grouped" +_FEATURES_full = --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" +_FEATURES_debug = ${_FEATURES_full} --features debug +_FEATURES_release = ${_FEATURES_full} --release + +check-%: + cargo check --all-targets ${ARGS} ${_FEATURES_${@:check-%=%}} + +build-%: + cargo test --no-run ${ARGS} ${_FEATURES_${@:build-%=%}} + +test-%: + cargo test ${ARGS} ${_FEATURES_${@:test-%=%}}