From c332ac5800bcf6d8f4f24d2d409877c8ea56a96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Wed, 20 Jul 2022 21:31:02 -0700 Subject: [PATCH] Switch to using GitHub Actions as CI provider GitLab has repeatedly messed with webhooks, repository mirroring, and CI itself in sinister ways that silently broke our CI from one day to the next, without any advance notice, acknowledgment, or even hint what they have done this time. On top of that, debugging their solution is a nightmare and time sink, because they provide virtually no insight into what is going on (at least not without involvement of third party services) and their API endpoints may just indicate success and still do nothing. This time it appears that they decided to remove "pull" mirroring from the free tier altogether, meaning that we can no longer keep code on GitLab in sync with that on GitHub, assuming it is being pushed to the latter. That renders their product entirely useless for our intents and purposes. To that end, this change switches over to using GitHub Actions as the CI provider. We start off with a reasonably simple CI script that covers all the steps we performed previously, but excludes all the advanced caching logic. The reason for this decision is that GitHub Actions workers are generally much faster and workflow duration is less of an issue. Should this change in the future or the program become significantly bigger, we can always revisit this decision. --- .github/workflows/ci.yml | 60 +++++++++++++++++++++++++++ CHANGELOG.md | 1 + README.md | 2 +- ci/gitlab-ci.yml | 87 ---------------------------------------- src/main.rs | 8 +++- 5 files changed, 68 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 ci/gitlab-ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dd30cea --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +# Copyright (C) 2022 Daniel Mueller +# SPDX-License-Identifier: GPL-3.0-or-later + +name: CI + +on: [push, pull_request] + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + # Build without debug information enabled to decrease compilation time + # and binary sizes in CI. This option is assumed to only have marginal + # effects on the generated code, likely only in terms of section + # arrangement. See + # https://doc.rust-lang.org/cargo/reference/environment-variables.html + # https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo + RUSTFLAGS: '-C debuginfo=0' + +jobs: + test: + name: Build and test [${{ matrix.rust }}, ${{ matrix.profile }}] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: [1.57.0, stable] + profile: [dev, release] + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + - name: Build & test ${{ matrix.profile }} + run: | + cargo build --profile=${{ matrix.profile }} --bins + cargo test --profile=${{ matrix.profile }} + clippy: + name: Lint with clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: clippy + override: true + - run: cargo clippy --no-deps --all-targets --all-features --tests -- -A unknown_lints -A deprecated -D warnings + rustfmt: + name: Check code formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: rustfmt + override: true + - run: cargo +nightly fmt -- --check diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6319c..b049ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Unreleased - Added support for submission of more kinds of bracket orders - Migrated over to using `clap` v3 for argument parsing - Removed `structopt` dependency +- Switched to using GitHub Actions as CI provider - Bumped minimum supported Rust version to `1.57` - Bumped `apca` dependency to `0.25.0` diff --git a/README.md b/README.md index 6315ed0..b7d419f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![pipeline](https://gitlab.com/d-e-s-o/apcacli/badges/main/pipeline.svg)](https://gitlab.com/d-e-s-o/apcacli/commits/main) +[![pipeline](https://github.com/d-e-s-o/apcacli/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/d-e-s-o/apcacli/actions/workflows/ci.yml) [![crates.io](https://img.shields.io/crates/v/apcacli.svg)](https://crates.io/crates/apcacli) [![rustc](https://img.shields.io/badge/rustc-1.57+-blue.svg)](https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html) diff --git a/ci/gitlab-ci.yml b/ci/gitlab-ci.yml deleted file mode 100644 index b9bdecc..0000000 --- a/ci/gitlab-ci.yml +++ /dev/null @@ -1,87 +0,0 @@ -# The documentation for the contents of this file can be found at: -# https://docs.gitlab.com/ce/ci/yaml/README.html - -# Official language image. Look for the different tagged releases at: -# https://hub.docker.com/r/library/rust/tags/ -# The recipe for this docker image can be found at: -# https://github.com/rust-lang/docker-rust/blob/c8ff5ad62bfd424f50c8cfd285ac1da98880593d/1.57.0/buster/Dockerfile -image: "rust:1.57.0" - - -variables: - FF_USE_FASTZIP: "true" - ARTIFACT_COMPRESSION_LEVEL: "fast" - CACHE_COMPRESSION_LEVEL: "fast" - # Build without debug information enabled to decrease compilation time - # and binary sizes in CI. This option is assumed to only have marginal - # effects on the generated code, likely only in terms of section - # arrangement. See - # https://doc.rust-lang.org/cargo/reference/environment-variables.html - # https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo - RUSTFLAGS: '-C debuginfo=0' - -.cargo-home: &cargo-home - CARGO_HOME: $CI_PROJECT_DIR/.cargo - -.crates-io-cache: &crates-io-cache - key: crates-io-cache - paths: - # See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci - - $CARGO_HOME/bin/ - - $CARGO_HOME/git/db/ - - $CARGO_HOME/registry/index/ - - $CARGO_HOME/registry/cache/ - policy: pull-push - -.target-debug-cache: &target-debug-cache - key: target-debug-cache-$CI_JOB_IMAGE - paths: - - target/debug/ - - Cargo.lock - policy: pull-push - -.target-release-cache: &target-release-cache - key: target-release-cache-$CI_JOB_IMAGE - paths: - - target/release/ - - Cargo.lock - policy: pull-push - -build-test-debug:cargo: - variables: - <<: *cargo-home - cache: - - <<: *crates-io-cache - - <<: *target-debug-cache - script: - - rustc --version && cargo --version - - cargo build --bins - - cargo test - -build-release:cargo: - variables: - <<: *cargo-home - cache: - - <<: *crates-io-cache - policy: pull - - <<: *target-release-cache - script: - - rustc --version && cargo --version - - cargo build --bins --release - -lint:clippy: - variables: - <<: *cargo-home - cache: - - <<: *crates-io-cache - policy: pull - - <<: *target-debug-cache - policy: pull - script: - - rustup component add clippy - - cargo clippy --no-deps --all-targets --all-features --tests -- -A unknown_lints -A deprecated -D warnings - -format:rustfmt: - script: - - rustup toolchain install nightly -c rustfmt - - cargo +nightly fmt -- --check diff --git a/src/main.rs b/src/main.rs index 612f650..a27e7c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later #![type_length_limit = "536870912"] -#![allow(clippy::large_enum_variant, clippy::let_and_return)] +#![allow( + clippy::large_enum_variant, + clippy::let_and_return, + clippy::let_unit_value +)] mod args; @@ -244,7 +248,7 @@ fn format_activity_type(side: account_activities::ActivityType) -> &'static str /// Sort a vector of `Activity` objects in descending order of their /// time stamps. -fn sort_account_activity(activities: &mut Vec) { +fn sort_account_activity(activities: &mut [account_activities::Activity]) { activities.sort_by(|act1, act2| { let ordering = match act1 { account_activities::Activity::Trade(trade1) => match act2 {