From 03d08a7dc63cb3c787a47ce1a592461a6352f529 Mon Sep 17 00:00:00 2001 From: Mikkel Malmberg Date: Tue, 11 Nov 2025 14:48:52 +0100 Subject: [PATCH 1/3] Add linter and update CI --- .github/workflows/test-node.yaml | 40 ---------------------- .github/workflows/test.yml | 57 ++++++++++++++++++++++++++++++++ package.json | 8 +++-- 3 files changed, 62 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/test-node.yaml create mode 100644 .github/workflows/test.yml 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/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..06c9a625 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,57 @@ +name: Test + +on: + push: + branches: [main] + tags: + - '*' + pull_request: + branches: [main] + +jobs: + lint: + if: ${{ !startsWith(github.ref, 'refs/tags/')}} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: { node-version: lts/* } + - run: npm install + - run: npm run lint + + test-node: + if: ${{ !startsWith(github.ref, 'refs/tags/')}} + runs-on: ubuntu-latest + name: Node + steps: + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: { node-version: lts/* } + - run: npm i + - run: npm run test:node + + test-bare: + if: ${{ !startsWith(github.ref, 'refs/tags/')}} + runs-on: ubuntu-latest + name: Bare + steps: + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: { node-version: lts/* } + - run: npm i + - run: npm i -g bare-runtime + - run: npm run test:bare + + 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/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" From 8b6f0a3d9986ef9cfc1f5f9fa0fc461bde8735ed Mon Sep 17 00:00:00 2001 From: Mikkel Malmberg Date: Fri, 28 Nov 2025 08:51:05 +0100 Subject: [PATCH 2/3] Update ci --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++ .github/workflows/test.yml | 57 -------------------------------------- 2 files changed, 45 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c0cad3d1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +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@current + - 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/node-base@current + - run: npm install -g bare-runtime + - 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.yml b/.github/workflows/test.yml deleted file mode 100644 index 06c9a625..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Test - -on: - push: - branches: [main] - tags: - - '*' - pull_request: - branches: [main] - -jobs: - lint: - if: ${{ !startsWith(github.ref, 'refs/tags/')}} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: { node-version: lts/* } - - run: npm install - - run: npm run lint - - test-node: - if: ${{ !startsWith(github.ref, 'refs/tags/')}} - runs-on: ubuntu-latest - name: Node - steps: - - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: { node-version: lts/* } - - run: npm i - - run: npm run test:node - - test-bare: - if: ${{ !startsWith(github.ref, 'refs/tags/')}} - runs-on: ubuntu-latest - name: Bare - steps: - - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: { node-version: lts/* } - - run: npm i - - run: npm i -g bare-runtime - - run: npm run test:bare - - 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 }}"}' From 8d0a20b86256ed410ed1ed6e4581f94a4b44afce Mon Sep 17 00:00:00 2001 From: Mikkel Malmberg Date: Fri, 28 Nov 2025 11:01:36 +0100 Subject: [PATCH 3/3] Update ci --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0cad3d1..dc025a56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest name: Lint steps: - - uses: holepunchto/actions/node-base@current + - uses: holepunchto/actions/node-base@v1 - run: npm run lint test: if: ${{ !startsWith(github.ref, 'refs/tags/')}} @@ -28,8 +28,7 @@ jobs: runs-on: ${{ matrix.os }} name: Test / ${{ matrix.platform }} steps: - - uses: holepunchto/actions/node-base@current - - run: npm install -g bare-runtime + - uses: holepunchto/actions/bare-base@v1 - run: npm test trigger_canary: if: startsWith(github.ref, 'refs/tags/')