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

Commit 8216dca

Browse files
authored
Add ci (#72)
* Add ci * fix clippy warnings * fix ci
1 parent c123ed1 commit 8216dca

File tree

4 files changed

+84
-10
lines changed

4 files changed

+84
-10
lines changed

.github/workflows/ci.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches:
5+
- main
6+
7+
name: continuous-integration
8+
9+
env:
10+
NUSHELL_CARGO_PROFILE: ci
11+
NU_LOG_LEVEL: DEBUG
12+
CLIPPY_OPTIONS: "-D warnings"
13+
14+
jobs:
15+
fmt-clippy:
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
# Pinning to Ubuntu 20.04 because building on newer Ubuntu versions causes linux-gnu
20+
# builds to link against a too-new-for-many-Linux-installs glibc version. Consider
21+
# revisiting this when 20.04 is closer to EOL (April 2025)
22+
platform: [macos-latest, ubuntu-20.04, windows-latest]
23+
feature: [default]
24+
include:
25+
- feature: default
26+
flags: ""
27+
28+
runs-on: ${{ matrix.platform }}
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup Rust toolchain and cache
34+
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
35+
with:
36+
rustflags: ""
37+
38+
- name: cargo fmt
39+
run: cargo fmt --all -- --check
40+
41+
- name: Clippy
42+
run: cargo clippy --workspace ${{ matrix.flags }} -- $CLIPPY_OPTIONS
43+
44+
# In tests we don't have to deny unwrap
45+
- name: Clippy of tests
46+
run: cargo clippy --tests --workspace ${{ matrix.flags }} -- -D warnings
47+
48+
tests:
49+
strategy:
50+
fail-fast: true
51+
matrix:
52+
platform: [macos-latest, ubuntu-20.04, windows-latest]
53+
feature: [default]
54+
include:
55+
- feature: default
56+
flags: ""
57+
flags:
58+
- # default
59+
- --all-features
60+
61+
runs-on: ${{ matrix.platform }}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Setup Rust toolchain and cache
67+
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
68+
with:
69+
rustflags: ""
70+
71+
- name: Tests
72+
run: cargo test ${{ matrix.flags }}

src/codegen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl Codegen {
724724
for param in params {
725725
output.extend_from_slice(b", ");
726726
let variable_ty = self.compiler.get_variable(param.var_id).ty;
727-
self.codegen_typename(variable_ty, &inference_vars, output);
727+
self.codegen_typename(variable_ty, inference_vars, output);
728728
output.push(b' ');
729729
output.extend_from_slice(b"variable_");
730730
output.extend_from_slice(param.var_id.0.to_string().as_bytes());

src/typechecker.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct TypedField {
3131
pub where_defined: NodeId,
3232
}
3333

34+
#[allow(clippy::enum_variant_names)]
3435
#[derive(Debug, Clone, PartialEq)]
3536
pub enum Type {
3637
Unknown,
@@ -368,6 +369,7 @@ impl Typechecker {
368369
}
369370
}
370371

372+
#[allow(clippy::too_many_arguments)]
371373
pub fn typecheck_fun_predecl(
372374
&mut self,
373375
name: NodeId,
@@ -918,7 +920,7 @@ impl Typechecker {
918920

919921
let mut base_classes = vec![base_class];
920922
if let Some(base_base_classes) = self.compiler.base_classes.get(&base_class) {
921-
base_classes.extend_from_slice(&base_base_classes);
923+
base_classes.extend_from_slice(base_base_classes);
922924
}
923925

924926
self.compiler.base_classes.insert(type_id, base_classes);
@@ -1239,7 +1241,7 @@ impl Typechecker {
12391241
&self,
12401242
expected_type: TypeId,
12411243
actual_type: TypeId,
1242-
local_inferences: &mut Vec<TypeId>,
1244+
local_inferences: &mut [TypeId],
12431245
) -> bool {
12441246
let expected_type = self.compiler.resolve_type(expected_type, local_inferences);
12451247
let expected_type = self.compiler.get_underlying_type_id(expected_type);
@@ -2523,12 +2525,12 @@ impl Typechecker {
25232525
let mut fields = fields.clone();
25242526
if let Some(base_classes) = self.compiler.base_classes.get(&type_id) {
25252527
for type_id in base_classes {
2526-
match self.compiler.get_type(*type_id) {
2527-
Type::Struct {
2528-
fields: base_fields,
2529-
..
2530-
} => fields.extend_from_slice(&base_fields),
2531-
_ => {}
2528+
if let Type::Struct {
2529+
fields: base_fields,
2530+
..
2531+
} = self.compiler.get_type(*type_id)
2532+
{
2533+
fields.extend_from_slice(base_fields)
25322534
}
25332535
}
25342536
}

tests/integration_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_example(test_name: &Path) -> TestResult {
8181

8282
// Create it if it's not there
8383
let mut temp_dir = std::env::var("JUNE_TESTDIR")
84-
.map(|dir| PathBuf::from(dir))
84+
.map(PathBuf::from)
8585
.unwrap_or_else(|_| std::env::temp_dir());
8686
temp_dir.push("june_tests");
8787

0 commit comments

Comments
 (0)