Skip to content

Commit

Permalink
Update CLI and some workflows (#130)
Browse files Browse the repository at this point in the history
* Update CLI and some workflows
* Added experimental formatting to CLI
  • Loading branch information
kaleidawave committed Apr 10, 2024
1 parent 3fab1f7 commit ac2ba2e
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 177 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/github-release.yml
Expand Up @@ -23,7 +23,8 @@ jobs:
outputs:
new-ezno-version: ${{ steps.get-version.outputs.new-ezno-version }}
new-ezno-version-name: ${{ steps.get-version.outputs.new-ezno-version-name }}
sponsors: ${{ steps.get-sponsors.outputs.sponsors }}
SPONSORS: ${{ steps.get-data.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-data.outputs.CONTRIBUTORS }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -55,7 +56,7 @@ jobs:
echo "new-ezno-version-name=${NAME_VERSION}" >> $GITHUB_OUTPUT
fi
- id: get-sponsors
- id: get-data
run: |
SPONSORS=$(gh api graphql -f query='{
user(login: "kaleidawave") {
Expand All @@ -71,7 +72,24 @@ jobs:
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")')
echo "sponsors=$SPONSORS" >> $GITHUB_OUTPUT
echo "SPONSORS=$SPONSORS" >> $GITHUB_OUTPUT
CONTRIBUTORS=$(gh api graphql -f query='{
repository(owner: "kaleidawave", name: "ezno") {
pullRequests(first: 100, states: 'MERGED') {
edges {
node {
author {
login
}
}
}
}
}
}' -q '.data.repository.pullRequests.edges | map(.node.author.login) | unique | join(", ")')
echo "CONTRIBUTORS=$CONTRIBUTORS"
shell: bash
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -103,7 +121,8 @@ jobs:
- name: Build binary
run: cargo build --release
env:
SPONSORS: ${{ needs.get-build-info.outputs.sponsors }}
SPONSORS: ${{ needs.get-build-info.outputs.SPONSORS }}
CONTRIBUTORS: ${{ needs.get-build-info.outputs.CONTRIBUTORS }}

- name: Rename and move release assets
run: |
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/lines-of-code.yml
Expand Up @@ -22,20 +22,26 @@ jobs:

- name: Run update script
run: |
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r name version pathInfo ; do
path=${pathInfo:13:-1}
if [[ -d "$path/src" ]] ; then
linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$path/src" | jq '.[] | .Code');
function record {
cratePath=$1
name=$2
if [ -d "$cratePath/src" ] ; then
linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$cratePath/src" | jq '.[] | .Code');
else
linesOfRustCode=$(scc -c --no-cocomo -f json -i rs $path | jq '.[] | .Code');
linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$cratePath" | jq '.[] | .Code');
fi
echo "\`$name\` has $linesOfRustCode lines of code" # >> $GITHUB_STEP_SUMMARY;
curl \
--header "Content-Type: application/json" \
--header "X-POST-ACCESS-KEY: ${{ secrets.PROJECTS_POST_ACCESS_KEY }}" \
--data "{\"project\":\"$name\",\"language\":\"rust\",\"loc\":$linesOfRustCode}" \
-w "\nUpdated-project: \n" \
https://projects.kaleidawave.workers.dev/update-project;
}
echo "\`$name\` has $linesOfRustCode lines of code" >> $GITHUB_STEP_SUMMARY;
done
record "parser" "ezno-parser"
record "checker" "ezno-checker"
record "src" "ezno"
16 changes: 5 additions & 11 deletions .github/workflows/performance-and-size.yml
Expand Up @@ -46,10 +46,6 @@ jobs:
env:
CARGO_PROFILE_RELEASE_DEBUG: true

- name: Download files
run: |
curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js
- name: Run checker performance
shell: bash
run: |
Expand All @@ -58,12 +54,6 @@ jobs:
# Generate a file which contains everything that Ezno currently implements
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md ./demo.ts
echo "::group::Generated demo.ts"
cat ./demo.ts
cargo run -p ezno-parser --example parse demo.ts --timings
echo "::endgroup::"
echo "::info::Finished file generation"
echo "<details>
Expand All @@ -89,7 +79,7 @@ jobs:
# Printing diagnostics, so turn colors off for GH Summary (also affects printing perf I think)
NO_COLOR=1
./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY
(./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY) || true
echo "\`\`\`
</details>
Expand All @@ -105,6 +95,10 @@ jobs:
echo "::group::Comparing printing of diagnostics"
hyperfine -i './target/release/ezno check demo.ts' './target/release/ezno check demo.ts --count-diagnostics'
echo "::endgroup::"
- name: Download parser files
run: |
curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js
- name: Run parser, minfier/stringer performance
shell: bash
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -74,7 +74,24 @@ jobs:
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")')
echo "sponsors=$SPONSORS" >> $GITHUB_OUTPUT
echo "SPONSORS=$SPONSORS" >> $GITHUB_OUTPUT
CONTRIBUTORS=$(gh api graphql -f query='{
repository(owner: "kaleidawave", name: "ezno") {
pullRequests(first: 100, states: 'MERGED') {
edges {
node {
author {
login
}
}
}
}
}
}' -q '.data.repository.pullRequests.edges | map(.node.author.login) | unique | join(", ")')
echo "CONTRIBUTORS=$CONTRIBUTORS"
shell: bash
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -86,7 +103,8 @@ jobs:
version: ${{ steps.set-arguments.outputs.publish-json-args }}
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
SPONSORS: ${{ steps.get-sponsors.outputs.sponsors }}
SPONSORS: ${{ steps.get-sponsors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors.outputs.CONTRIBUTORS }}

- name: Add WASM to rustup
if: ${{ inputs.ezno-version != 'none' }}
Expand Down
4 changes: 2 additions & 2 deletions checker/src/synthesis/assignments.rs
Expand Up @@ -159,10 +159,10 @@ fn synthesise_object_shorthand_assignable<T: crate::ReadFromFS>(

fn synthesise_object_property_key(
name: &parser::VariableIdentifier,
environment: &Environment,
_environment: &Environment,
) -> PropertyKey<'static> {
match name {
parser::VariableIdentifier::Standard(name, pos) => {
parser::VariableIdentifier::Standard(name, _pos) => {
PropertyKey::String(Cow::Owned(name.to_owned()))
}
parser::VariableIdentifier::Marker(..) => todo!(),
Expand Down
2 changes: 1 addition & 1 deletion checker/src/types/calling.rs
Expand Up @@ -963,7 +963,7 @@ impl FunctionType {

match type_is_subtype {
SubTypeResult::IsSubType => {}
SubTypeResult::IsNotSubType(reason) => {
SubTypeResult::IsNotSubType(_reason) => {
errors.errors.push(FunctionCallingError::MismatchedThis {
expected: TypeStringRepresentation::from_type_id(
free_this_id,
Expand Down
38 changes: 15 additions & 23 deletions checker/src/types/poly_types/generics/generic_structure.rs
@@ -1,15 +1,7 @@
use super::generic_type_arguments::FunctionTypeArguments;
use crate::TypeId;

/// A instance of a generic typed object
#[derive(Clone, Debug)]
pub struct GenericStructure {
pub generic_type: TypeId,
pub arguments: GenericStructureTypeArguments,
}

#[derive(Clone, Debug, Default)]
pub struct GenericStructureTypeArguments(pub(crate) Vec<GenericStructureTypeArgument>);
// #[derive(Clone, Debug, Default)]
// pub struct GenericStructureTypeArguments(pub(crate) Vec<GenericStructureTypeArgument>);

#[derive(Clone, Debug)]
pub enum GenericStructureArgumentValue {
Expand Down Expand Up @@ -41,16 +33,16 @@ pub struct GenericStructureTypeArgument {
// pub(crate) constraint: Option<Box<Type>>,
}

impl From<GenericStructureTypeArguments> for FunctionTypeArguments {
fn from(_instance_of_generics_arguments: GenericStructureTypeArguments) -> Self {
todo!()
// TypeArguments {
// structure_arguments: todo!(),
// local_arguments: todo!(),
// environment: todo!(),
// }
// Cow::Owned(
// instance_of_generics_arguments.into(),
// ))
}
}
// impl From<GenericStructureTypeArguments> for FunctionTypeArguments {
// fn from(_instance_of_generics_arguments: GenericStructureTypeArguments) -> Self {
// todo!()
// // TypeArguments {
// // structure_arguments: todo!(),
// // local_arguments: todo!(),
// // environment: todo!(),
// // }
// // Cow::Owned(
// // instance_of_generics_arguments.into(),
// // ))
// }
// }
10 changes: 1 addition & 9 deletions checker/src/types/poly_types/generics/generic_type_arguments.rs
Expand Up @@ -11,15 +11,7 @@ use crate::{
use map_vec::Map as SmallMap;
use source_map::{Nullable, SpanWithSource};

use std::{fmt::Debug, iter::FromIterator};

use super::{GenericStructureTypeArgument, GenericStructureTypeArguments};

impl FromIterator<GenericStructureTypeArgument> for GenericStructureTypeArguments {
fn from_iter<I: IntoIterator<Item = GenericStructureTypeArgument>>(iter: I) -> Self {
Self(iter.into_iter().collect())
}
}
use std::fmt::Debug;

/// For when a function is called
#[derive(Debug)]
Expand Down
14 changes: 10 additions & 4 deletions src/ast_explorer.rs
Expand Up @@ -8,7 +8,7 @@ use enum_variants_strings::EnumVariantsStrings;
use parser::{source_map::FileSystem, ASTNode, Expression, Module, ToStringOptions};

use crate::{
error_handling::emit_ezno_diagnostic,
reporting::emit_diagnostics,
utilities::{print_to_cli, print_to_cli_without_newline},
};

Expand Down Expand Up @@ -136,7 +136,9 @@ impl ExplorerSubCommand {
}
}
// TODO temp
Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
Err(err) => {
emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
}
}
}
ExplorerSubCommand::FullAST(cfg) => {
Expand All @@ -156,7 +158,9 @@ impl ExplorerSubCommand {
}
}
// TODO temp
Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
Err(err) => {
emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
}
}
}
ExplorerSubCommand::Prettifier(_) | ExplorerSubCommand::Uglifier(_) => {
Expand All @@ -173,7 +177,9 @@ impl ExplorerSubCommand {
};
print_to_cli(format_args!("{}", module.to_string(&options)));
}
Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
Err(err) => {
emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
}
}
}
ExplorerSubCommand::Lexer(_) => {
Expand Down

0 comments on commit ac2ba2e

Please sign in to comment.