From c07e1b4c505de387bf4d249771623511a784d5d0 Mon Sep 17 00:00:00 2001 From: Corey Alexander Date: Sat, 27 Jan 2024 17:49:02 -0500 Subject: [PATCH] Switch to Github Actions (#938) * Basically copy over the file from my blog and trim it down * Don't fail fast if stable or nightly fails, I want all the results * What if I do the expect with format too, does actions like that? * Use format! for all the tests in this file * Add a useless arg * This didn't work * Format vs to_string * Force colors in even if the env vars don't want it, this might just be what I need to fix Github Actions * Remove circleci * Empty commit to run CI, this time Circle shouldnt be listening * Lets only set the override and keep the hard coded spec --- .circleci/config.yml | 57 ------------------------------------- .github/workflows/tests.yml | 57 +++++++++++++++++++++++++++++++++++++ tests/strip_ansi.rs | 6 ++++ 3 files changed, 63 insertions(+), 57 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/tests.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 05fa8d41..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,57 +0,0 @@ -version: 2.1 -jobs: - lint-rust: - docker: - - image: rust:latest - resource_class: small - steps: - - checkout - - - run: - name: Print Rust Versions - command: rustc --version; cargo --version; rustup --version - - - run: - name: Install Rust Format - command: rustup component add rustfmt - - - run: - name: Test Formatting - command: cargo fmt -- --check - test-rust: - docker: - - image: rust:latest - resource_class: small - steps: - - checkout - - - run: - name: Print Rust Versions - command: rustc --version; cargo --version; rustup --version - - - restore_cache: - keys: - - v2-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} - - - run: - name: Build - command: cargo build --locked --all-targets - - - run: - name: Run Tests - command: cargo test --locked - - - run: - name: Autoclean Cargo cache before storing - command: cargo-cache || (cargo install cargo-cache --force --git https://github.com/matthiaskrgr/cargo-cache.git --no-default-features --features ci-autoclean && cargo-cache) - - save_cache: - key: v2-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} - paths: - - /usr/local/cargo - - target/debug -workflows: - version: 2 - ci: - jobs: - - test-rust - - lint-rust diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..1074dc10 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,57 @@ +name: Rust Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt clippy + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: "v1-rust" + - name: Build | Lint + run: cargo clippy --all-targets --no-deps + doc: + name: Doc + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: "v1-rust" + - name: Cargo Doc + run: cargo doc --workspace --no-deps + test: + name: Test + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + rust: + - stable + - nightly + runs-on: ${{ matrix.os }} + steps: + - name: Setup | Checkout + uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: "v1-rust" + - name: Test + run: cargo test --all-targets diff --git a/tests/strip_ansi.rs b/tests/strip_ansi.rs index 5c585bba..bbbf07fb 100644 --- a/tests/strip_ansi.rs +++ b/tests/strip_ansi.rs @@ -7,6 +7,8 @@ mod integration { #[test] fn calling_devicon_lookup_without_strip_color_single_file() { + colored::control::set_override(true); + let mut cmd = Command::cargo_bin("devicon-lookup").unwrap(); cmd.write_stdin("test.rs".blue().to_string()) .assert() @@ -15,6 +17,8 @@ mod integration { #[test] fn calling_devicon_lookup_with_strip_color_single_file() { + colored::control::set_override(true); + let mut cmd = Command::cargo_bin("devicon-lookup").unwrap(); cmd.arg("--color"); cmd.write_stdin("test.rs".blue().to_string()) @@ -24,6 +28,8 @@ mod integration { #[test] fn calling_devicon_lookup_with_strip_color_multi_file() { + colored::control::set_override(true); + let mut cmd = Command::cargo_bin("devicon-lookup").unwrap(); cmd.arg("-c"); cmd.write_stdin(format!("{}\n{}", "test.rs".blue(), "test.rb".red()))