glsdk napi: Fix onchainSend and receive tests
#64
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| paths: | |
| - '.github/workflows/typescript.yml' | |
| - 'libs/gl-sdk-napi/**' | |
| branches: | |
| - main | |
| pull_request: {} | |
| workflow_dispatch: | |
| inputs: | |
| shouldPublish: | |
| description: 'Publish to NPM' | |
| type: boolean | |
| default: true | |
| name: Typescript Library | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version-changed: ${{ steps.check.outputs.changed }} | |
| defaults: | |
| run: | |
| working-directory: libs/gl-sdk-napi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - id: check | |
| run: | | |
| CURRENT_VERSION=$(cat package.json | jq -r '.version') | |
| git checkout HEAD^ | |
| PREVIOUS_VERSION=$(cat package.json | jq -r '.version') | |
| git checkout - | |
| if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then | |
| echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "::warning::Will not trigger publishing because version is unchanged" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| build: | |
| needs: check-version | |
| if: needs.check-version.outputs.version-changed == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| strip: strip -x *.node | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| strip: aarch64-linux-gnu-strip -x *.node | |
| - host: macos-15-intel | |
| target: x86_64-apple-darwin | |
| strip: strip -x *.node | |
| - host: macos-14 | |
| target: aarch64-apple-darwin | |
| strip: strip -x *.node | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| strip: "" | |
| name: Build - ${{ matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| defaults: | |
| run: | |
| working-directory: libs/gl-sdk-napi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: libs/gl-sdk-napi/package-lock.json | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.settings.target }} | |
| - name: Install protobuf compiler (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Install protobuf compiler (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install protobuf | |
| - name: Install protobuf compiler (Windows) | |
| if: runner.os == 'Windows' | |
| run: choco install protoc | |
| - name: Setup cross-compilation (Linux ARM64) | |
| if: matrix.settings.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry/cache | |
| key: ${{ matrix.settings.target }}-cargo-registry | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry/index | |
| key: ${{ matrix.settings.target }}-cargo-index | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build -- --target ${{ matrix.settings.target }} | |
| shell: bash | |
| - name: Strip binary | |
| if: matrix.settings.strip != '' | |
| run: ${{ matrix.settings.strip }} | |
| shell: bash | |
| - name: List build output | |
| run: ls -la *.node index.js index.d.ts | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: | | |
| libs/gl-sdk-napi/*.node | |
| libs/gl-sdk-napi/index.js | |
| libs/gl-sdk-napi/index.d.ts | |
| if-no-files-found: error | |
| test: | |
| name: Test - ${{ matrix.settings.target }} | |
| needs: build | |
| continue-on-error: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - host: macos-14 | |
| target: aarch64-apple-darwin | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| runs-on: ${{ matrix.settings.host }} | |
| defaults: | |
| run: | |
| working-directory: libs/gl-sdk-napi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: libs/gl-sdk-napi/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: libs/gl-sdk-napi | |
| - name: List downloaded files | |
| run: ls -la *.node index.js index.d.ts | |
| shell: bash | |
| - name: Run tests | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 3 | |
| retry_wait_seconds: 10 | |
| shell: bash | |
| command: cd libs/gl-sdk-napi && npm test -- tests/basic.spec.ts | |
| publish: | |
| name: Publish to NPM | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.shouldPublish == true) | |
| defaults: | |
| run: | |
| working-directory: libs/gl-sdk-napi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Move artifacts to package directory | |
| run: | | |
| for dir in ../../artifacts/bindings-*; do | |
| if [ -d "$dir" ]; then | |
| echo "Processing $dir" | |
| cp "$dir"/* . 2>/dev/null || true | |
| fi | |
| done | |
| ls -la *.* | |
| - name: List package contents | |
| run: npm pack --dry-run | |
| - name: Publish to NPM | |
| run: | | |
| echo "Token length: ${#NODE_AUTH_TOKEN}" | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |