From ebbb3b106e7844eab30545d49a2661fe5aa0312f Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 25 Sep 2023 14:59:50 +0100 Subject: [PATCH] Update CI and small fixes --- .github/workflows/github-release.yml | 2 +- .github/workflows/npm-release.yml | 90 ------------------- .github/workflows/publish.yml | 52 ++++++++++- .github/workflows/rust.yml | 6 +- parser/examples/parse.rs | 2 +- .../fuzz_targets/module_roundtrip_naive.rs | 1 - .../module_roundtrip_structured.rs | 1 - 7 files changed, 54 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/npm-release.yml diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index adf9e402..4fb8f2b2 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -23,7 +23,7 @@ jobs: - name: Get version id: get-version run: | - version=$(git tag --list 'release/main-*' --sort=-taggerdate | head -n 1) + version=$(git tag --list 'release/main-*' --sort=-taggerdate | tail -n 1) echo "Releasing ${version:13}" echo "new-ezno-version=${version:13}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml deleted file mode 100644 index 44675577..00000000 --- a/.github/workflows/npm-release.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: NPM release - -on: workflow_dispatch - -env: - CACHE_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - -jobs: - build-and-publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ${{ env.CACHE_PATHS }} - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Get version - id: get-version - run: | - version=$(git tag --list 'release/main-*' --sort=-taggerdate | head -n 1) - echo "Releasing ${version:13}" - echo "new-ezno-version=${version:13}" >> $GITHUB_OUTPUT - - - id: set-sponsors - run: | - SPONSORS=$(gh api graphql -f query='{ - user(login: "kaleidawave") { - sponsorshipsAsMaintainer(first: 100, activeOnly: false) { - edges { - node { - sponsor { - login - } - } - } - } - } - }' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")') - - export SPONSORS - shell: bash - env: - GH_TOKEN: ${{ github.token }} - - - name: Add WASM to rustup - run: rustup target add wasm32-unknown-unknown - - - uses: brndnmtthws/rust-action-cargo-binstall@v1 - with: - packages: wasm-bindgen-cli - - - name: Set NPM package version & build - run: | - npm ci - npm version ${{ steps.get-version.outputs.new-ezno-version }} - npm run build-release - working-directory: src/js-cli-and-library - - - name: NPM publish (cli and library) - uses: rxfork/npm-publish@v1 - with: - token: ${{ secrets.NPM_REGISTRY_TOKEN }} - package: src/js-cli-and-library/package.json - - - name: Update plugin version and dependencies - run: | - # Hopefully propagated in 20 seconds - sleep 20 - npm ci - npm install ezno@${{ steps.get-version.outputs.new-ezno-version }} - npm version ${{ steps.get-version.outputs.new-ezno-version }} - working-directory: src/js-based-plugin - - - name: NPM publish (plugin) - uses: rxfork/npm-publish@v1 - with: - token: ${{ secrets.NPM_REGISTRY_TOKEN }} - package: src/js-based-plugin/package.json - - - name: Preview library dist - if: true - run: | - ls dist - working-directory: src/js-cli-and-library \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 110e98ed..ad03685a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: (main) Crates release +name: Release on Crates and NPM on: workflow_dispatch: @@ -31,7 +31,7 @@ env: target/ jobs: - crates-publish: + publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -86,7 +86,52 @@ jobs: version: ${{ steps.set-arguments.outputs.publish-json-args }} crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - name: Push updated manifests + - name: Add WASM to rustup + if: ${{ github.event.inputs.ezno-version != 'none' }} + run: rustup target add wasm32-unknown-unknown + + - uses: brndnmtthws/rust-action-cargo-binstall@v1 + if: ${{ github.event.inputs.ezno-version != 'none' }} + with: + packages: wasm-bindgen-cli + + - name: Set NPM package version & build + id: set-npm-version + if: ${{ github.event.inputs.ezno-version != 'none' }} + run: | + VERSION=$('${{ steps.release.outputs.new-versions-json-object }}' | jq -r '.ezno') + echo "new-ezno-version=${VERSION}" >> $GITHUB_OUTPUT + npm ci + npm version $VERSION + npm run build-release + # TODO temp here: + ls dist + working-directory: src/js-cli-and-library + + - name: NPM publish (cli and library) + if: ${{ github.event.inputs.ezno-version != 'none' }} + uses: rxfork/npm-publish@v1 + with: + token: ${{ secrets.NPM_REGISTRY_TOKEN }} + package: src/js-cli-and-library/package.json + + - name: Update JS plugin version and dependencies + if: ${{ github.event.inputs.ezno-version != 'none' }} + run: | + # Hopefully propagated in 20 seconds + sleep 20 + npm ci + npm install ezno@${{ steps.set-npm-version.outputs.new-ezno-version }} + npm version ${{ steps.set-npm-version.outputs.new-ezno-version }} + working-directory: src/js-based-plugin + + - name: NPM publish (plugin) + uses: rxfork/npm-publish@v1 + with: + token: ${{ secrets.NPM_REGISTRY_TOKEN }} + package: src/js-based-plugin/package.json + + - name: Push updated manifests (Cargo.toml and package.json) run: | # Create tags echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do @@ -98,7 +143,6 @@ jobs: git add . git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}" git push --tags origin main - sleep 20 - name: Discord uses: dusmartijngames/discord-webhook-notify@master diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bc397c20..c6ed2afa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -105,10 +105,12 @@ jobs: if: steps.changes.outputs.parser == 'true' run: | cargo test - + # TODO test other big libraries curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js - cargo run -p ezno-parser --example parse react.js + cargo run -p ezno-parser --example parse react.js > /dev/null + + cargo test -p ezno-ast-generator working-directory: parser - name: Run checker specification diff --git a/parser/examples/parse.rs b/parser/examples/parse.rs index 7d73bd5c..89fa1e90 100644 --- a/parser/examples/parse.rs +++ b/parser/examples/parse.rs @@ -9,7 +9,7 @@ fn main() -> Result<(), Box> { let result = Module::from_file(&path, ParseOptions::default(), &mut fs); match result { Ok(module) => { - println!("Parsed in: {:?}", now.elapsed()); + eprintln!("Parsed in: {:?}", now.elapsed()); if std::env::args().any(|item| item == "--ast") { println!("{module:#?}"); } else { diff --git a/parser/fuzz/fuzz_targets/module_roundtrip_naive.rs b/parser/fuzz/fuzz_targets/module_roundtrip_naive.rs index 97d7db7d..4105399a 100644 --- a/parser/fuzz/fuzz_targets/module_roundtrip_naive.rs +++ b/parser/fuzz/fuzz_targets/module_roundtrip_naive.rs @@ -16,7 +16,6 @@ fn do_fuzz(data: &str) -> Corpus { Default::default(), SourceId::NULL, None, - Vec::new(), ) else { return Corpus::Reject }; diff --git a/parser/fuzz/fuzz_targets/module_roundtrip_structured.rs b/parser/fuzz/fuzz_targets/module_roundtrip_structured.rs index e2a35fb2..78fd0627 100644 --- a/parser/fuzz/fuzz_targets/module_roundtrip_structured.rs +++ b/parser/fuzz/fuzz_targets/module_roundtrip_structured.rs @@ -18,7 +18,6 @@ fn do_fuzz(data: common::FuzzSource) -> Corpus { Default::default(), SourceId::NULL, None, - Vec::new(), ) else { return Corpus::Reject };