CI: error on dead/unused code for features (#146)

By using `RUSTFLAGS="-D dead_code -D unused-variables -D unused"`, we tell
the compiler to upgrade warnings for unused code to errors. This combined
with a more elaborate test matrix means we can have the CI catch feature
flag combos that cause warnings.
This commit is contained in:
Martin Algesten
2020-09-18 22:55:23 +02:00
committed by GitHub
parent f599828c6d
commit 05ffe53e4c
3 changed files with 35 additions and 9 deletions

View File

@@ -3,17 +3,46 @@ on: [push, pull_request]
name: CI name: CI
jobs: jobs:
doc:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Docs
uses: actions-rs/cargo@v1
with:
command: doc
# Keep in sync with Cargo.toml's [package.metadata.docs.rs]
args: --no-default-features --no-deps --features "tls json charset cookies socks-proxy"
build_and_test: build_and_test:
name: Rust project name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
tls:
- ""
- tls
- native-tls
feature: feature:
- ""
- json
- charset - charset
- cookies - cookies
- socks-proxy - socks-proxy
what:
- "--doc"
- "--tests"
exclude:
- tls: ""
what: "--doc"
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
RUSTFLAGS: "-D dead_code -D unused-variables -D unused"
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Install Rust - name: Install Rust
@@ -25,10 +54,4 @@ jobs:
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: test command: test
args: --no-default-features --features "json tls ${{ matrix.feature }}" args: ${{ matrix.what }} --no-default-features --features "${{ matrix.tls }} ${{ matrix.feature }}"
- name: Docs
uses: actions-rs/cargo@v1
with:
command: doc
# Keep in sync with Cargo.toml's [package.metadata.docs.rs]
args: --no-default-features --no-deps --features "tls json charset cookies socks-proxy"

View File

@@ -282,7 +282,6 @@ pub(crate) fn basic_auth(user: &str, pass: &str) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::io::Read;
use std::thread; use std::thread;
///////////////////// AGENT TESTS ////////////////////////////// ///////////////////// AGENT TESTS //////////////////////////////
@@ -298,6 +297,8 @@ mod tests {
#[test] #[test]
#[cfg(any(feature = "tls", feature = "native-tls"))] #[cfg(any(feature = "tls", feature = "native-tls"))]
fn agent_pool() { fn agent_pool() {
use std::io::Read;
let agent = crate::agent(); let agent = crate::agent();
let url = "https://ureq.s3.eu-central-1.amazonaws.com/sherlock.txt"; let url = "https://ureq.s3.eu-central-1.amazonaws.com/sherlock.txt";
// req 1 // req 1

View File

@@ -1,3 +1,5 @@
#![allow(dead_code)]
use crate::test; use crate::test;
use crate::test::testserver::{read_headers, TestServer}; use crate::test::testserver::{read_headers, TestServer};
use std::io::{self, Write}; use std::io::{self, Write};