From 8a765f3e6b96841c4fed5bb24e652cec45226ce0 Mon Sep 17 00:00:00 2001 From: debora berte Date: Mon, 23 Dec 2024 22:07:51 -0300 Subject: [PATCH 01/32] feat: nix flake for numscript wask with tiny go --- .envrc | 1 + flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..396ec32 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1734649271, + "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a5ecfc9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "A Nix flake for NumScript WASM compilation"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + inherit (pkgs.lib) optional optionals; + pkgs = import nixpkgs { inherit system; }; + + inputs = with pkgs; [ + go + tinygo + git + ] ++ optional stdenv.isLinux inotify-tools + ++ optionals stdenv.isDarwin + (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices ]); + + in with pkgs; { + devShells.default = mkShell { + name = "numscript-wasm"; + packages = inputs; + + shellHook = '' + echo "NumScript WASM development environment" + echo "TinyGo version: $(tinygo version)" + echo "Go version: $(go version)" + ''; + }; + }); +} \ No newline at end of file From 5bebea5b3b49c8cb0815b6af6ad414d30138f3ba Mon Sep 17 00:00:00 2001 From: debora berte Date: Mon, 23 Dec 2024 22:27:08 -0300 Subject: [PATCH 02/32] feat: numscript-wasm github pipeline --- .github/workflows/numscript-wasm.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/numscript-wasm.yml diff --git a/.github/workflows/numscript-wasm.yml b/.github/workflows/numscript-wasm.yml new file mode 100644 index 0000000..34139f7 --- /dev/null +++ b/.github/workflows/numscript-wasm.yml @@ -0,0 +1,34 @@ +name: NumScript WASM Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-numscript-wasm: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' # Fixed version to 1.21 to be compatible with TinyGo + + - name: Run Tests + run: | + go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... + + - name: Upload Coverage Report + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + file: ./coverage.txt + verbose: true \ No newline at end of file From 7d92f452602c39bd761a1015332453c27f354c5b Mon Sep 17 00:00:00 2001 From: debora berte Date: Mon, 23 Dec 2024 22:36:51 -0300 Subject: [PATCH 03/32] feat: add wasm build pipeline and dev env config --- .github/workflows/numscript-wasm.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/numscript-wasm.yml b/.github/workflows/numscript-wasm.yml index 34139f7..11c5b20 100644 --- a/.github/workflows/numscript-wasm.yml +++ b/.github/workflows/numscript-wasm.yml @@ -31,4 +31,27 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: file: ./coverage.txt - verbose: true \ No newline at end of file + verbose: true + + - name: Install TinyGo + if: github.ref == 'refs/heads/main' # Only on main branch + run: | + wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb + sudo dpkg -i tinygo_0.30.0_amd64.deb + + - name: Build WASM + if: github.ref == 'refs/heads/main' # Only on main branch + run: | + mkdir -p build + tinygo build -o build/numscript.wasm -target wasm ./ + + - name: Create Release + if: github.ref == 'refs/heads/main' # Only on main branch + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ github.run_number }} \ + --title "NumScript WASM v${{ github.run_number }}" \ + --notes "Automated WASM build release" \ + build/numscript.wasm \ No newline at end of file From 4484331577f292c4f64b9814c9569e2305948465 Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 27 Dec 2024 08:46:50 -0300 Subject: [PATCH 04/32] feat: update release --- .github/workflows/numscript-wasm.yml | 57 ---------------------------- .github/workflows/release.yml | 22 ++++++++++- 2 files changed, 20 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/numscript-wasm.yml diff --git a/.github/workflows/numscript-wasm.yml b/.github/workflows/numscript-wasm.yml deleted file mode 100644 index 11c5b20..0000000 --- a/.github/workflows/numscript-wasm.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: NumScript WASM Build - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build-numscript-wasm: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: '1.21' # Fixed version to 1.21 to be compatible with TinyGo - - - name: Run Tests - run: | - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - - - name: Upload Coverage Report - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - with: - file: ./coverage.txt - verbose: true - - - name: Install TinyGo - if: github.ref == 'refs/heads/main' # Only on main branch - run: | - wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb - sudo dpkg -i tinygo_0.30.0_amd64.deb - - - name: Build WASM - if: github.ref == 'refs/heads/main' # Only on main branch - run: | - mkdir -p build - tinygo build -o build/numscript.wasm -target wasm ./ - - - name: Create Release - if: github.ref == 'refs/heads/main' # Only on main branch - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create v${{ github.run_number }} \ - --title "NumScript WASM v${{ github.run_number }}" \ - --notes "Automated WASM build release" \ - build/numscript.wasm \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 628092b..a63b41e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: "1.22" + go-version: "1.21" # Changed to 1.21 for TinyGo compatibility - uses: actions/checkout@v2 - uses: actions/cache@v2 with: @@ -20,12 +20,30 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- + + - name: Install TinyGo + run: | + wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb + sudo dpkg -i tinygo_0.30.0_amd64.deb + + - name: Build WASM + run: | + mkdir -p build + tinygo build -o build/numscript.wasm -target wasm ./ + - name: get deps run: go mod download + - name: Run GoReleaser env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: goreleaser/goreleaser-action@v6 with: version: latest - args: release + args: release --rm-dist + + - name: Upload WASM artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.event.release.tag_name }} build/numscript.wasm \ No newline at end of file From ce0d9bc01b6f9f8530de9b0be86394efe0f1205c Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 27 Dec 2024 08:49:08 -0300 Subject: [PATCH 05/32] feat: exact go version for testing with act --- .github/workflows/release.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a63b41e..2115519 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,10 +8,15 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v2 - with: - go-version: "1.21" # Changed to 1.21 for TinyGo compatibility - uses: actions/checkout@v2 + + - name: Set up Go 1.21 + uses: actions/setup-go@v2 + with: + go-version: '1.21.5' # Specify exact version that works with TinyGo + env: + ACTIONS_RUNTIME_TOKEN: '' + - uses: actions/cache@v2 with: path: | From 73ae6a3e4a8ebde87e133cfac7806b1c5f021a66 Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 27 Dec 2024 09:17:19 -0300 Subject: [PATCH 06/32] feat: script for downloading wasm --- scripts/download-wasm.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/download-wasm.sh diff --git a/scripts/download-wasm.sh b/scripts/download-wasm.sh new file mode 100755 index 0000000..4019b50 --- /dev/null +++ b/scripts/download-wasm.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +# Default version (can be overridden by environment variable) +VERSION=${VERSION:-latest} +REPO="formancehq/numscript" + +if [ "$VERSION" = "latest" ]; then + VERSION=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +fi + +echo "Downloading numscript.wasm version $VERSION..." + +# Create directory if it doesn't exist +mkdir -p priv/wasm + +# Download the file +curl -L "https://github.com/$REPO/releases/download/$VERSION/numscript.wasm" -o priv/wasm/numscript.wasm + +echo "Downloaded successfully to priv/wasm/numscript.wasm" \ No newline at end of file From ae223e83ffceb2178eccf9a5479f71037a1343a6 Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 27 Dec 2024 09:18:34 -0300 Subject: [PATCH 07/32] chore: adjust .gitignore --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 2203eb0..98d746f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,14 @@ coverage.* numscript numscript.wasm + + +# WASM builds +build/ +*.wasm + +# Go specific +/vendor/ +/bin/ +*.test +/coverage.txt From f2e669df9fed1e67f9eb8044bca74cd9ddc0e804 Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 27 Dec 2024 14:49:45 -0300 Subject: [PATCH 08/32] feat: nix workflow --- .github/workflows/nix.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..c98791e --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,14 @@ +name: Nix CI + +on: [push, pull_request] + +jobs: + nix-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v23 + - name: Test Nix build + run: | + nix develop --command echo "Nix environment works" + nix flake check \ No newline at end of file From e583886154dae46706f30fb1895611d63591132b Mon Sep 17 00:00:00 2001 From: debora be <72231462+debora-be@users.noreply.github.com> Date: Fri, 3 Jan 2025 09:10:51 -0300 Subject: [PATCH 09/32] chore: apply suggestions from code review Co-authored-by: Fernando Mumbach --- scripts/download-wasm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/download-wasm.sh b/scripts/download-wasm.sh index 4019b50..4071a69 100755 --- a/scripts/download-wasm.sh +++ b/scripts/download-wasm.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -e +set -e -o pipefail # Default version (can be overridden by environment variable) VERSION=${VERSION:-latest} From 5973823a25aec7597ad804cb221f80a7f622b650 Mon Sep 17 00:00:00 2001 From: debora berte Date: Fri, 3 Jan 2025 18:17:27 -0300 Subject: [PATCH 10/32] chore: apply review suggestions --- .github/workflows/nix.yml | 50 +++++++++++++-- .github/workflows/release.yml | 64 ++++++++++--------- go.mod | 8 +-- .../parser/antlr/numscript_base_listener.go | 5 +- internal/parser/antlr/numscript_lexer.go | 4 +- internal/parser/antlr/numscript_listener.go | 5 +- internal/parser/antlr/numscript_parser.go | 13 ++-- internal/parser/parser.go | 2 +- scripts/download-wasm.sh | 4 +- 9 files changed, 97 insertions(+), 58 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index c98791e..19228bc 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,14 +1,50 @@ name: Nix CI -on: [push, pull_request] +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: - nix-build: + build: runs-on: ubuntu-latest + container: + image: nixos/nix:latest + options: --privileged steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v23 - - name: Test Nix build + - name: Prepare environment run: | - nix develop --command echo "Nix environment works" - nix flake check \ No newline at end of file + # Install required packages + nix-env -iA nixpkgs.git nixpkgs.nodejs nixpkgs.go nixpkgs.tinygo + + - name: Checkout code + run: | + git clone https://github.com/$GITHUB_REPOSITORY . + git checkout $GITHUB_SHA + env: + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_SHA: ${{ github.sha }} + + - name: Build + run: | + mkdir -p build + go mod download + go mod tidy + tinygo build -o build/numscript.wasm -target wasm -no-debug ./ + + # Only run on GitHub Actions, not locally + - if: ${{ !env.ACT }} + name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: numscript-wasm + path: build/numscript.wasm + + # Local testing step + - if: ${{ env.ACT }} + name: Copy artifact locally + run: | + mkdir -p /tmp/artifacts + cp build/numscript.wasm /tmp/artifacts/ + echo "Artifact copied to /tmp/artifacts/numscript.wasm" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2115519..49aedb0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,54 +1,60 @@ -name: release +name: Release + on: release: types: [created] + permissions: contents: write + jobs: - build: + release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Set up Go 1.21 - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 with: - go-version: '1.21.5' # Specify exact version that works with TinyGo - env: - ACTIONS_RUNTIME_TOKEN: '' - - - uses: actions/cache@v2 + fetch-depth: 0 + + - uses: actions/cache@v3 with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + path: /tmp/.cache + key: ${{ runner.os }}-build-${{ github.sha }} restore-keys: | - ${{ runner.os }}-go- - + ${{ runner.os }}-build- + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: true + - name: Install TinyGo run: | wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb sudo dpkg -i tinygo_0.30.0_amd64.deb + - name: Get dependencies + run: | + go mod download + go mod verify + - name: Build WASM run: | mkdir -p build - tinygo build -o build/numscript.wasm -target wasm ./ - - - name: get deps - run: go mod download - + tinygo build -o build/numscript.wasm -target wasm -no-debug ./ + # Added -no-debug to reduce binary size + - name: Run GoReleaser - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: goreleaser/goreleaser-action@v6 + uses: goreleaser/goreleaser-action@v5 with: + distribution: goreleaser version: latest - args: release --rm-dist - - - name: Upload WASM artifact + args: release --clean --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload WASM artifact run: | - gh release upload ${{ github.event.release.tag_name }} build/numscript.wasm \ No newline at end of file + gh release upload ${{ github.event.release.tag_name }} build/numscript.wasm --clobber + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/go.mod b/go.mod index 3f447a1..0d8154b 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,11 @@ module github.com/PagoPlus/numscriptex -go 1.22.1 +go 1.22.0 -replace github.com/PagoPlus/numscriptex => github.com/PagoPlus/numscriptex v0.0.0-20241202132127-f10ae2504bbc +toolchain go1.23.3 require ( github.com/Jeffail/gabs/v2 v2.7.0 - github.com/antlr4-go/antlr/v4 v4.13.1 github.com/gkampitakis/go-snaps v0.5.4 ) @@ -22,6 +21,7 @@ require ( ) require ( + github.com/antlr4-go/antlr/v4 v4.13.1 github.com/gkampitakis/ciinfo v0.3.0 // indirect github.com/gkampitakis/go-diff v1.3.2 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -34,5 +34,5 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect - golang.org/x/exp v0.0.0-20240707233637-46b078467d37 + golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 ) diff --git a/internal/parser/antlr/numscript_base_listener.go b/internal/parser/antlr/numscript_base_listener.go index 64794ef..0517829 100644 --- a/internal/parser/antlr/numscript_base_listener.go +++ b/internal/parser/antlr/numscript_base_listener.go @@ -1,7 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package parser // Numscript +// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +package antlr // Numscript import "github.com/antlr4-go/antlr/v4" // BaseNumscriptListener is a complete listener for a parse tree produced by NumscriptParser. diff --git a/internal/parser/antlr/numscript_lexer.go b/internal/parser/antlr/numscript_lexer.go index 2b86925..e0e2264 100644 --- a/internal/parser/antlr/numscript_lexer.go +++ b/internal/parser/antlr/numscript_lexer.go @@ -1,6 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. +// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. -package parser +package antlr import ( "fmt" diff --git a/internal/parser/antlr/numscript_listener.go b/internal/parser/antlr/numscript_listener.go index 9bb6d3d..b0e6d96 100644 --- a/internal/parser/antlr/numscript_listener.go +++ b/internal/parser/antlr/numscript_listener.go @@ -1,7 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package parser // Numscript +// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +package antlr // Numscript import "github.com/antlr4-go/antlr/v4" // NumscriptListener is a complete listener for a parse tree produced by NumscriptParser. diff --git a/internal/parser/antlr/numscript_parser.go b/internal/parser/antlr/numscript_parser.go index 4fefc7b..1bdbaaf 100644 --- a/internal/parser/antlr/numscript_parser.go +++ b/internal/parser/antlr/numscript_parser.go @@ -1,7 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package parser // Numscript +// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +package antlr // Numscript import ( "fmt" "strconv" @@ -2960,7 +2959,7 @@ func (s *SrcInorderContext) ExitRule(listener antlr.ParseTreeListener) { type SrcCappedContext struct { SourceContext - cap_ IValueExprContext + limit IValueExprContext } func NewSrcCappedContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *SrcCappedContext { @@ -2973,9 +2972,9 @@ func NewSrcCappedContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *SrcC return p } -func (s *SrcCappedContext) GetCap_() IValueExprContext { return s.cap_ } +func (s *SrcCappedContext) GetLimit() IValueExprContext { return s.limit } -func (s *SrcCappedContext) SetCap_(v IValueExprContext) { s.cap_ = v } +func (s *SrcCappedContext) SetLimit(v IValueExprContext) { s.limit = v } func (s *SrcCappedContext) GetRuleContext() antlr.RuleContext { return s @@ -3280,7 +3279,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { var _x = p.valueExpr(0) - localctx.(*SrcCappedContext).cap_ = _x + localctx.(*SrcCappedContext).limit = _x } { p.SetState(150) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 4f98b48..3d8ec10 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -189,7 +189,7 @@ func parseSource(sourceCtx parser.ISourceContext) Source { return &SourceCapped{ Range: range_, From: parseSource(sourceCtx.Source()), - Cap: parseValueExpr(sourceCtx.GetCap_()), + Cap: parseValueExpr(sourceCtx.GetLimit()), // Change to GetLimit() } case *parser.SrcAccountUnboundedOverdraftContext: diff --git a/scripts/download-wasm.sh b/scripts/download-wasm.sh index 4019b50..61f47dd 100755 --- a/scripts/download-wasm.sh +++ b/scripts/download-wasm.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash set -e # Default version (can be overridden by environment variable) VERSION=${VERSION:-latest} -REPO="formancehq/numscript" +REPO="PagoPlus/numscript-wasm" if [ "$VERSION" = "latest" ]; then VERSION=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') From 0a02fac3ff5e5358312d5a7f093a666f09f3c181 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Wed, 8 Jan 2025 16:40:43 -0300 Subject: [PATCH 11/32] Merge main --- .goreleaser.yaml | 4 ++++ internal/numscript/numscript.go | 29 ++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c5dc479..c160c8e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -24,6 +24,10 @@ builds: goarch: - amd64 - arm64 + tool: "tinygo" + hooks: + pre: + - mkdir -p {{ dir .Path }} binary: numscript ldflags: - -X main.Version=v{{ .Version }} diff --git a/internal/numscript/numscript.go b/internal/numscript/numscript.go index 7ed4bef..ae0d639 100644 --- a/internal/numscript/numscript.go +++ b/internal/numscript/numscript.go @@ -24,6 +24,25 @@ type RunInputOpts struct { Balances interpreter.Balances `json:"balances"` } +var Version string + +func version() string { + if Version == "" { + return "dev" + } else { + return Version + } +} + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Shows the app version", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + fmt.Print(version()) + }, +} + func SeverityToString(s analysis.Severity) string { switch s { case analysis.ErrorSeverity: @@ -157,9 +176,10 @@ var runCmd = &cobra.Command{ } var rootCmd = &cobra.Command{ - Use: "numscript", - Short: "Numscript cli", - Long: "Numscript cli", + Use: "numscript", + Short: "Numscript cli", + Long: "Numscript cli", + Version: version(), CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: true, }, @@ -173,8 +193,11 @@ func main() { } }() + rootCmd.SetVersionTemplate(rootCmd.Version) + rootCmd.AddCommand(checkCmd) rootCmd.AddCommand(runCmd) + rootCmd.AddCommand(versionCmd) rootCmd.Execute() } From ea1288853391c56d75d9858a2670ba5426043436 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Thu, 9 Jan 2025 15:51:49 -0300 Subject: [PATCH 12/32] Fix module name --- go.mod | 9 +++------ internal/analysis/check.go | 4 ++-- internal/analysis/check_test.go | 4 ++-- internal/analysis/diagnostic_kind.go | 4 ++-- internal/analysis/document_symbols.go | 2 +- internal/analysis/document_symbols_test.go | 4 ++-- internal/analysis/goto_definition.go | 2 +- internal/analysis/goto_definition_test.go | 4 ++-- internal/analysis/hover.go | 4 ++-- internal/analysis/hover_test.go | 4 ++-- internal/cmd/check.go | 2 +- internal/cmd/lsp.go | 2 +- internal/cmd/run.go | 6 +++--- internal/interpreter/args_parser.go | 2 +- internal/interpreter/args_parser_test.go | 2 +- internal/interpreter/batch_balances_query.go | 4 ++-- internal/interpreter/evaluate_expr.go | 4 ++-- internal/interpreter/infix.go | 2 +- internal/interpreter/interpreter.go | 6 +++--- internal/interpreter/interpreter_error.go | 2 +- internal/interpreter/interpreter_errors_test.go | 4 ++-- internal/interpreter/interpreter_test.go | 4 ++-- internal/interpreter/portion_test.go | 2 +- internal/interpreter/value.go | 4 ++-- internal/interpreter/value_test.go | 2 +- internal/lsp/handlers.go | 6 +++--- internal/lsp/server_test.go | 2 +- internal/numscript/numscript.go | 8 ++++---- internal/parser/parser.go | 4 ++-- internal/parser/parser_fault_tolerance_test.go | 2 +- internal/parser/parser_test.go | 2 +- internal/parser/range_test.go | 2 +- 32 files changed, 56 insertions(+), 59 deletions(-) diff --git a/go.mod b/go.mod index 0d8154b..7cc4b33 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,13 @@ -module github.com/PagoPlus/numscriptex +module github.com/PagoPlus/numscript-wasm -go 1.22.0 - -toolchain go1.23.3 +go 1.22.1 require ( github.com/Jeffail/gabs/v2 v2.7.0 + github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967 github.com/gkampitakis/go-snaps v0.5.4 ) -require github.com/gorilla/websocket v1.5.0 // indirect - require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect diff --git a/internal/analysis/check.go b/internal/analysis/check.go index 86f5c09..f26b19a 100644 --- a/internal/analysis/check.go +++ b/internal/analysis/check.go @@ -4,8 +4,8 @@ import ( "math/big" "slices" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) const TypeMonetary = "monetary" diff --git a/internal/analysis/check_test.go b/internal/analysis/check_test.go index 12ab913..f9ff564 100644 --- a/internal/analysis/check_test.go +++ b/internal/analysis/check_test.go @@ -4,8 +4,8 @@ import ( "math/big" "testing" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/analysis/diagnostic_kind.go b/internal/analysis/diagnostic_kind.go index d09c36d..7b875c9 100644 --- a/internal/analysis/diagnostic_kind.go +++ b/internal/analysis/diagnostic_kind.go @@ -4,8 +4,8 @@ import ( "fmt" "math/big" - "github.com/PagoPlus/numscriptex/internal/ansi" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/ansi" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) type Severity = byte diff --git a/internal/analysis/document_symbols.go b/internal/analysis/document_symbols.go index 1cd6fce..b538989 100644 --- a/internal/analysis/document_symbols.go +++ b/internal/analysis/document_symbols.go @@ -1,7 +1,7 @@ package analysis import ( - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" ) type DocumentSymbolKind = float64 diff --git a/internal/analysis/document_symbols_test.go b/internal/analysis/document_symbols_test.go index c65e28f..5e7b0e6 100644 --- a/internal/analysis/document_symbols_test.go +++ b/internal/analysis/document_symbols_test.go @@ -4,8 +4,8 @@ import ( "slices" "testing" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/assert" ) diff --git a/internal/analysis/goto_definition.go b/internal/analysis/goto_definition.go index 3c57751..630dbba 100644 --- a/internal/analysis/goto_definition.go +++ b/internal/analysis/goto_definition.go @@ -1,6 +1,6 @@ package analysis -import "github.com/PagoPlus/numscriptex/internal/parser" +import "github.com/PagoPlus/numscript-wasm/internal/parser" type GotoDefinitionResult struct { Range parser.Range diff --git a/internal/analysis/goto_definition_test.go b/internal/analysis/goto_definition_test.go index 8f13b0a..5954935 100644 --- a/internal/analysis/goto_definition_test.go +++ b/internal/analysis/goto_definition_test.go @@ -3,8 +3,8 @@ package analysis_test import ( "testing" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/analysis/hover.go b/internal/analysis/hover.go index 535b591..e751eb3 100644 --- a/internal/analysis/hover.go +++ b/internal/analysis/hover.go @@ -1,8 +1,8 @@ package analysis import ( - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) type Hover interface{ hover() } diff --git a/internal/analysis/hover_test.go b/internal/analysis/hover_test.go index bd75783..8d48fbe 100644 --- a/internal/analysis/hover_test.go +++ b/internal/analysis/hover_test.go @@ -3,8 +3,8 @@ package analysis_test import ( "testing" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/require" ) diff --git a/internal/cmd/check.go b/internal/cmd/check.go index dff9d3f..c90d432 100644 --- a/internal/cmd/check.go +++ b/internal/cmd/check.go @@ -5,7 +5,7 @@ import ( "os" "sort" - "github.com/PagoPlus/numscriptex/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/analysis" "github.com/spf13/cobra" ) diff --git a/internal/cmd/lsp.go b/internal/cmd/lsp.go index 426858a..3aa72a5 100644 --- a/internal/cmd/lsp.go +++ b/internal/cmd/lsp.go @@ -1,7 +1,7 @@ package cmd import ( - "github.com/PagoPlus/numscriptex/internal/lsp" + "github.com/PagoPlus/numscript-wasm/internal/lsp" "github.com/spf13/cobra" ) diff --git a/internal/cmd/run.go b/internal/cmd/run.go index 173e511..f37c24f 100644 --- a/internal/cmd/run.go +++ b/internal/cmd/run.go @@ -7,9 +7,9 @@ import ( "io" "os" - "github.com/PagoPlus/numscriptex/internal/ansi" - "github.com/PagoPlus/numscriptex/internal/interpreter" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/ansi" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/spf13/cobra" ) diff --git a/internal/interpreter/args_parser.go b/internal/interpreter/args_parser.go index c6865e7..7ba0cd8 100644 --- a/internal/interpreter/args_parser.go +++ b/internal/interpreter/args_parser.go @@ -1,6 +1,6 @@ package interpreter -import "github.com/PagoPlus/numscriptex/internal/parser" +import "github.com/PagoPlus/numscript-wasm/internal/parser" type argsParser struct { parsedArgsCount int diff --git a/internal/interpreter/args_parser_test.go b/internal/interpreter/args_parser_test.go index 0d9a585..17d0d64 100644 --- a/internal/interpreter/args_parser_test.go +++ b/internal/interpreter/args_parser_test.go @@ -4,7 +4,7 @@ import ( "math/big" "testing" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/require" ) diff --git a/internal/interpreter/batch_balances_query.go b/internal/interpreter/batch_balances_query.go index fb68f1d..8a730a0 100644 --- a/internal/interpreter/batch_balances_query.go +++ b/internal/interpreter/batch_balances_query.go @@ -3,8 +3,8 @@ package interpreter import ( "slices" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" "golang.org/x/exp/maps" ) diff --git a/internal/interpreter/evaluate_expr.go b/internal/interpreter/evaluate_expr.go index 6efa962..fac988d 100644 --- a/internal/interpreter/evaluate_expr.go +++ b/internal/interpreter/evaluate_expr.go @@ -3,8 +3,8 @@ package interpreter import ( "math/big" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) func (st *programState) evaluateExpr(expr parser.ValueExpr) (Value, InterpreterError) { diff --git a/internal/interpreter/infix.go b/internal/interpreter/infix.go index e8dcf32..b601625 100644 --- a/internal/interpreter/infix.go +++ b/internal/interpreter/infix.go @@ -3,7 +3,7 @@ package interpreter import ( "math/big" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" ) type opAdd interface { diff --git a/internal/interpreter/interpreter.go b/internal/interpreter/interpreter.go index 8767949..bb11a89 100644 --- a/internal/interpreter/interpreter.go +++ b/internal/interpreter/interpreter.go @@ -6,9 +6,9 @@ import ( "regexp" "strings" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) type VariablesMap map[string]string diff --git a/internal/interpreter/interpreter_error.go b/internal/interpreter/interpreter_error.go index 6e63ee9..8be2b07 100644 --- a/internal/interpreter/interpreter_error.go +++ b/internal/interpreter/interpreter_error.go @@ -4,7 +4,7 @@ import ( "fmt" "math/big" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" ) type MissingFundsErr struct { diff --git a/internal/interpreter/interpreter_errors_test.go b/internal/interpreter/interpreter_errors_test.go index ff3130a..db271ce 100644 --- a/internal/interpreter/interpreter_errors_test.go +++ b/internal/interpreter/interpreter_errors_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/PagoPlus/numscriptex/internal/interpreter" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/gkampitakis/go-snaps/snaps" "github.com/stretchr/testify/require" ) diff --git a/internal/interpreter/interpreter_test.go b/internal/interpreter/interpreter_test.go index 76d3f1c..80dca1d 100644 --- a/internal/interpreter/interpreter_test.go +++ b/internal/interpreter/interpreter_test.go @@ -5,11 +5,11 @@ import ( "encoding/json" "math/big" - machine "github.com/PagoPlus/numscriptex/internal/interpreter" + machine "github.com/PagoPlus/numscript-wasm/internal/interpreter" "testing" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/interpreter/portion_test.go b/internal/interpreter/portion_test.go index 302a8f9..37879b6 100644 --- a/internal/interpreter/portion_test.go +++ b/internal/interpreter/portion_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/PagoPlus/numscriptex/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" ) func TestBetween0And1Inclusive(t *testing.T) { diff --git a/internal/interpreter/value.go b/internal/interpreter/value.go index 47a9d47..a481ff0 100644 --- a/internal/interpreter/value.go +++ b/internal/interpreter/value.go @@ -4,8 +4,8 @@ import ( "fmt" "math/big" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" ) type Value interface { diff --git a/internal/interpreter/value_test.go b/internal/interpreter/value_test.go index d02076f..2d47921 100644 --- a/internal/interpreter/value_test.go +++ b/internal/interpreter/value_test.go @@ -5,7 +5,7 @@ import ( "math/big" "testing" - "github.com/PagoPlus/numscriptex/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" "github.com/stretchr/testify/require" ) diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go index 23c2419..457ceb4 100644 --- a/internal/lsp/handlers.go +++ b/internal/lsp/handlers.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" "github.com/sourcegraph/jsonrpc2" ) diff --git a/internal/lsp/server_test.go b/internal/lsp/server_test.go index 86dd82d..1516d35 100644 --- a/internal/lsp/server_test.go +++ b/internal/lsp/server_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - lsp "github.com/PagoPlus/numscriptex/internal/lsp" + lsp "github.com/PagoPlus/numscript-wasm/internal/lsp" ) func encodePayload(payload string) *strings.Reader { diff --git a/internal/numscript/numscript.go b/internal/numscript/numscript.go index ae0d639..2accfc1 100644 --- a/internal/numscript/numscript.go +++ b/internal/numscript/numscript.go @@ -11,10 +11,10 @@ import ( "github.com/Jeffail/gabs/v2" "github.com/spf13/cobra" - "github.com/PagoPlus/numscriptex/internal/analysis" - "github.com/PagoPlus/numscriptex/internal/interpreter" - "github.com/PagoPlus/numscriptex/internal/parser" - "github.com/PagoPlus/numscriptex/internal/utils" + "github.com/PagoPlus/numscript-wasm/internal/analysis" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/utils" ) type RunInputOpts struct { diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 3d8ec10..373872c 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - parser "github.com/PagoPlus/numscriptex/internal/parser/antlr" - "github.com/PagoPlus/numscriptex/internal/utils" + parser "github.com/PagoPlus/numscript-wasm/internal/parser/antlr" + "github.com/PagoPlus/numscript-wasm/internal/utils" "github.com/antlr4-go/antlr/v4" ) diff --git a/internal/parser/parser_fault_tolerance_test.go b/internal/parser/parser_fault_tolerance_test.go index 9a6694d..c90a719 100644 --- a/internal/parser/parser_fault_tolerance_test.go +++ b/internal/parser/parser_fault_tolerance_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/gkampitakis/go-snaps/snaps" "github.com/stretchr/testify/assert" diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index e1a872f..9c268d3 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/gkampitakis/go-snaps/snaps" "github.com/stretchr/testify/assert" diff --git a/internal/parser/range_test.go b/internal/parser/range_test.go index 64af1e0..6b311f4 100644 --- a/internal/parser/range_test.go +++ b/internal/parser/range_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/parser" "github.com/gkampitakis/go-snaps/snaps" "github.com/stretchr/testify/assert" ) From 66a9a6c8d9db7a9fd113d917775886697624defc Mon Sep 17 00:00:00 2001 From: Vinicius Date: Thu, 9 Jan 2025 16:40:27 -0300 Subject: [PATCH 13/32] Fix release CI --- .github/workflows/release.yml | 22 +++++----------------- .goreleaser.yaml | 7 ++----- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49aedb0..568eefb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,36 +25,24 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' + go-version: "1.22" cache: true - name: Install TinyGo run: | - wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb - sudo dpkg -i tinygo_0.30.0_amd64.deb + wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb + sudo dpkg -i tinygo_0.34.0_amd64.deb - name: Get dependencies run: | go mod download go mod verify - - name: Build WASM - run: | - mkdir -p build - tinygo build -o build/numscript.wasm -target wasm -no-debug ./ - # Added -no-debug to reduce binary size - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest - args: release --clean --rm-dist + args: release --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload WASM artifact - run: | - gh release upload ${{ github.event.release.tag_name }} build/numscript.wasm --clobber - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c160c8e..f446eb9 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -18,12 +18,9 @@ builds: - CGO_ENABLED=0 main: ./internal/numscript/numscript.go goos: - - linux - - windows - - darwin + - wasip1 goarch: - - amd64 - - arm64 + - wasm tool: "tinygo" hooks: pre: From dbf01cdfe032a1481d3e074ed3bad25974de6b35 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Thu, 9 Jan 2025 16:51:42 -0300 Subject: [PATCH 14/32] Fix build --- go.sum | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go.sum b/go.sum index 14c0c23..fe14261 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg= github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw= +github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967 h1:iuQUuW29c6uoGAqp+E00theAYKHr6HcCYIdk5vBEIkM= +github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967/go.mod h1:Y+ymNQhXxoeBhueWQOpePyYrPUff0CgNpgbv5LVmI0w= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -50,6 +52,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w= golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From d5910d5c4a79fa7e040b42065814c7e561280fe4 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Thu, 9 Jan 2025 16:58:44 -0300 Subject: [PATCH 15/32] Fix module name on 'numscript.go' --- numscript.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numscript.go b/numscript.go index b85b9c1..e34ad34 100644 --- a/numscript.go +++ b/numscript.go @@ -3,8 +3,8 @@ package numscript import ( "context" - "github.com/PagoPlus/numscriptex/internal/interpreter" - "github.com/PagoPlus/numscriptex/internal/parser" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" + "github.com/PagoPlus/numscript-wasm/internal/parser" ) // This struct represents a parsed numscript source code From 60c0bbd270521a717ab02f7614617779e1e94ef1 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Fri, 10 Jan 2025 13:31:31 -0300 Subject: [PATCH 16/32] Run go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index fe14261..e82d2ba 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,6 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w= -golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 3ba3ecc5109c8dde5817bb4af34b78fdfb2c3fae Mon Sep 17 00:00:00 2001 From: Vinicius Date: Fri, 10 Jan 2025 13:31:47 -0300 Subject: [PATCH 17/32] Fix module name on 'numscript_test.go' --- numscript_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numscript_test.go b/numscript_test.go index 6db0871..5772364 100644 --- a/numscript_test.go +++ b/numscript_test.go @@ -6,8 +6,8 @@ import ( "math/big" "testing" - numscript "github.com/PagoPlus/numscriptex" - "github.com/PagoPlus/numscriptex/internal/interpreter" + numscript "github.com/PagoPlus/numscript-wasm" + "github.com/PagoPlus/numscript-wasm/internal/interpreter" "github.com/stretchr/testify/require" ) From c4da050b4fd1d7c7e784493f252be06a9114a56a Mon Sep 17 00:00:00 2001 From: debora berte Date: Sun, 12 Jan 2025 21:56:07 -0300 Subject: [PATCH 18/32] chore: improve nix ci --- .github/workflows/nix.yml | 44 +++++++++++++++------------------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 19228bc..f401318 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -13,38 +13,28 @@ jobs: image: nixos/nix:latest options: --privileged steps: - - name: Prepare environment - run: | - # Install required packages - nix-env -iA nixpkgs.git nixpkgs.nodejs nixpkgs.go nixpkgs.tinygo - - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install dependencies run: | - git clone https://github.com/$GITHUB_REPOSITORY . - git checkout $GITHUB_SHA - env: - GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_SHA: ${{ github.sha }} - + nix-shell --run "go mod download" + nix-shell --run "go mod tidy" + - name: Build run: | mkdir -p build - go mod download - go mod tidy - tinygo build -o build/numscript.wasm -target wasm -no-debug ./ + nix-shell --run "tinygo build -o build/numscript.wasm -target wasm -no-debug ./" - # Only run on GitHub Actions, not locally - - if: ${{ !env.ACT }} - name: Upload artifact - uses: actions/upload-artifact@v4 + - name: Test + run: | + nix-shell --run "go test ./..." + + - name: Upload artifact + uses: actions/upload-artifact@v3 with: name: numscript-wasm - path: build/numscript.wasm - - # Local testing step - - if: ${{ env.ACT }} - name: Copy artifact locally - run: | - mkdir -p /tmp/artifacts - cp build/numscript.wasm /tmp/artifacts/ - echo "Artifact copied to /tmp/artifacts/numscript.wasm" \ No newline at end of file + path: build/numscript.wasm \ No newline at end of file From 217c168d8e206284f2fd4c8fda84718eaba2ac0c Mon Sep 17 00:00:00 2001 From: debora berte Date: Sun, 12 Jan 2025 21:59:24 -0300 Subject: [PATCH 19/32] chore: fix nodejs version --- flake.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flake.nix b/flake.nix index a5ecfc9..f08f249 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,11 @@ go tinygo git + act + antlr4 + just + nodejs_20 + tree ] ++ optional stdenv.isLinux inotify-tools ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices ]); From b3c33d90dceb19ef19609890ce45fcc52be9f7ef Mon Sep 17 00:00:00 2001 From: debora berte Date: Sun, 12 Jan 2025 22:17:12 -0300 Subject: [PATCH 20/32] chore: fix build --- .github/workflows/nix.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index f401318..71b4218 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -9,10 +9,12 @@ on: jobs: build: runs-on: ubuntu-latest - container: - image: nixos/nix:latest - options: --privileged steps: + - name: Install Nix + run: | + curl -L https://nixos.org/nix/install | sh + . /home/runner/.nix-profile/etc/profile.d/nix.sh + - name: Checkout code uses: actions/checkout@v3 with: From dbf61041ff44e14af0c046c0acf6f6e3c885049f Mon Sep 17 00:00:00 2001 From: debora berte Date: Sun, 12 Jan 2025 22:20:51 -0300 Subject: [PATCH 21/32] feat: configure with matrix --- .github/workflows/nix.yml | 48 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 71b4218..b9e5ca1 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -7,36 +7,34 @@ on: branches: [ main ] jobs: - build: + configure: runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - name: Install Nix - run: | - curl -L https://nixos.org/nix/install | sh - . /home/runner/.nix-profile/etc/profile.d/nix.sh + - uses: actions/checkout@v4 + - id: set-matrix + run: echo "matrix=$(nixci gh-matrix --systems=x86_64-linux,aarch64-darwin | jq -c .)" >> $GITHUB_OUTPUT - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Install dependencies - run: | - nix-shell --run "go mod download" - nix-shell --run "go mod tidy" - - - name: Build - run: | - mkdir -p build - nix-shell --run "tinygo build -o build/numscript.wasm -target wasm -no-debug ./" - - - name: Test - run: | - nix-shell --run "go test ./..." + nix: + runs-on: ${{ matrix.system }} + permissions: + contents: read + needs: configure + strategy: + matrix: ${{ fromJson(needs.configure.outputs.matrix) }} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - run: | + nixci \ + --extra-access-tokens "github.com=${{ secrets.GITHUB_TOKEN }}" \ + build \ + --systems "${{ matrix.system }}" \ + .#default.${{ matrix.subflake}} - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: numscript-wasm + name: numscript-wasm-${{ matrix.system }} path: build/numscript.wasm \ No newline at end of file From 6aea37ead545822016362bc441660e2ce1a4e407 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Mon, 13 Jan 2025 09:33:19 -0300 Subject: [PATCH 22/32] Remove snapshot flag on release workflow --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 568eefb..d34562f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,6 @@ jobs: with: distribution: goreleaser version: latest - args: release --snapshot + args: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 52be60c4fb8a5141be1470b3ae59ef8e964afb6d Mon Sep 17 00:00:00 2001 From: Vinicius Date: Tue, 14 Jan 2025 15:36:17 -0300 Subject: [PATCH 23/32] Put version on binary name --- .goreleaser.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f446eb9..1c3c67d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -25,7 +25,7 @@ builds: hooks: pre: - mkdir -p {{ dir .Path }} - binary: numscript + binary: numscript-v{{ .Version }} ldflags: - -X main.Version=v{{ .Version }} @@ -33,13 +33,7 @@ archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of `uname`. name_template: >- - {{ .ProjectName }}_ - {{ .Version }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} + {{ .ProjectName }}-v{{ .Version }} # use zip for windows archives format_overrides: - goos: windows From 20d12fbe1f8af86cec1d54b7028000845578782a Mon Sep 17 00:00:00 2001 From: Vinicius Date: Tue, 14 Jan 2025 17:16:00 -0300 Subject: [PATCH 24/32] Revert last commit --- .goreleaser.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1c3c67d..188df3f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -25,15 +25,14 @@ builds: hooks: pre: - mkdir -p {{ dir .Path }} - binary: numscript-v{{ .Version }} + binary: numscript ldflags: - -X main.Version=v{{ .Version }} archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of `uname`. - name_template: >- - {{ .ProjectName }}-v{{ .Version }} + name_template: '{{ .ProjectName }}_{{ .Version }}_{{- title .Os }}_{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}' # use zip for windows archives format_overrides: - goos: windows From c72056d90fab84644be3eae1b1f98dd6d537a422 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Sun, 19 Jan 2025 13:58:59 -0300 Subject: [PATCH 25/32] Remove unused script --- scripts/download-wasm.sh | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 scripts/download-wasm.sh diff --git a/scripts/download-wasm.sh b/scripts/download-wasm.sh deleted file mode 100755 index 61f47dd..0000000 --- a/scripts/download-wasm.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -e - -# Default version (can be overridden by environment variable) -VERSION=${VERSION:-latest} -REPO="PagoPlus/numscript-wasm" - -if [ "$VERSION" = "latest" ]; then - VERSION=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') -fi - -echo "Downloading numscript.wasm version $VERSION..." - -# Create directory if it doesn't exist -mkdir -p priv/wasm - -# Download the file -curl -L "https://github.com/$REPO/releases/download/$VERSION/numscript.wasm" -o priv/wasm/numscript.wasm - -echo "Downloaded successfully to priv/wasm/numscript.wasm" \ No newline at end of file From 2ffba764f5878eabb8c0ed780aa4b0cc6124933f Mon Sep 17 00:00:00 2001 From: Vinicius Date: Sun, 19 Jan 2025 14:00:12 -0300 Subject: [PATCH 26/32] Rename release tar.gz file --- .goreleaser.yaml | 4 ++-- go.mod | 3 ++- go.sum | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 188df3f..82d5f83 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -23,7 +23,7 @@ builds: - wasm tool: "tinygo" hooks: - pre: + pre: - mkdir -p {{ dir .Path }} binary: numscript ldflags: @@ -32,7 +32,7 @@ builds: archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of `uname`. - name_template: '{{ .ProjectName }}_{{ .Version }}_{{- title .Os }}_{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}' + name_template: "{{ .ProjectName }}_{{ .Version }}" # use zip for windows archives format_overrides: - goos: windows diff --git a/go.mod b/go.mod index 7cc4b33..f11f38a 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,11 @@ go 1.22.1 require ( github.com/Jeffail/gabs/v2 v2.7.0 - github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967 github.com/gkampitakis/go-snaps v0.5.4 ) +require github.com/gorilla/websocket v1.5.0 // indirect + require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect diff --git a/go.sum b/go.sum index e82d2ba..7be67fd 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg= github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw= -github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967 h1:iuQUuW29c6uoGAqp+E00theAYKHr6HcCYIdk5vBEIkM= -github.com/PagoPlus/numscriptex v0.0.0-20241202135701-b8e89d0f3967/go.mod h1:Y+ymNQhXxoeBhueWQOpePyYrPUff0CgNpgbv5LVmI0w= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= From 5d7928d2d96870df5d3277d143d0093d52c9c99c Mon Sep 17 00:00:00 2001 From: Vinicius Date: Mon, 20 Jan 2025 11:16:16 -0300 Subject: [PATCH 27/32] Archive just the binary on release --- .goreleaser.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 82d5f83..657a6ed 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -25,18 +25,16 @@ builds: hooks: pre: - mkdir -p {{ dir .Path }} - binary: numscript + binary: ../numscript ldflags: - -X main.Version=v{{ .Version }} +checksum: + name_template: "numscript_checksums.txt" + archives: - - format: tar.gz - # this name template makes the OS and Arch compatible with the results of `uname`. - name_template: "{{ .ProjectName }}_{{ .Version }}" - # use zip for windows archives - format_overrides: - - goos: windows - format: zip + - format: binary + name_template: "numscript" changelog: sort: asc From bbe73a5cc3932ea20440afdf130e71c18cf9c2cc Mon Sep 17 00:00:00 2001 From: Vinicius Date: Mon, 20 Jan 2025 17:08:36 -0300 Subject: [PATCH 28/32] Strip unused features off of the binary --- .goreleaser.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 657a6ed..cd70a57 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -28,6 +28,9 @@ builds: binary: ../numscript ldflags: - -X main.Version=v{{ .Version }} + flags: + - -scheduler=none + - -no-debug checksum: name_template: "numscript_checksums.txt" From d4443c97d8b6a7b8e6b2b328e3dfea15a1033a9f Mon Sep 17 00:00:00 2001 From: Vinicius Date: Tue, 21 Jan 2025 10:10:39 -0300 Subject: [PATCH 29/32] Download TinyGo deb file on tmp dir --- .github/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d34562f..3cad94b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,30 +14,30 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - + - uses: actions/cache@v3 with: path: /tmp/.cache key: ${{ runner.os }}-build-${{ github.sha }} restore-keys: | ${{ runner.os }}-build- - + - name: Set up Go uses: actions/setup-go@v4 with: go-version: "1.22" cache: true - + - name: Install TinyGo run: | - wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb - sudo dpkg -i tinygo_0.34.0_amd64.deb + wget -P tmp/ https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb + sudo dpkg -i tmp/tinygo_0.34.0_amd64.deb - name: Get dependencies run: | go mod download go mod verify - + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: From 564f0e4c42e3ef700ec114852ff6d33c6969e90e Mon Sep 17 00:00:00 2001 From: Vinicius Date: Tue, 21 Jan 2025 12:40:28 -0300 Subject: [PATCH 30/32] Revert changes from commit '5973823' --- go.mod | 4 ++-- go.sum | 4 ++-- internal/parser/antlr/numscript_base_listener.go | 4 ++-- internal/parser/antlr/numscript_lexer.go | 4 ++-- internal/parser/antlr/numscript_listener.go | 4 ++-- internal/parser/antlr/numscript_parser.go | 12 ++++++------ internal/parser/parser.go | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index f11f38a..121f710 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.22.1 require ( github.com/Jeffail/gabs/v2 v2.7.0 + github.com/antlr4-go/antlr/v4 v4.13.1 github.com/gkampitakis/go-snaps v0.5.4 ) @@ -19,7 +20,6 @@ require ( ) require ( - github.com/antlr4-go/antlr/v4 v4.13.1 github.com/gkampitakis/ciinfo v0.3.0 // indirect github.com/gkampitakis/go-diff v1.3.2 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -32,5 +32,5 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect - golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 + golang.org/x/exp v0.0.0-20240707233637-46b078467d37 ) diff --git a/go.sum b/go.sum index 7be67fd..14c0c23 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= +golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w= +golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/parser/antlr/numscript_base_listener.go b/internal/parser/antlr/numscript_base_listener.go index 0517829..746f85e 100644 --- a/internal/parser/antlr/numscript_base_listener.go +++ b/internal/parser/antlr/numscript_base_listener.go @@ -1,6 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package antlr // Numscript +package parser // Numscript import "github.com/antlr4-go/antlr/v4" // BaseNumscriptListener is a complete listener for a parse tree produced by NumscriptParser. diff --git a/internal/parser/antlr/numscript_lexer.go b/internal/parser/antlr/numscript_lexer.go index e0e2264..2b86925 100644 --- a/internal/parser/antlr/numscript_lexer.go +++ b/internal/parser/antlr/numscript_lexer.go @@ -1,6 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package antlr +package parser import ( "fmt" diff --git a/internal/parser/antlr/numscript_listener.go b/internal/parser/antlr/numscript_listener.go index b0e6d96..e90c9e7 100644 --- a/internal/parser/antlr/numscript_listener.go +++ b/internal/parser/antlr/numscript_listener.go @@ -1,6 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package antlr // Numscript +package parser // Numscript import "github.com/antlr4-go/antlr/v4" // NumscriptListener is a complete listener for a parse tree produced by NumscriptParser. diff --git a/internal/parser/antlr/numscript_parser.go b/internal/parser/antlr/numscript_parser.go index 1bdbaaf..66d52fc 100644 --- a/internal/parser/antlr/numscript_parser.go +++ b/internal/parser/antlr/numscript_parser.go @@ -1,6 +1,6 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.0. DO NOT EDIT. +// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package antlr // Numscript +package parser // Numscript import ( "fmt" "strconv" @@ -2959,7 +2959,7 @@ func (s *SrcInorderContext) ExitRule(listener antlr.ParseTreeListener) { type SrcCappedContext struct { SourceContext - limit IValueExprContext + cap_ IValueExprContext } func NewSrcCappedContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *SrcCappedContext { @@ -2972,9 +2972,9 @@ func NewSrcCappedContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *SrcC return p } -func (s *SrcCappedContext) GetLimit() IValueExprContext { return s.limit } +func (s *SrcCappedContext) GetCap_() IValueExprContext { return s.cap_ } -func (s *SrcCappedContext) SetLimit(v IValueExprContext) { s.limit = v } +func (s *SrcCappedContext) SetCap_(v IValueExprContext) { s.cap_ = v } func (s *SrcCappedContext) GetRuleContext() antlr.RuleContext { return s @@ -3279,7 +3279,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { var _x = p.valueExpr(0) - localctx.(*SrcCappedContext).limit = _x + localctx.(*SrcCappedContext).cap_ = _x } { p.SetState(150) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 373872c..48fc3ba 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -189,7 +189,7 @@ func parseSource(sourceCtx parser.ISourceContext) Source { return &SourceCapped{ Range: range_, From: parseSource(sourceCtx.Source()), - Cap: parseValueExpr(sourceCtx.GetLimit()), // Change to GetLimit() + Cap: parseValueExpr(sourceCtx.GetCap_()), } case *parser.SrcAccountUnboundedOverdraftContext: From 6c5efa44104ec940341ef5365edb2c597425f73c Mon Sep 17 00:00:00 2001 From: debora be <72231462+debora-be@users.noreply.github.com> Date: Thu, 23 Jan 2025 12:54:39 -0300 Subject: [PATCH 31/32] update flake.nix --- flake.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index f08f249..750575b 100644 --- a/flake.nix +++ b/flake.nix @@ -16,11 +16,7 @@ go tinygo git - act - antlr4 just - nodejs_20 - tree ] ++ optional stdenv.isLinux inotify-tools ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices ]); @@ -37,4 +33,4 @@ ''; }; }); -} \ No newline at end of file +} From 9abb84ff3b72f7d27699303574f0358c115492f9 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Thu, 23 Jan 2025 13:41:29 -0300 Subject: [PATCH 32/32] Now TinyGo builds with target flag instead of GOOS and GOARCH vars --- .goreleaser.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index cd70a57..6a29dc2 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -31,6 +31,7 @@ builds: flags: - -scheduler=none - -no-debug + - -target=wasi checksum: name_template: "numscript_checksums.txt"