Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #38

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/actions/environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build toolchain
description: Installs Dependencies and Compiles Lingo

runs:
using: "composite"
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Integration Test
run: |
# setting java17
ls -alh /usr/lib/jvm/
# export JAVA_HOME=/usr/lib/jvm/java-17-temurin-amd64

# building lingo
cargo b --release

# installing lingua-franca tests
git clone https://github.com/lf-lang/lingua-franca.git ./lingua-franca

# installing lfc
curl -Ls https://install.lf-lang.org | bash -s nightly cli
export PATH="$HOME/.local/bin:$PATH"

# going into lfc repo and checking out the vers
cd ./lingua-franca
git reset nightly
cd ..

shell: bash
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
pull_request:
push:
branches:
- main

name: Test Lingo
jobs:
cpp-test:
name: CPP Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/environment
- name: Integration Test Cpp
run: |
# copying Lingo.toml
cp test/Lingo-Cpp.toml ./lingua-franca/test/Lingo.toml

cd ./lingua-franca/test/
../../target/release/lingo build

shell: bash
typescript-test:
name: TypeScript Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/environment
- name: Integration Test TypeScript
run: |
# copying Lingo.toml
cp test/Lingo-TypeScript.toml ./lingua-franca/test/Lingo.toml

cd ./lingua-franca/test/
../../target/release/lingo build

shell: bash
lfc-test:
name: LFC Fallback Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/environment
- name: Integration Test TypeScript
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
run: |
# copying Lingo.toml
cp test/Lingo-LFC.toml ./lingua-franca/test/Lingo.toml

cd ./lingua-franca/test/
../../target/release/lingo build

shell: bash

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ sandbox/
build/
**/src-gen/
tmp/
lingua-franca
6 changes: 3 additions & 3 deletions derivation.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ naersk, src, lib, pkg-config, cmake, zlib, openssl }:
{ naersk, src, lib, pkg-config, cmake, zlib, openssl, glibc}:

