Skip to content

Commit

Permalink
move to GitHub Actions for CI (tokio-rs#304)
Browse files Browse the repository at this point in the history
Transitions the project's CI infrastructure, and fixes a bunch of associated tests, clippy warnings, and rustfmt issues.
  • Loading branch information
danburkert authored Apr 21, 2020
1 parent 6f3c60f commit 2de785a
Show file tree
Hide file tree
Showing 26 changed files with 266 additions and 208 deletions.
30 changes: 0 additions & 30 deletions .appveyor.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/continuous-integration-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: continuous integration
on: pull_request

jobs:

rustfmt:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- name: install ninja
uses: seanmiddleditch/gha-setup-ninja@v1
- name: cache target directory
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-clippy-target-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/*.rs') }}
restore_keys: |
${{ runner.os }}-clippy-target-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-clippy-target-
- name: clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-targets

test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
toolchain:
- stable
- 1.39.0
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
components: rustfmt
- name: install ninja
uses: seanmiddleditch/gha-setup-ninja@v1
- name: cache target directory
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-${{ matrix.toolchain }}-target-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/*.rs') }}
restore_keys: |
${{ runner.os }}-${{ matrix.toolchain }}-target-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-${{ matrix.toolchain }}-target-
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-targets
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions benches/varint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ fn benchmark_varint(criterion: &mut Criterion, name: &str, mut values: Vec<u64>)
})
.throughput(Throughput::Bytes(decoded_len));

let encoded_len_values = values.clone();
let encoded_len = Benchmark::new("encoded_len", move |b| {
b.iter(|| {
let mut sum = 0;
for &value in &encoded_len_values {
for &value in &values {
sum += encoded_len_varint(value);
}
criterion::black_box(sum);
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
too-many-arguments-threshold=8
2 changes: 2 additions & 0 deletions conformance/tests/conformance.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(target_os = "windows"))]

use std::env;
use std::process::Command;

Expand Down
6 changes: 3 additions & 3 deletions prost-build/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl Comments {
.as_ref()
.map_or(Vec::new(), get_lines);
Comments {
leading_detached: leading_detached,
leading: leading,
trailing: trailing,
leading_detached,
leading,
trailing,
}
}

Expand Down
21 changes: 7 additions & 14 deletions prost-build/src/code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,9 @@ impl<'a> CodeGenerator<'a> {
code_gen.path.pop();
}

let buf = code_gen.buf;
code_gen
.config
.service_generator
.as_mut()
.map(|service_generator| {
service_generator.finalize(buf);
});
if let Some(service_generator) = code_gen.config.service_generator.as_mut() {
service_generator.finalize(code_gen.buf);
}

code_gen.path.pop();
}
Expand Down Expand Up @@ -584,7 +579,7 @@ impl<'a> CodeGenerator<'a> {

self.depth += 1;
self.path.push(2);
for (idx, value) in enum_values.into_iter().enumerate() {
for (idx, value) in enum_values.iter().enumerate() {
// Skip duplicate enum values. Protobuf allows this when the
// 'allow_alias' option is set.
if !numbers.insert(value.number()) {
Expand Down Expand Up @@ -677,11 +672,9 @@ impl<'a> CodeGenerator<'a> {
options: service.options.unwrap_or_default(),
};

let buf = &mut self.buf;
self.config
.service_generator
.as_mut()
.map(move |service_generator| service_generator.generate(service, buf));
if let Some(service_generator) = self.config.service_generator.as_mut() {
service_generator.generate(service, &mut self.buf)
}
}

fn push_indent(&mut self) {
Expand Down
3 changes: 3 additions & 0 deletions prost-build/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ pub fn match_ident(matcher: &str, msg: &str, field: Option<&str>) -> bool {

#[cfg(test)]
mod tests {

#![allow(clippy::cognitive_complexity)]

use super::*;

#[test]
Expand Down
28 changes: 16 additions & 12 deletions prost-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![doc(html_root_url = "https://docs.rs/prost-build/0.6.1")]
#![allow(clippy::option_as_ref_deref)]

//! `prost-build` compiles `.proto` files into Rust.
//!
Expand Down Expand Up @@ -50,9 +51,10 @@
//! `build.rs` build-script:
//!
//! ```rust,no_run
//! fn main() {
//! prost_build::compile_protos(&["src/items.proto"],
//! &["src/"]).unwrap();
//! # use std::io::Result;
//! fn main() -> Result<()> {
//! prost_build::compile_protos(&["src/items.proto"], &["src/"])?;
//! Ok(())
//! }
//! ```
//!
Expand Down Expand Up @@ -492,11 +494,12 @@ impl Config {
/// # Example `build.rs`
///
/// ```rust,no_run
/// fn main() {
/// let mut prost_build = prost_build::Config::new();
/// prost_build.btree_map(&["."]);
/// prost_build.compile_protos(&["src/frontend.proto", "src/backend.proto"],
/// &["src"]).unwrap();
/// # use std::io::Result;
/// fn main() -> Result<()> {
/// let mut prost_build = prost_build::Config::new();
/// prost_build.btree_map(&["."]);
/// prost_build.compile_protos(&["src/frontend.proto", "src/backend.proto"], &["src"])?;
/// Ok(())
/// }
/// ```
pub fn compile_protos<P>(&mut self, protos: &[P], includes: &[P]) -> Result<()>
Expand Down Expand Up @@ -658,9 +661,10 @@ impl default::Default for Config {
/// # Example `build.rs`
///
/// ```rust,no_run
/// fn main() {
/// prost_build::compile_protos(&["src/frontend.proto", "src/backend.proto"],
/// &["src"]).unwrap();
/// # use std::io::Result;
/// fn main() -> Result<()> {
/// prost_build::compile_protos(&["src/frontend.proto", "src/backend.proto"], &["src"])?;
/// Ok(())
/// }
/// ```
///
Expand Down Expand Up @@ -741,7 +745,7 @@ mod tests {
impl ServiceGenerator for MockServiceGenerator {
fn generate(&mut self, service: Service, _buf: &mut String) {
let mut state = self.state.borrow_mut();
state.service_names.push(service.name.clone());
state.service_names.push(service.name);
}

fn finalize(&mut self, _buf: &mut String) {
Expand Down
2 changes: 1 addition & 1 deletion prost-derive/src/field/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Field {

Ok(Some(Field {
label: label.unwrap_or(Label::Optional),
tag: tag,
tag,
}))
}

Expand Down
Loading

0 comments on commit 2de785a

Please sign in to comment.