From ad811ec36a42f1cf4dc8667cf42ed76f8331b01a Mon Sep 17 00:00:00 2001 From: James Waples Date: Mon, 10 Feb 2020 14:39:47 +0000 Subject: [PATCH 1/2] Migrate from Travis to CircleCI Closes #92 --- .circleci/config.yml | 108 +++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 72 ----------------------------- Cargo.toml | 6 +-- README.md | 6 ++- build.sh | 21 ++++++++- 5 files changed, 134 insertions(+), 79 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..d2a72d0f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,108 @@ +target_steps: &target_steps + docker: + - image: circleci/rust:1.41.0 + steps: + - checkout + - restore_cache: + key: v1-ssd1306-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }} + - run: rustup self update + - run: sudo apt install -qq python-pip + - run: sudo pip install linkchecker + - run: rustup default ${RUST_VERSION:-stable} + - run: rustup component add rustfmt + - run: | + SYSROOT=$(rustc --print sysroot) + + if [[ ! "$SYSROOT" =~ "$TARGET" ]]; then + rustup target add $TARGET + else + echo "Target $TARGET is already installed" + fi + - run: ./build.sh + - save_cache: + key: v1-ssd1306-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }} + paths: + - ./target + - /home/ubuntu/.cargo + +version: 2 +jobs: + target-arm-unknown-linux-eabi: + environment: + - TARGET: 'arm-unknown-linux-gnueabi' + - DISABLE_EXAMPLES: 1 + <<: *target_steps + + target-armv7-unknown-linux-gnueabihf: + environment: + - TARGET: 'armv7-unknown-linux-gnueabihf' + - DISABLE_EXAMPLES: 1 + <<: *target_steps + + target-x86_64-unknown-linux-gnu: + environment: + - TARGET: 'x86_64-unknown-linux-gnu' + - DISABLE_EXAMPLES: 1 + <<: *target_steps + + target-x86_64-unknown-linux-musl: + environment: + - TARGET: 'x86_64-unknown-linux-musl' + - DISABLE_EXAMPLES: 1 + <<: *target_steps + + target-thumbv6m-none-eabi: + environment: + - TARGET: 'thumbv6m-none-eabi' + # Disable example builds as they target thumbv7 and up + - DISABLE_EXAMPLES: 1 + <<: *target_steps + + target-thumbv7em-none-eabi: + environment: + - TARGET: 'thumbv7em-none-eabi' + <<: *target_steps + + target-thumbv7em-none-eabihf: + environment: + - TARGET: 'thumbv7em-none-eabihf' + <<: *target_steps + + target-thumbv7m-none-eabi: + environment: + - TARGET: 'thumbv7m-none-eabi' + <<: *target_steps + +build_jobs: &build_jobs + jobs: + # Raspberry Pi 1 + - target-arm-unknown-linux-eabi + + # Raspberry Pi 2, 3, etc + - target-armv7-unknown-linux-gnueabihf + + # Linux + - target-x86_64-unknown-linux-gnu + - target-x86_64-unknown-linux-musl + + # Bare metal + - target-thumbv6m-none-eabi + - target-thumbv7em-none-eabi + - target-thumbv7em-none-eabihf + - target-thumbv7m-none-eabi + +workflows: + version: 2 + build_all: + <<: *build_jobs + + # Build every day + nightly: + <<: *build_jobs + triggers: + - schedule: + cron: '0 0 * * *' + filters: + branches: + only: + - master diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da45051c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# Based on the "trust" template v0.1.2 -# https://github.com/japaric/trust/tree/v0.1.2 - -dist: trusty -language: rust -rust: - - stable - - beta - - nightly -sudo: required - -matrix: - include: - # Raspberry Pi 1 - - env: TARGET=arm-unknown-linux-gnueabi DISABLE_EXAMPLES=1 - - # Raspberry Pi 2, 3, etc - - env: TARGET=armv7-unknown-linux-gnueabihf DISABLE_EXAMPLES=1 - - env: TARGET=x86_64-unknown-linux-gnu DISABLE_EXAMPLES=1 - - env: TARGET=x86_64-unknown-linux-musl DISABLE_EXAMPLES=1 - - # Bare metal - - env: TARGET=thumbv6m-none-eabi DISABLE_EXAMPLES=1 - - env: TARGET=thumbv7em-none-eabi - - env: TARGET=thumbv7em-none-eabihf - - env: TARGET=thumbv7m-none-eabi - - - rust: nightly - env: TARGET=thumbv7m-none-eabi - - - rust: beta - env: TARGET=thumbv7m-none-eabi - - # Always supply a target - exclude: - - rust: stable - - rust: beta - - rust: nightly - - allow_failures: - - rust: nightly - env: TARGET=thumbv7m-none-eabi - -before_install: - - pip install linkchecker --user - -install: - - rustup component add rust-src - - rustup component add rustfmt - - | - SYSROOT=$(rustc --print sysroot) - - if [[ ! "$SYSROOT" =~ "$TARGET" ]]; then - rustup target add $TARGET - else - echo "Target $TARGET is already installed" - fi - - source ~/.cargo/env || true - -script: - - ./build.sh - - cargo doc --all-features --target $TARGET - - linkchecker target/$TARGET/doc/ssd1306/index.html - -cache: cargo -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo - -notifications: - email: - on_success: never diff --git a/Cargo.toml b/Cargo.toml index 403aea4d..33aa6856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ authors = ["James Waples "] categories = ["embedded", "no-std"] description = "I2C/SPI driver for the SSD1306 OLED display controller" documentation = "https://docs.rs/ssd1306" -exclude = [".travis.yml", ".gitignore"] keywords = ["no-std", "ssd1306", "oled", "embedded", "embedded-hal-driver"] license = "MIT OR Apache-2.0" name = "ssd1306" @@ -12,9 +11,8 @@ repository = "https://github.com/jamwaffles/ssd1306" version = "0.3.0-alpha.4" edition = "2018" -[badges.travis-ci] -branch = "master" -repository = "jamwaffles/ssd1306" +[badges] +circle-ci = { repository = "jamwaffles/ssd1306", branch = "master" } [package.metadata.docs.rs] all-features = true diff --git a/README.md b/README.md index 5821fcee..1c570fc9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # SSD1306 driver -[![Build Status](https://travis-ci.org/jamwaffles/ssd1306.svg?branch=master)](https://travis-ci.org/jamwaffles/ssd1306) +[![Build Status](https://circleci.com/gh/jamwaffles/ssd1306/tree/master.svg?style=shield)](https://circleci.com/gh/jamwaffles/ssd1306/tree/master) +[![Crates.io](https://img.shields.io/crates/v/ssd1306.svg)](https://crates.io/crates/ssd1306) +[![Docs.rs](https://docs.rs/ssd1306/badge.svg)](https://docs.rs/ssd1306) [![CRIUS display showing the Rust logo](readme_banner.jpg?raw=true)](examples/image_i2c.rs) @@ -8,7 +10,7 @@ I2C and SPI (4 wire) driver for the SSD1306 OLED display. See the [announcement blog post](https://wapl.es/electronics/rust/2018/04/30/ssd1306-driver.html) for more information. -Please consider [becoming a sponsor](https://github.com/sponsors/jamwaffles/) so I may continue to maintain these crates in my spare time! +Please consider [becoming a sponsor](https://github.com/sponsors/jamwaffles/) so I may continue to maintain this crate in my spare time! ## [Documentation](https://docs.rs/ssd1306) diff --git a/build.sh b/build.sh index c24d4437..69caca82 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,32 @@ #!/bin/sh +# Exit early on error set -e +# Print commands as they're run +set -x + +if [ -z $TARGET ]; then + echo "TARGET environment variable required but not set" + + exit 1 +fi + cargo fmt --all -- --check + cargo build --target $TARGET --all-features --release cargo test --lib --target x86_64-unknown-linux-gnu cargo test --doc --target x86_64-unknown-linux-gnu if [ -z $DISABLE_EXAMPLES ]; then - cargo build --target $TARGET --all-features --examples + cargo build --target $TARGET --all-features --examples fi + +# Remove stale docs - the linkchecker might miss links to old files if they're not removed +cargo clean --doc +cargo clean --doc --target $TARGET + +cargo doc --all-features --target $TARGET + +linkchecker target/$TARGET/doc/ssd1306/index.html From 942147f21dcc4c172d60ac63bbf0b2c902ece56d Mon Sep 17 00:00:00 2001 From: James Waples Date: Mon, 10 Feb 2020 14:46:45 +0000 Subject: [PATCH 2/2] Changelog item --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0a1d4fd..28fce9db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Changed +- [#107](https://github.com/jamwaffles/ssd1306/pull/107) Migrate from Travis to CircleCI - [#105](https://github.com/jamwaffles/ssd1306/pull/105) Reduce flash usage by around 400 bytes by replacing some internal `unwrap()`s with `as` coercions. - [#106](https://github.com/jamwaffles/ssd1306/pull/106) Optimise internals by using iterators to elide bounds checks. Should also speed up `GraphicsMode` (and `embedded-graphics` operations) with a cleaned-up `set_pixel`.