naersk.buildPackage {
pname = "lingo";
Expand All @@ -8,8 +8,8 @@ naersk.buildPackage {

cargoSha256 = lib.fakeSha256;

nativeBuildInputs = [ pkg-config cmake ];
buildInputs = [ zlib openssl ];
nativeBuildInputs = [ pkg-config cmake zlib openssl glibc];
buildInputs = [ ];

meta = with lib; {
description = "Simple package manager for lingua franca";
Expand Down
30 changes: 14 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;

naersk = {
url = github:nix-community/naersk;
};
Expand Down
6 changes: 3 additions & 3 deletions sandbox/Lingo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ fast = true
[[app]]
name = "git-hook"
target = "Cpp"
main_reactor = "src/Main.lf"
main = "src/Main.lf"
dependencies = {}
# main_reactor defaults to src/Main.lf
# main defaults to src/Main.lf

# dependencies
#[[app.dependencies]]
Expand All @@ -31,7 +31,7 @@ logging = "info"
# second binary
[[app]]
name = "embedded"
main_reactor = "src/Main2.lf"
main = "src/Main2.lf"
dependencies = {}
target = "Cpp"

Expand Down
10 changes: 8 additions & 2 deletions src/backends/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ fn gen_cmake_files(app: &App, options: &BuildCommandOptions) -> BuildResult {
cmake.arg("-DREACTOR_CPP_VALIDATE=ON");
cmake.arg("-DREACTOR_CPP_TRACE=OFF");
cmake.arg("-DREACTOR_CPP_LOG_LEVEL=3");
cmake.arg(format!("-DLF_SRC_PKG_PATH={}", app.root_path.display()));
cmake.arg(format!(
"-DLF_SRC_PKG_PATH={}",
app.src_dir_path()
.expect("not a valid main reactor path")
.display()
));
cmake.arg(app.src_gen_dir());
cmake.arg(format!("-B {}", build_dir.display()));
cmake.current_dir(&build_dir);
Expand All @@ -42,7 +47,8 @@ fn gen_cmake_files(app: &App, options: &BuildCommandOptions) -> BuildResult {
}

fn do_cmake_build(results: &mut BatchBuildResults, options: &BuildCommandOptions) {
super::lfc::LFC::do_parallel_lfc_codegen(options, results, false);
results.keep_going(options.keep_going);
super::lfc::LFC::do_parallel_lfc_codegen(options, results, true);
if !options.compile_target_code {
return;
}
Expand Down
8 changes: 6 additions & 2 deletions src/backends/lfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ impl LFC {
results: &mut BatchBuildResults,
compile_target_code: bool,
) {
results.par_map(|app| LFC::do_lfc_codegen(app, options, compile_target_code));
results.keep_going(options.keep_going);
// TODO: using map_par introduced a race condition
results.map(|app| LFC::do_lfc_codegen(app, options, compile_target_code));
}

/// Do codegen for a single app.
Expand Down Expand Up @@ -89,10 +91,12 @@ impl<'a> LfcJsonArgs<'a> {
.unwrap()
.as_object_mut()
.unwrap();

// lfc does not support no-compile:false
if self.no_compile {
properties.insert("no-compile".to_string(), self.no_compile.into());
properties.insert("no-compile".to_string(), serde_json::Value::Bool(true));
}

Ok(value)
}
}
Expand Down
32 changes: 31 additions & 1 deletion src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ pub fn execute_command<'a>(command: &CommandSpec, apps: &[&'a App]) -> BatchBuil
match build_system {
BuildSystem::LFC => lfc::LFC.execute_command(command, &mut sub_res),
BuildSystem::CMake => cmake::Cmake.execute_command(command, &mut sub_res),
BuildSystem::Cargo => todo!(),
BuildSystem::Npm => npm::Npm.execute_command(command, &mut sub_res),
BuildSystem::Pnpm => pnpm::Pnpm.execute_command(command, &mut sub_res),
BuildSystem::Cargo => todo!(),
};
result.append(sub_res);
}
Expand Down Expand Up @@ -91,13 +91,15 @@ pub trait BatchBackend {
/// Collects build results by app.
pub struct BatchBuildResults<'a> {
results: Vec<(&'a App, BuildResult)>,
keep_going: bool,
}

impl<'a> BatchBuildResults<'a> {
/// Create an empty result, only for use with `append`.
fn new() -> Self {
Self {
results: Vec::new(),
keep_going: false,
}
}

Expand All @@ -106,8 +108,13 @@ impl<'a> BatchBuildResults<'a> {
fn for_apps(apps: &[&'a App]) -> Self {
Self {
results: apps.iter().map(|&a| (a, Ok(()))).collect(),
keep_going: false,
}
}
/// sets the keep going value
fn keep_going(&mut self, value: bool) {
self.keep_going = value
}

/// Print this result collection to standard output.
pub fn print_results(&self) {
Expand Down Expand Up @@ -143,6 +150,14 @@ impl<'a> BatchBuildResults<'a> {
self.results.iter_mut().for_each(|(app, res)| {
if let Ok(()) = res {
*res = f(app);

if (*res).is_err() && !self.keep_going {
panic!(
"build step failed because of {} with main reactor {}!",
&app.name,
&app.main_reactor.display()
);
}
}
});
self
Expand All @@ -157,6 +172,15 @@ impl<'a> BatchBuildResults<'a> {
self.results.par_iter_mut().for_each(|(app, res)| {
if let Ok(()) = res {
*res = f(app);

if (*res).is_err() && !self.keep_going {
panic!(
"build step failed with error {:?} because of app {} with main reactor {}!",
&res,
&app.name,
&app.main_reactor.display()
);
}
}
});
self
Expand All @@ -175,12 +199,18 @@ impl<'a> BatchBuildResults<'a> {
.iter()
.filter_map(|&(app, ref res)| res.as_ref().ok().map(|()| app))
.collect();

if vec.is_empty() {
return self;
}

match f(&vec) {
Ok(()) => { /* Do nothing, all apps have succeeded. */ }
Err(e) => {
if !self.keep_going {
panic!("build step failed!");
}

// Mark all as failed for the same reason.
let shared: Arc<AnyError> = e.into();
for (_app, res) in &mut self.results {
Expand Down
Loading
Loading