Skip to content

Commit

Permalink
Improve CI setup + other fixes (#214)
Browse files Browse the repository at this point in the history
* CI Improvements
* Parser formatting
* Update crates & library
* Improvements to CLI and build command
* Extract REPL code
* Add JS tests
* Update description of project
* Add options to specification
* Add `duplicate_block` example
* Improvements
* Fuzzing only on final or labelled
* Sponsors in info fix
  • Loading branch information
kaleidawave authored Nov 13, 2024
1 parent 9088496 commit bba226c
Show file tree
Hide file tree
Showing 53 changed files with 2,626 additions and 1,689 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/clippy-rustfmt-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
target/
jobs:
publish:
run-and-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -23,15 +23,19 @@ jobs:

- name: Run automated fixes
run: |
cargo clippy --fix
# Run clippy on projects
cargo clippy --fix --manifest-path ./parser/Cargo.toml --allow-dirty
cargo clippy --fix --manifest-path ./checker/Cargo.toml --allow-dirty
cargo clippy --fix --allow-dirty
# Format
cargo fmt
- name: Commit
- name: Commit changes
run: |
git add .
git commit -m "Run clippy --fix & formatting"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Run clippy --fix & cargo fmt"
git push
69 changes: 31 additions & 38 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
runs-on: ubuntu-latest

outputs:
new-ezno-version: ${{ steps.get-version.outputs.new-ezno-version }}
LATEST_EZNO_VERSION: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION }}
LATEST_EZNO_VERSION_DASH: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION_DASH }}
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}

