Skip to content

Commit

Permalink
Random fixes across the project (#90)
Browse files Browse the repository at this point in the history
- Up to 114 specification tests passing
- Multiple fixes to parsing
  • Loading branch information
kaleidawave authored Dec 5, 2023
1 parent b5d16a7 commit 6626479
Show file tree
Hide file tree
Showing 102 changed files with 3,304 additions and 2,393 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-tags: true
- name: Get version
id: get-version
run: |
version=$(git tag --list 'release/main-*' --sort=-taggerdate | tail -n 1)
echo "Releasing ${version:13}"
echo "new-ezno-version=${version:13}" >> $GITHUB_OUTPUT
tag=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1)
echo "Releasing ${tag:13}"
echo "new-ezno-version=${tag:13}" >> $GITHUB_OUTPUT
- id: get-sponsors
run: |
Expand Down Expand Up @@ -101,7 +103,7 @@ jobs:

- name: Print artifacts
run: |
echo "::group::Print Artifacts"
echo "::group::Build artifacts"
ls -R build-artifacts
echo "::endgroup::"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lines-of-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
-w "\nUpdated-project: \n" \
https://projects.kaleidawave.workers.dev/update-project;
echo "\`$name\` has $linesOfRustCode lines of code"Y;
echo "\`$name\` has $linesOfRustCode lines of code" >> $GITHUB_STEP_SUMMARY;
done
84 changes: 48 additions & 36 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ env:
jobs:
validity:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -38,27 +38,49 @@ jobs:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Check source is valid
run: cargo check --workspace

- name: Check binary
run: cargo check --bin ezno

extras:
runs-on: ubuntu-latest
needs: validity
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable

- uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'src/**'
parser:
- 'parser/**'
checker:
- 'checker/**'
src:
- 'src/**'
- name: Check source is valid
run: cargo check --workspace

- name: Check binary
run: cargo check --bin ezno
- uses: brndnmtthws/rust-action-cargo-binstall@v1
if: steps.changes.outputs.src == 'true'
with:
packages: [email protected]
- uses: denoland/setup-deno@v1
if: steps.changes.outputs.src == 'true'
with:
deno-version: v1.x
- uses: actions/setup-node@v3
if: steps.changes.outputs.src == 'true'
with:
node-version: 18

- name: Check WASM
if: steps.changes.outputs.src == 'true'
run: |
Expand All @@ -68,6 +90,16 @@ jobs:
npm run build
working-directory: src/js-cli-and-library

- name: Build and test WASM
if: steps.changes.outputs.src == 'true'
run: |
npm ci
npm run test
node ./dist/cli.cjs info
deno run -A ./dist/cli.mjs info
working-directory: src/js-cli-and-library
shell: bash

- name: Check parser without extras
if: steps.changes.outputs.parser == 'true'
run:
Expand All @@ -77,7 +109,7 @@ jobs:
if: steps.changes.outputs.checker == 'true'
run:
cargo check -p ezno-checker --no-default-features

formating:
runs-on: ubuntu-latest
steps:
Expand All @@ -92,13 +124,12 @@ jobs:
packages: taplo-cli

- name: Check TOML formatting with taplo
run: |
taplo fmt --check **/*/Cargo.toml
run: taplo fmt --check **/*/Cargo.toml

tests:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -135,37 +166,18 @@ jobs:

- name: Run checker tests
if: steps.changes.outputs.checker == 'true'
run: cargo test -F ezno-parser
run: |
# Test checker with the parser features
cargo test -F ezno-parser
working-directory: checker

- name: Run base tests
run: cargo test

- uses: brndnmtthws/rust-action-cargo-binstall@v1
with:
packages: [email protected]

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Build and test WASM
run: |
rustup target add wasm32-unknown-unknown
npm ci
npm run test
node ./dist/cli.cjs info
deno run -A ./dist/cli.mjs info
working-directory: src/js-cli-and-library
shell: bash

fuzzing:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 15
continue-on-error: true
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default = []
ezno-parser = ["parser"]

[dependencies]
source-map = { version = "0.14.6", features = ["serde-serialize"] }
source-map = { version = "0.14.7", features = ["serde-serialize"] }

binary-serialize-derive = { path = "./binary-serialize-derive", version = "0.0.1" }

