Use GitHub actions (#407)

* gh-403: add basic github actions

* gh-403: add environment variables during test

* gh-403: fix error in tower-balance example

* gh-403: rename build workflow

* gh-403: fix release workflow

* gh-403: add GitHub page publish workflow

* gh-403: remove release workflow

* gh-403: run per crate build

* gh-403: replace build to check
This commit is contained in:
László Nagy 2020-01-10 11:02:40 +11:00 committed by Lucio Franco
parent 7b48479bd2
commit 40103d84ce
3 changed files with 165 additions and 1 deletions

135
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,135 @@
name: continuous integration
on: [push, pull_request]
jobs:
build_whole_workspace:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macOS-10.14]
rust: [stable, nightly]
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: check
args: --verbose
- name: Run tests
uses: actions-rs/cargo@v1
env:
CI: 'True'
RUSTFLAGS: '-D warnings'
with:
command: test
args: --verbose
build_per_crate:
runs-on: ubuntu-latest
strategy:
matrix:
crate:
- tower
- tower-balance
- tower-buffer
- tower-discover
- tower-filter
- tower-hedge
- tower-layer
- tower-limit
- tower-load
- tower-load-shed
- tower-make
- tower-ready-cache
- tower-reconnect
- tower-retry
- tower-service
- tower-spawn-ready
- tower-test
- tower-timeout
- tower-util
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Patch
run: |
set -e
# Remove any existing patch statements
mv Cargo.toml Cargo.toml.bck
sed -n '/\[patch.crates-io\]/q;p' Cargo.toml.bck > Cargo.toml
# Patch all crates
cat ci/patch.toml >> Cargo.toml
# Print `Cargo.toml` for debugging
echo "~~~~ Cargo.toml ~~~~"
cat Cargo.toml
echo "~~~~~~~~~~~~~~~~~~~~"
- name: Build
uses: actions-rs/cargo@v1
with:
command: check
args: -p ${{ matrix.crate }} --verbose
- name: Run tests
uses: actions-rs/cargo@v1
env:
CI: 'True'
RUSTFLAGS: '-D warnings'
with:
command: test
args: -p ${{ matrix.crate }} --verbose
rustfmt_check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Ensure that rustfmt is installed
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
# This is failing, because it finds errors...
# clippy_check:
#
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v1
# - name: Ensure that clippy is installed
# uses: actions-rs/toolchain@v1
# with:
# toolchain: nightly
# override: true
# components: clippy
# - name: Run clippy
# uses: actions-rs/clippy-check@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# args: --all-targets --all-features

29
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Deploy API Documentation
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps
- name: Deploy documentation
if: success()
uses: crazy-max/ghaction-github-pages@v1
with:
target_branch: gh-pages
build_dir: target/doc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -180,7 +180,7 @@ impl Summary {
for c in &self.count_by_instance {
total += c;
}
for (i, c) in self.count_by_instance.into_iter().enumerate() {
for (i, c) in self.count_by_instance.iter().enumerate() {
let p = *c as f64 / total as f64 * 100.0;
println!(" [{:02}] {:>5.01}%", i, p);
}