From 29d26ca2690b355650cfe23b7d1dd207b65cefe3 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Sat, 18 Dec 2021 15:45:54 +1300 Subject: [PATCH] Switch from travis and appveyor to github actions. --- .github/workflows/ci.yml | 132 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 41 ------------ appveyor.yml | 121 ----------------------------------- src/lib.rs | 5 +- tarpaulin.toml | 5 ++ 5 files changed, 140 insertions(+), 164 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 tarpaulin.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6fa2b30 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,132 @@ +on: + push: + branches: + - master + pull_request: + branches: + - '**' + +name: CI + +jobs: + audit: + name: Audit + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt + + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: clippy + + - name: Install Clippy + run: rustup component add clippy + + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + coverage: + name: Coverage + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: tarpaulin Cache + id: tarpaulin_cache + uses: actions/cache@v2 + with: + path: ~/.cargo/bin/cargo-tarpaulin + key: ${{ runner.os }}-cargo-tarpaulin + + - uses: actions-rs/cargo@v1 + if: steps.tarpaulin_cache.outputs.cache-hit != 'true' + with: + command: install + args: cargo-tarpaulin + + - name: 'Run `cargo-tarpaulin`' + uses: actions-rs/cargo@v1 + with: + command: tarpaulin + args: --workspace + + - name: Upload to codecov.io + uses: codecov/codecov-action@v1 + with: + file: ./target/tarpaulin/cobertura.xml + + build_and_test_linux: + name: Build and Test (Linux) + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: actions-rs/cargo@v1 + with: + command: test + args: --release + + build_and_test_windows: + name: Build and Test (Windows) + runs-on: windows-latest + timeout-minutes: 10 + steps: + - name: Prepare symlink configuration + run: git config --global core.symlinks true + + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: actions-rs/cargo@v1 + with: + command: test + args: --release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c1dc309..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: rust - -sudo: required - -rust: - - stable - - nightly - -matrix: - allow_failures: - - rust: nightly - -addons: - apt: - packages: - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev - - cmake - - gcc - - binutils-dev - - libiberty-dev - -after_success: | - if [ "${TRAVIS_RUST_VERSION}" == "stable" ] - then - wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && - tar xzf master.tar.gz && - cd kcov-master && - mkdir build && - cd build && - cmake .. && - make && - make install DESTDIR=../../kcov-build && - cd ../.. && - rm -rf kcov-master && - export PATH="${PATH}:$(pwd)/kcov-build/usr/local/bin/" && - ./scripts/coverage.sh && - bash <(curl -s https://codecov.io/bash) && - echo "Uploaded code coverage" - fi diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 50e29e9..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,121 +0,0 @@ -# Appveyor configuration template for Rust using rustup for Rust installation -# https://github.com/starkat99/appveyor-rust - -## Operating System (VM environment) ## - -# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. -os: Visual Studio 2015 - -## Build Matrix ## - -# This configuration will setup a build for each channel & target combination (12 windows -# combinations in all). -# -# There are 3 channels: stable, beta, and nightly. -# -# Alternatively, the full version may be specified for the channel to build using that specific -# version (e.g. channel: 1.5.0) -# -# The values for target are the set of windows Rust build targets. Each value is of the form -# -# ARCH-pc-windows-TOOLCHAIN -# -# Where ARCH is the target architecture, either x86_64 or i686, and TOOLCHAIN is the linker -# toolchain to use, either msvc or gnu. See https://www.rust-lang.org/downloads.html#win-foot for -# a description of the toolchain differences. -# See https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification for description of -# toolchains and host triples. -# -# Comment out channel/target combos you do not wish to build in CI. -# -# You may use the `cargoflags` and `RUSTFLAGS` variables to set additional flags for cargo commands -# and rustc, respectively. For instance, you can uncomment the cargoflags lines in the nightly -# channels to enable unstable features when building for nightly. Or you could add additional -# matrix entries to test different combinations of features. -environment: - matrix: - -### MSVC Toolchains ### - - # Stable 64-bit MSVC - - channel: stable - target: x86_64-pc-windows-msvc - # # Stable 32-bit MSVC - # - channel: stable - # target: i686-pc-windows-msvc - # # Beta 64-bit MSVC - # - channel: beta - # target: x86_64-pc-windows-msvc - # # Beta 32-bit MSVC - # - channel: beta - # target: i686-pc-windows-msvc - # Nightly 64-bit MSVC - - channel: nightly - target: x86_64-pc-windows-msvc - #cargoflags: --features "unstable" - # # Nightly 32-bit MSVC - # - channel: nightly - # target: i686-pc-windows-msvc - # #cargoflags: --features "unstable" - -### GNU Toolchains ### - - # # Stable 64-bit GNU - # - channel: stable - # target: x86_64-pc-windows-gnu - # # Stable 32-bit GNU - # - channel: stable - # target: i686-pc-windows-gnu - # # Beta 64-bit GNU - # - channel: beta - # target: x86_64-pc-windows-gnu - # # Beta 32-bit GNU - # - channel: beta - # target: i686-pc-windows-gnu - # # Nightly 64-bit GNU - # - channel: nightly - # target: x86_64-pc-windows-gnu - # #cargoflags: --features "unstable" - # # Nightly 32-bit GNU - # - channel: nightly - # target: i686-pc-windows-gnu - # #cargoflags: --features "unstable" - -### Allowed failures ### - -# See Appveyor documentation for specific details. In short, place any channel or targets you wish -# to allow build failures on (usually nightly at least is a wise choice). This will prevent a build -# or test failure in the matching channels/targets from failing the entire build. -matrix: - allow_failures: - - channel: nightly - -# If you only care about stable channel build failures, uncomment the following line: - #- channel: beta - -## Install Script ## - -# This is the most important part of the Appveyor configuration. This installs the version of Rust -# specified by the 'channel' and 'target' environment variables from the build matrix. This uses -# rustup to install Rust. -# -# For simple configurations, instead of using the build matrix, you can simply set the -# default-toolchain and default-host manually here. -install: - - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init -yv --default-toolchain %channel% --default-host %target% - - set PATH=%PATH%;%USERPROFILE%\.cargo\bin - - rustc -vV - - cargo -vV - -## Build Script ## - -# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents -# the "directory does not contain a project or solution file" error. -build: false - -# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs -#directly or perform other testing commands. Rust will automatically be placed in the PATH -# environment variable. -test_script: - - cargo test --verbose %cargoflags% diff --git a/src/lib.rs b/src/lib.rs index d264200..45df781 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![deny(missing_debug_implementations, missing_docs)] // kcov-ignore +#![deny(missing_debug_implementations, missing_docs)] #![no_std] #![recursion_limit = "128"] @@ -167,6 +167,7 @@ const ATTRIBUTES_TO_COPY: &[&str] = &["doc", "cfg", "allow", "deny"]; /// Derives a struct for each enum variant. /// /// Struct fields including their attributes are copied over. +#[cfg(not(tarpaulin_include))] #[proc_macro_derive(EnumVariantType, attributes(evt))] pub fn enum_variant_type(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); @@ -363,7 +364,7 @@ fn data_enum(ast: &DeriveInput) -> &DataEnum { if let Data::Enum(data_enum) = &ast.data { data_enum } else { - panic!("`EnumVariantType` derive can only be used on an enum."); // kcov-ignore + panic!("`EnumVariantType` derive can only be used on an enum."); } } diff --git a/tarpaulin.toml b/tarpaulin.toml new file mode 100644 index 0000000..bfad298 --- /dev/null +++ b/tarpaulin.toml @@ -0,0 +1,5 @@ +[default] + +[report] +out = ["Html", "Xml"] +output-dir = "target/tarpaulin"