Expand Down
11 changes: 11 additions & 0 deletions checker/definitions/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ interface nominal Array<T> {
}

interface Math {
@DoNotIncludeThis
sin(x: number): number performs const sin;
@DoNotIncludeThis
cos(x: number): number performs const cos;
@DoNotIncludeThis
tan(x: number): number performs const tan;
@DoNotIncludeThis
floor(x: number): number performs const floor;
@DoNotIncludeThis
sqrt(x: number): number performs const sqrt;
@DoNotIncludeThis
cbrt(x: number): number performs const cbrt;

// TODO newer method
Expand All @@ -63,14 +69,17 @@ interface nominal string {
}

interface Console {
@DoNotIncludeThis
log(msg: any): void;
}

interface JSON {
// TODO any temp
@DoNotIncludeThis
parse(input: string): any;

// TODO any temp
@DoNotIncludeThis
stringify(input: any): string;
}

Expand All @@ -79,8 +88,10 @@ interface Function {
}

interface Object {
@DoNotIncludeThis
setPrototypeOf(on: object, to: object): object performs const set_prototype;

@DoNotIncludeThis
getPrototypeOf(on: object): object | null performs const get_prototype;

// create(prototype: object): object performs {
Expand Down
2 changes: 0 additions & 2 deletions checker/examples/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
fn main() {
use ezno_checker::{check_project, synthesis};
use std::{
collections::HashSet,
env, fs,
path::{Path, PathBuf},
};
Expand All @@ -21,7 +20,6 @@ fn main() {
}
},
None,
Default::default(),
);

let args: Vec<_> = env::args().collect();
Expand Down
23 changes: 11 additions & 12 deletions checker/specification/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn markdown_lines_append_test_to_rust(
writeln!(out, "}}").unwrap();
}
first_section = false;
let section_heading = heading_to_rust_name(section_heading);
let section_heading = heading_to_rust_identifier(section_heading);
writeln!(out, "mod {section_heading} {{").unwrap();
continue;
}
Expand All @@ -58,7 +58,7 @@ fn markdown_lines_append_test_to_rust(
}

let heading = line.strip_prefix("####").unwrap().trim_start();
let test_title = heading_to_rust_name(heading);
let test_title = heading_to_rust_identifier(heading);

let blocks = {
let mut blocks = Vec::new();
Expand All @@ -75,7 +75,7 @@ fn markdown_lines_append_test_to_rust(
if !code.trim().is_empty() {
blocks.push((
current_filename.unwrap_or(DEFAULT_FILE_PATH),
mem::take(&mut code).replace('"', "\\\""),
mem::take(&mut code),
));
}
current_filename = Some(path);
Expand All @@ -87,32 +87,31 @@ fn markdown_lines_append_test_to_rust(
code.push_str(line);
code.push('\n')
}
// Escape "
let code = code.replace('"', "\\\"");
blocks.push((current_filename.unwrap_or(DEFAULT_FILE_PATH), code));
blocks
};
let errors = {
let mut errors = Vec::new();
for (_, line) in lines.by_ref() {
if line.is_empty() || !line.starts_with('-') {
if !errors.is_empty() {
break;
}
} else {
if line.starts_with("#") {
panic!("block with no diagnostics or break between")
} else if line.starts_with('-') {
let error =
line.strip_prefix("- ").unwrap().replace('\\', "").replace('"', "\\\"");
errors.push(format!("\"{}\"", error))
} else if !errors.is_empty() {
break;
}
}
errors
};

let errors = errors.join(", ");

let heading_idx = heading_idx + 1;
let code = blocks
.into_iter()
.map(|(path, content)| format!("(\"{path}\",\"{content}\"),"))
.map(|(path, content)| format!("(\"{path}\",r#\"{content}\"#),"))
.fold(String::new(), |mut acc, cur| {
acc.push_str(&cur);
acc
Expand All @@ -132,7 +131,7 @@ fn markdown_lines_append_test_to_rust(
Ok(())
}

fn heading_to_rust_name(heading: &str) -> String {
fn heading_to_rust_identifier(heading: &str) -> String {
heading
.replace([' ', '-', '&'], "_")
.replace(['*', '\'', '`', '"', '!', '(', ')', ','], "")
Expand Down
Loading

0 comments on commit 6626479

Please sign in to comment.