From a1926c32ca1f57f795c25b3c9c0708f520cba4ca Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Wed, 25 Sep 2024 11:00:15 +0200 Subject: [PATCH] Add github workflows --- .github/workflows/test.yml | 56 ++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ea9f9bf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: Tests +# only one can run at a time +concurrency: + # If PR, cancel prev commits. head_ref = source branch name on pull_request, null if push + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: buildjet-4vcpu-ubuntu-2204 + strategy: + fail-fast: false + matrix: + node: [22.4] + steps: + - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{matrix.node}} + check-latest: true + cache: npm + - name: Install & build + shell: bash + run: npm install && npm run build + - name: Check Build + shell: bash + run: npm run check:build + + unit-tests: + name: Unit Tests + needs: ["build"] + runs-on: buildjet-4vcpu-ubuntu-2204 + strategy: + fail-fast: false + matrix: + node: [22.4] + steps: + - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{matrix.node}} + check-latest: true + cache: npm + - name: Install & build + shell: bash + run: npm install && npm run build + - name: Unit tests + run: npm run test:unit diff --git a/package.json b/package.json index 2ce191d..649da10 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "build": "npm run build:native && npm run build:ts", "build:native": "./scripts/patch_xdelta3.sh && node-zigar build", "build:ts": "tsc -p tsconfig.build.json", - "test:unit": "npx vitest run --dir test/unit" + "test:unit": "npx vitest run --dir test/unit", + "check:build": "node -e \"(async function() { await import('./lib/index.js') })()\"" }, "main": "lib/index.js", "types": "lib/index.d.ts",