Skip to content

Commit

Permalink
Add initial CI jobs for Rust build (#28)
Browse files Browse the repository at this point in the history
* Modernize Rust syntax to 2018 edition and fix many lint warnings

* Correct full namespaces of imports
* Don't import things that aren't used (yet)
* Use `_` prefix for private / unused values (should be refactored back
  to regular names on a case by cases basis as they are used & made public)
* Order and space according to rustfmt

The bulk of this work was done by:

    cargo +nightly fix --edition

* Explicitly parse Rust as latest syntax edition (default is 2015)

* Fix coding style with `rustfmt`

* Correct bogus file extension, .rs → .sh

* Add CI jobs to lint, validate, build, & test Rust code

* Track Cargo lock file (this is correct Rust+VCS usage)

* Install GTK and libxcb devel headers into CI environment
  • Loading branch information
alerque authored Sep 17, 2020
1 parent 27e2f23 commit 49852df
Show file tree
Hide file tree
Showing 26 changed files with 2,176 additions and 98 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Rust

on:
pull_request: {}
push:
branches:
- master

jobs:

build:
strategy:
fail-fast: false
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags
- name: Setup system dependencies
run: sudo apt-get install libgtk-3-dev libxcb-shape0-dev libxcb-xfixes0-dev
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: clippy
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: build-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: build-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: build-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo build
run: |
cargo build --locked
- name: Run cargo test
run: |
cargo test --locked
rustfmt:
strategy:
fail-fast: false
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt
- name: Run rustfmt
run: |
git ls-files '*.rs' | xargs rustfmt --check
cargo_bloat:
if: false
strategy:
fail-fast: false
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: bloat-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: bloat-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: bloat-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo bloat
uses: orf/cargo-bloat-action@v1
with:
token: ${{ github.token }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/target
Cargo.lock
*.swp
Loading

0 comments on commit 49852df

Please sign in to comment.