Expand All @@ -38,43 +39,32 @@ jobs:
git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*'
echo "::endgroup::"
TAG=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1)
echo "Building GH release for ${TAG:13}"
echo "new-ezno-version=${TAG:13}" >> $GITHUB_OUTPUT
TAG=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1 | cut -c 14-)
# Replace '.' with '-'
NAME_VERSION=$(echo $VERSION | sed -e "s/\./-/g")
echo "::notice::Releasing with found version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
else
VERSION="${{ inputs.ezno-version }}"
echo "Building GH release for ${VERSION}"
echo "new-ezno-version=${VERSION}" >> $GITHUB_OUTPUT
TAG="${{ inputs.ezno-version }}"
# Replace '.' with '-'
NAME_VERSION=$(echo $VERSION | sed -e "s/\./-/g")
echo "::notice::Releasing with specific version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
fi
- id: get-sponsors-and-contributors
- name: Get sponsors and contributors
id: get-sponsors-and-contributors
run: |
SPONSORS=$(gh api graphql -f query='{
user(login: "kaleidawave") {
sponsorshipsAsMaintainer(first: 100, activeOnly: false) {
edges {
node {
sponsor {
name, login
}
}
}
}
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")')
CONTRIBUTORS=$(
gh pr list --state merged --json author | jq 'map(.author.name // .author.login) | unique | join(",")' --raw-output
)
SQP='.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
GQL_SQ='{ user(login: "kaleidawave") { sponsorshipsAsMaintainer(first: 100, activeOnly: false) { edges { node { sponsor { name, login } } } } } }'
SPONSORS=$(gh api graphql -f query="$GQL_SQ" -q "$SQP")
CQP='map(.author.name // .author.login) | unique | join(",")'
CONTRIBUTORS=$(gh pr list --state merged --json author | jq "$CQP" --raw-output)
echo "SPONSORS=$SPONSORS" # >> $GITHUB_OUTPUT
echo "CONTRIBUTORS=$CONTRIBUTORS"
echo "SPONSORS=$SPONSORS" >> "$GITHUB_OUTPUT"
echo "CONTRIBUTORS=$CONTRIBUTORS" >> "$GITHUB_OUTPUT"
echo "::notice::CONTRIBUTORS=$CONTRIBUTORS and SPONSORS=$SPONSORS"
shell: bash
env:
Expand All @@ -88,13 +78,16 @@ jobs:
os: [ubuntu-latest, windows-latest]
include:
- os: windows-latest
executable-extension: .exe
platform_name: x86_64-pc-windows
platform-name: x86_64-pc-windows
executable-extension: ".exe"
- os: ubuntu-latest
platform_name: x86_64-unknown-linux
platform-name: x86_64-unknown-linux

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

env:
LEVEL: release

# Important that everything here works in all the above OSes!
steps:
- uses: actions/checkout@v4
Expand All @@ -110,10 +103,10 @@ jobs:
SPONSORS: ${{ needs.get-build-info.outputs.SPONSORS }}
CONTRIBUTORS: ${{ needs.get-build-info.outputs.CONTRIBUTORS }}

- name: Rename and move release assets
- name: Rename and move ${{ env.LEVEL }} assets
run: |
mkdir artifacts
mv target/release/ezno${{ matrix.executable-extension }} "artifacts/ezno-${{ needs.get-build-info.outputs.new-ezno-version }}-${{ matrix.platform_name }}${{ matrix.executable-extension }}"
mv "target/${{ env.LEVEL }}/ezno${{ matrix.executable-extension }}" "artifacts/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION_DASH }}-${{ matrix.platform-name }}${{ matrix.executable-extension }}"
- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -144,8 +137,8 @@ jobs:
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
name: "Ezno ${{ needs.get-build-info.outputs.new-ezno-version }}"
tag_name: "release/ezno-${{ needs.get-build-info.outputs.new-ezno-version }}"
name: "Ezno ${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
tag_name: "release/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
body: "For @kaleidawave to update"
files: |
README.md
Expand Down
123 changes: 102 additions & 21 deletions .github/workflows/performance-and-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,47 @@ jobs:
- uses: brndnmtthws/rust-action-cargo-binstall@v1
with:
packages: hyperfine

- name: Install valgrind
run: sudo apt-get install valgrind

- name: Build Ezno
run: cargo build --release
env:
CARGO_PROFILE_RELEASE_DEBUG: true

- name: Get base ezno
if: github.ref_name != 'main'
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: latest-checker
path: previous-ezno

- name: Set compilers
id: compilers
shell: bash
run: |
if [ -d "previous-ezno" ]; then
echo "::notice::Comparing against previous"
echo "BINARIES=./target/release/ezno,./previous-ezno/ezno" >> "$GITHUB_OUTPUT"
else
echo "::notice::Running singularly"
echo "BINARIES=./target/release/ezno" >> "$GITHUB_OUTPUT"
fi
- name: Run checker performance
shell: bash
run: |
# Generate a file which contains everything that Ezno currently implements
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md --comment-headers --out ./demo.tsx
cargo run -p ezno-parser \
--example code_blocks_to_script ./checker/specification/specification.md \
--comment-headers \
--out ./demo.tsx
echo "### Checking
\`\`\`shell
$(hyperfine -i './target/release/ezno check demo.tsx')
$(hyperfine -i -L compiler ${{ steps.compilers.outputs.BINARIES }} '{compiler} check demo.tsx')
\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "<details>
Expand All @@ -58,8 +84,8 @@ jobs:
echo "::info::Wrote code to summary"
command_output=$(./target/release/ezno check demo.tsx --timings --max-diagnostics all 2>&1 || true)
diagnostics=""; statistics=""; found_splitter=false;
while IFS= read -r line; do
if [[ "$line" == "---"* ]]; then found_splitter=true;
elif [[ "$found_splitter" == false ]]; then diagnostics+="$line"$'\n';
Expand All @@ -73,16 +99,35 @@ jobs:
$diagnostics
\`\`\`
</details>
<details>
<summary>Statistics</summary>
\`\`\`
$statistics
\`\`\`
</details>
" >> $GITHUB_STEP_SUMMARY
if [ -d "previous-ezno" ]; then
OUT=$(./previous-ezno/ezno check demo.tsx --timings --max-diagnostics all 2>&1 || true)
$base_statistics=$(echo $OUT | rg "Diagnostics:" -A 100)
echo "
<details>
<summary>Statistics</summary>
\`\`\`
$statistics
\`\`\`
against base
\`\`\`
$base_statistics
\`\`\`
against base
</details>
" >> $GITHUB_STEP_SUMMARY
else
echo "<details>
<summary>Statistics</summary>
\`\`\`
$statistics
\`\`\`
</details>" >> $GITHUB_STEP_SUMMARY
fi
- name: Run checker performance w/staging
shell: bash
if: github.ref_name != 'main'
Expand All @@ -93,7 +138,8 @@ jobs:
cargo run -p ezno-parser --example code_blocks_to_script all.md --comment-headers --out ./all.tsx
./target/release/ezno check all.tsx --timings || true
hyperfine -i './target/release/ezno check all.tsx'
hyperfine -i -L compiler ${{ steps.compilers.outputs.BINARIES }} '{compiler} check all.tsx'
echo "::endgroup::"
- name: Run checker performance on large file
Expand All @@ -109,23 +155,58 @@ jobs:
done
./target/release/ezno check large.tsx --timings --max-diagnostics 0 || true
hyperfine -i './target/release/ezno check large.tsx'
hyperfine -i -L compiler ${{ steps.compilers.outputs.BINARIES }} '{compiler} check large.tsx'
echo "::endgroup::"
- name: Valgrind and callgrind
shell: bash
continue-on-error: true
run: |
IFS=',' read -ra ITEMS <<< ${{ steps.compilers.outputs.BINARIES }}
for compiler in ${ITEMS[@]}; do
echo "::group::Running $compiler"
echo "::group::Callgrind"
valgrind --tool=callgrind --callgrind-out-file=cpu-out $compiler check demo.tsx | true
echo "CPU usage:"
head -n100 cpu-out
echo "::endgroup::"
echo "::group::Valgrind"
valgrind --log-file=memory-out $compiler check demo.tsx | true
echo "Memory usage:"
cat memory-out
echo "::endgroup::"

echo "::endgroup::"
done

- name: Run parsing & stringing (minfied) benchmarks
shell: bash
continue-on-error: true
run: |
strings=(
"https://esm.sh/v128/[email protected]/es2022/react-dom.mjs"
"https://esm.sh/v135/[email protected]/es2022/typescript.mjs"
)
# Currently broken "https://esm.sh/v135/[email protected]/es2022/typescript.mjs"
for url in "${strings[@]}"; do
curl -sS $url > input.js
echo "--- debug: $url ---"
cargo run -p ezno-parser --example parse input.js --timings --render-timings
echo "--- release: $url ---"
cargo run -p ezno-parser --release --example parse input.js --timings --render-timings
hyperfine "./target/debug/examples/parse input.js" "./target/release/examples/parse input.js"
# TODO copy expression
curl -sS $url > input.js
echo "::group::Comparison"
hyperfine \
-L compiler ${{ steps.compilers.outputs.BINARIES }} \
'{compiler} ast-explorer full input.js --timings'
echo "::endgroup::"
done
- name: Upload checker
if: github.ref == 'main'
uses: actions/upload-artifact@v4
with:
name: latest-checker
path: target/release/ezno
retention-days: 90
43 changes: 17 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,20 @@ jobs:
echo "publish-json-args=$KEY_PAIR_ARGS_JSON" >> $GITHUB_OUTPUT
shell: bash

- id: get-sponsors
# Needed for WASM
- name: Get sponsors and contributors
id: get-sponsors-and-contributors
run: |
SPONSORS=$(
gh api graphql -f query='{
user(login: "kaleidawave") {
sponsorshipsAsMaintainer(first: 100, activeOnly: false) {
edges {
node {
sponsor {
name, login
}
}
}
}
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
)
CONTRIBUTORS=$(
gh pr list --state merged --json author | jq 'map(.author.name // .author.login) | unique | join(",")' --raw-output
)
echo "SPONSORS=$SPONSORS" >> $GITHUB_OUTPUT
echo "CONTRIBUTORS=$CONTRIBUTORS" >> $GITHUB_OUTPUT
SQP='.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
GQL_SQ='{ user(login: "kaleidawave") { sponsorshipsAsMaintainer(first: 100, activeOnly: false) { edges { node { sponsor { name, login } } } } } }'
SPONSORS=$(gh api graphql -f query="$GQL_SQ" -q "$SQP")
CQP='map(.author.name // .author.login) | unique | join(",")'
CONTRIBUTORS=$(gh pr list --state merged --json author | jq "$CQP" --raw-output)
echo "SPONSORS=$SPONSORS" >> "$GITHUB_OUTPUT"
echo "CONTRIBUTORS=$CONTRIBUTORS" >> "$GITHUB_OUTPUT"
echo "::notice::CONTRIBUTORS=$CONTRIBUTORS and SPONSORS=$SPONSORS"
shell: bash
env:
Expand All @@ -94,8 +84,8 @@ jobs:
version: ${{ steps.set-arguments.outputs.publish-json-args }}
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
SPONSORS: ${{ steps.get-sponsors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors.outputs.CONTRIBUTORS }}
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}

- name: Add WASM to rustup
if: ${{ inputs.ezno-version != 'none' }}
Expand All @@ -115,7 +105,8 @@ jobs:
ls dist
working-directory: src/js-cli-and-library
env:
SPONSORS: ${{ steps.get-sponsors.outputs.sponsors }}
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}

- name: NPM publish (CLI and library)
if: ${{ inputs.ezno-version != 'none' }}
Expand Down
Loading

0 comments on commit bba226c

Please sign in to comment.