Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Add ci #72

Merged
merged 3 commits into from
May 14, 2024
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
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on:
pull_request:
push:
branches:
- main

name: continuous-integration

env:
NUSHELL_CARGO_PROFILE: ci
NU_LOG_LEVEL: DEBUG
CLIPPY_OPTIONS: "-D warnings"

jobs:
fmt-clippy:
strategy:
fail-fast: true
matrix:
# Pinning to Ubuntu 20.04 because building on newer Ubuntu versions causes linux-gnu
# builds to link against a too-new-for-many-Linux-installs glibc version. Consider
# revisiting this when 20.04 is closer to EOL (April 2025)
platform: [macos-latest, ubuntu-20.04, windows-latest]
feature: [default]
include:
- feature: default
flags: ""

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
rustflags: ""

- name: cargo fmt
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --workspace ${{ matrix.flags }} -- $CLIPPY_OPTIONS

# In tests we don't have to deny unwrap
- name: Clippy of tests
run: cargo clippy --tests --workspace ${{ matrix.flags }} -- -D warnings

tests:
strategy:
fail-fast: true
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
feature: [default]
include:
- feature: default
flags: ""
flags:
- # default
- --all-features

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
rustflags: ""

- name: Tests
run: cargo test ${{ matrix.flags }}
2 changes: 1 addition & 1 deletion src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ impl Codegen {
for param in params {
output.extend_from_slice(b", ");
let variable_ty = self.compiler.get_variable(param.var_id).ty;
self.codegen_typename(variable_ty, &inference_vars, output);
self.codegen_typename(variable_ty, inference_vars, output);
output.push(b' ');
output.extend_from_slice(b"variable_");
output.extend_from_slice(param.var_id.0.to_string().as_bytes());
Expand Down
18 changes: 10 additions & 8 deletions src/typechecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct TypedField {
pub where_defined: NodeId,
}

#[allow(clippy::enum_variant_names)]
#[derive(Debug, Clone, PartialEq)]
pub enum Type {
Unknown,
Expand Down Expand Up @@ -368,6 +369,7 @@ impl Typechecker {
}
}

#[allow(clippy::too_many_arguments)]
pub fn typecheck_fun_predecl(
&mut self,
name: NodeId,
Expand Down Expand Up @@ -918,7 +920,7 @@ impl Typechecker {

let mut base_classes = vec![base_class];
if let Some(base_base_classes) = self.compiler.base_classes.get(&base_class) {
base_classes.extend_from_slice(&base_base_classes);
base_classes.extend_from_slice(base_base_classes);
}

self.compiler.base_classes.insert(type_id, base_classes);
Expand Down Expand Up @@ -1239,7 +1241,7 @@ impl Typechecker {
&self,
expected_type: TypeId,
actual_type: TypeId,
local_inferences: &mut Vec<TypeId>,
local_inferences: &mut [TypeId],
) -> bool {
let expected_type = self.compiler.resolve_type(expected_type, local_inferences);
let expected_type = self.compiler.get_underlying_type_id(expected_type);
Expand Down Expand Up @@ -2523,12 +2525,12 @@ impl Typechecker {
let mut fields = fields.clone();
if let Some(base_classes) = self.compiler.base_classes.get(&type_id) {
for type_id in base_classes {
match self.compiler.get_type(*type_id) {
Type::Struct {
fields: base_fields,
..
} => fields.extend_from_slice(&base_fields),
_ => {}
if let Type::Struct {
fields: base_fields,
..
} = self.compiler.get_type(*type_id)
{
fields.extend_from_slice(base_fields)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn test_example(test_name: &Path) -> TestResult {

// Create it if it's not there
let mut temp_dir = std::env::var("JUNE_TESTDIR")
.map(|dir| PathBuf::from(dir))
.map(PathBuf::from)
.unwrap_or_else(|_| std::env::temp_dir());
temp_dir.push("june_tests");

Expand Down