diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dc025a56 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Integrate +on: + push: + branches: [main] + tags: + - '*' + pull_request: + branches: [main] +jobs: + lint: + if: ${{ !startsWith(github.ref, 'refs/tags/')}} + runs-on: ubuntu-latest + name: Lint + steps: + - uses: holepunchto/actions/node-base@v1 + - run: npm run lint + test: + if: ${{ !startsWith(github.ref, 'refs/tags/')}} + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux + - os: macos-latest + platform: darwin + - os: windows-latest + platform: win32 + runs-on: ${{ matrix.os }} + name: Test / ${{ matrix.platform }} + steps: + - uses: holepunchto/actions/bare-base@v1 + - run: npm test + trigger_canary: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: trigger canary + run: | + curl -L -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/holepunchto/canary-tests/dispatches \ + -d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}' diff --git a/.github/workflows/test-node.yaml b/.github/workflows/test-node.yaml deleted file mode 100644 index 1b422a7e..00000000 --- a/.github/workflows/test-node.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build Status -on: - push: - branches: - - main - tags: # To trigger the canary - - '*' - pull_request: - branches: - - main -jobs: - build: - if: ${{ !startsWith(github.ref, 'refs/tags/')}} # Already runs for the push of the commit, no need to run again for the tag - strategy: - matrix: - node-version: [lts/*] - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm test - - run: npm -g install bare - - run: npm run test:bare - trigger_canary: - if: startsWith(github.ref, 'refs/tags/') # Only run when a new package is published (detects when a new tag is pushed) - runs-on: ubuntu-latest - steps: - - name: trigger canary - run: | - curl -L -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/holepunchto/canary-tests/dispatches \ - -d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}' diff --git a/package.json b/package.json index 83f3d802..a6a0b332 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,10 @@ }, "scripts": { "format": "prettier --write .", - "lint": "prettier --check .", - "test": "npm run lint && brittle test.js", - "test:bare": "bare test.js" + "lint": "prettier --check . && lunte", + "test": "npm run test:node && npm run test:bare", + "test:bare": "brittle-bare --coverage test.js", + "test:node": "brittle-node --coverage test.js" }, "author": "Holepunch", "license": "Apache-2.0", @@ -47,6 +48,7 @@ "hypercore-crypto": "^3.4.0", "hyperdht": "^6.6.0", "hyperswarm": "^4.0.0", + "lunte": "^1.3.0", "prettier": "^3.6.2", "prettier-config-holepunch": "^2.0.0", "test-tmp": "^1.3.0"