diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6ca0f45..745bca2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,18 +15,23 @@ env: jobs: test: - name: ${{ matrix.cmd.name }} (Rust ${{ matrix.rust }}) + name: ${{ matrix.cmd.name }} (Rust ${{ matrix.rust }}) ${{ matrix.features }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: rust: - stable + features: + - --no-default-features + - + - -F cli cmd: - name: Test run: cargo test --locked - name: Clippy - run: cargo clippy --locked --tests -- -D warnings + run: cargo clippy --locked --tests + run2: -D warnings timeout-minutes: 45 steps: - uses: actions/checkout@v4 @@ -36,7 +41,7 @@ jobs: - name: Install build dependencies run: sudo apt-get install -y libudev-dev - name: ${{ matrix.cmd.name }} - run: ${{ matrix.cmd.run }} + run: ${{ matrix.cmd.run }} ${{ matrix.features }} -- ${{ matrix.cmd.run2 }} build: name: Build for ${{ matrix.target.name }} @@ -72,7 +77,7 @@ jobs: run: ${{ matrix.target.pre-build }} if: matrix.target.pre-build - name: Build for ${{ matrix.target.name }} - run: cargo build --locked --release --target ${{ matrix.target.target }} + run: cargo build --locked --release --target ${{ matrix.target.target }} --no-default-features -F cli - name: Check file run: | file target/${{ matrix.target.target }}/release/rust-github-actions-test${{ matrix.target.ext }} diff --git a/Cargo.toml b/Cargo.toml index dda7c94..91c44fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,14 @@ name = "rust-github-actions-test" version = "0.1.0" edition = "2021" +[[bin]] +name = "rust-github-actions-test" +required-features = ["cli"] + +[features] +default = ["example"] +example = [] +cli = ["example"] + [dependencies] hidapi = "2.6.1" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..d2bc429 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,13 @@ +#![warn(clippy::all, clippy::pedantic)] + +#[cfg(feature = "example")] +#[cfg(target_feature = "crt-static")] +pub fn foo() { + println!("the C runtime should be statically linked"); +} + +#[cfg(feature = "example")] +#[cfg(not(target_feature = "crt-static"))] +pub fn foo() { + println!("the C runtime should be dynamically linked"); +} diff --git a/src/main.rs b/src/main.rs index 72e6f14..af65d04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ #![warn(clippy::all, clippy::pedantic)] +use rust_github_actions_test::foo; + fn main() { println!( "Hello, world V2!: {:?} {:?}", @@ -28,13 +30,3 @@ fn main() { Err(err) => eprintln!("Error: {err:?}"), } } - -#[cfg(target_feature = "crt-static")] -fn foo() { - println!("the C runtime should be statically linked"); -} - -#[cfg(not(target_feature = "crt-static"))] -fn foo() { - println!("the C runtime should be dynamically linked"); -}