Skip to content

Commit

Permalink
chore: github workflow to run tests (#12)
Browse files Browse the repository at this point in the history
Adding github workflow to run rust tests as well as integration tests.
As part of that cleaned up use of _nightly_ feature and removed dependency on `cargo-expand` 
module in order to keep the workflow fast.

- chore: build+test workflow
- chore: remove str_split feature annotation
- chore: setup dart and pub for ci tests
- chore: adding llvm to github actions
- rid-build: expanding without cargo expand
- chore: rustc expand needs nightly rust
- chore: final cleanup of github action
  • Loading branch information
thlorenz authored Aug 3, 2021
1 parent c0aab70 commit 97fd45b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build+test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build+Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [nightly]
dart_sdk: [2.14.0-115.0.dev] # ffigen depends on Dart v2.14+

steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}

# ffigen depends on an llvm
- name: Install libclang-10-dev
run: sudo apt-get install libclang-10-dev

- uses: dart-lang/[email protected]
with:
sdk: ${{ matrix.dart_sdk }}

- uses: actions/checkout@master

- name: Build and Run Tests
run: make test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rid
# Rid [![](https://github.com/thlorenz/rid/workflows/Build+Test/badge.svg?branch=master)](https://github.com/thlorenz/rid/actions)

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.

Expand Down
4 changes: 1 addition & 3 deletions rid-build/src/bindings_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ impl<'a> BindingsGenerator<'a> {
Ok(bindings)
}

// Option that doesn't depend on cargo-expand to be installed
// cargo rustc --lib -- -Zunstable-options --pretty=expanded
// cargo rustc --lib -- -Zunpretty=expanded
fn expand_crate(&self) -> Result<String> {
let output = Command::new(&self.cargo)
.args(&self.expand_args)
.args(&["--color", "never"])
.current_dir(&self.crate_dir)
.output()?;

Expand Down
22 changes: 13 additions & 9 deletions rid-build/src/build_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ pub enum BuildTarget {
impl BuildTarget {
pub(crate) fn cargo_expand_args(&self) -> Vec<String> {
use BuildTarget::*;
match self {
Release | Debug => {
vec!["expand".to_string(), "--lib".to_string()]

let mut target = match self {
Release | Debug => vec!["--lib".to_string()],
DebugExample(example_name) => {
vec!["--example".to_string(), example_name.to_string()]
}
DebugExample(example_name) => vec![
"expand".to_string(),
"--example".to_string(),
example_name.to_string(),
],
}
};
let mut cmd = vec!["rustc".to_string()];
cmd.append(&mut target);
cmd.append(&mut vec![
"--".to_string(),
"-Zunpretty=expanded".to_string(),
]);
cmd
}
}
2 changes: 0 additions & 2 deletions rid-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(stable_features)]
#![feature(str_split_once)]
use std::{fmt::Display, fs, iter::FromIterator, path::Path};

use anyhow::Result;
Expand Down
5 changes: 4 additions & 1 deletion tests/dart/field_access/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ test-all:
$(MAKE) test TEST=enums
$(MAKE) test TEST=vecs

test:
test: ./.dart_tool/
cargo build --example $(TEST) && \
TEST=$(TEST) cargo run rid_build && \
dart run test ./test/$(TEST).dart

expand:
cargo expand --example $(TEST)

./.dart_tool/:
pub get

.PHONY: test-all test expand

0 comments on commit 97fd45b

Please sign in to comment.