From e0357d11d831745fb12b1e82e218464faf077b7c Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 19:40:09 +0200 Subject: [PATCH 1/6] chore: switch to gh actions --- .github/workflows/deploy.yml | 37 +++++++++++++ .github/workflows/main.yml | 97 +++++++++++++++++++++++++++++++++ .travis.yml | 102 ----------------------------------- 3 files changed, 134 insertions(+), 102 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..dcf0e0c2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: deploy +on: + push: + branches: + - master + +jobs: + publish-rc: + runs-on: ubuntu-latest + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: 'packages/*/package-lock.json' + - name: configure Git User + run: | + git config --global user.email "actions@github.com" + git config --global user.name "@$GITHUB_ACTOR" + - name: Authenticate with Registry + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc + npm whoami + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: release + run: npm run release:rc -- --yes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..fd66f041 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,97 @@ +name: ci +on: + pull_request: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: 'packages/*/package-lock.json' + - run: npm install + - run: npm run build + - run: npm run lint + - run: npm run depcheck -- -- -- -p + - run: npm run depcheck -- -- -- -- --unused + test-node: + needs: check + runs-on: ${{ matrix.os }} + name: test ${{ matrix.project }} node ${{ matrix.node }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + cache: 'npm' + cache-dependency-path: 'packages/*/package-lock.json' + - run: npm install + - run: npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node + test-browser: + needs: check + runs-on: ubuntu-latest + name: test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} + strategy: + matrix: + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + browser: + - chromium + - firefox + type: + - browser + - webworker + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: 'packages/*/package-lock.json' + - run: npm install + - run: npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} + test-electron: + needs: check + runs-on: ubuntu-latest + name: test ${{ matrix.project }} ${{ matrix.type }} + strategy: + matrix: + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + type: + - electron-main + - electron-renderer + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: 'packages/*/package-lock.json' + - run: npm install + - run: npm run build + - uses: GabrielBB/xvfb-action@v1 + with: + run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5ac5ceaf..00000000 --- a/.travis.yml +++ /dev/null @@ -1,102 +0,0 @@ -language: node_js -cache: npm -dist: focal - -branches: - only: - - master - - /^release\/.*$/ - -services: - - xvfb - -stages: - - check - - test - - cov - - release - -node_js: - - 'lts/*' - - 'node' - -os: - - linux - - osx - - windows - -before_install: - # prevents windows error: npm ERR! ... git-sh-setup: file not found - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export PATH=/c/PROGRA~1/Git/usr/bin:/c/PROGRA~1/Git/mingw64/libexec/git-core:$PATH ; fi - # upgrading npm on travis/windows/node 14 is completely broken - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export NODE_INSTALL_DIR=`npm prefix -g` ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then mv $NODE_INSTALL_DIR/node_modules $NODE_INSTALL_DIR/node_modules_old ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then mkdir $NODE_INSTALL_DIR/node_modules ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then rm -f $NODE_INSTALL_DIR/npm $NODE_INSTALL_DIR/npm.cmd $NODE_INSTALL_DIR/npm.ps1 $NODE_INSTALL_DIR/npx $NODE_INSTALL_DIR/npx.cmd $NODE_INSTALL_DIR/npx.ps1 ; fi - # workspaces require npm 7 or above - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then node $NODE_INSTALL_DIR/node_modules_old/npm/bin/npm-cli.js i -g npm@latest ; fi - - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then npm install -g npm@latest ; fi - # allow windows to run scripts with node 14 and npm 7 (may not be necessary when node 14 is no longer lts) - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then npm config set script-shell c:/PROGRA~1/Git/bin/bash.exe ; fi - -before_script: npm run build -script: npx nyc -s npm run test -- -- -- -t node --bail -after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov - -jobs: - include: - - stage: check - name: linting - script: - - npm run lint - - - stage: check - name: dep-check (production deps) - script: - - npm run depcheck -- $RUN_SINCE -- -- -p - - - stage: check - name: dep-check (unused deps) - script: - - npm run depcheck -- $RUN_SINCE -- -- -- --unused - - - stage: test - name: chrome - addons: - chrome: stable - script: npm run test -- -- -- -t browser - - - stage: test - name: chrome webworker - addons: - chrome: stable - script: npm run test -- -- -- -t webworker - - - stage: test - name: firefox - addons: - firefox: latest - script: npm run test -- -- -- -t browser --browsers FirefoxHeadless - - - stage: test - name: firefox webworker - addons: - firefox: latest - script: npm run test -- -- -- -t webworker --browsers FirefoxHeadless - - - stage: test - name: electron main - script: - - npx lerna link # use publishConfig.directory - - npm run test -- -- -- -t electron-main -f dist/cjs/node-test/*js - - - stage: release - # only run on changes to master - if: branch = master AND type = push AND fork = false - name: release rc - script: - - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - - npm run release:rc -- --yes - -notifications: - email: false From d53b62c56f57e07804ffd38b174be2848b7a34b5 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 19:42:22 +0200 Subject: [PATCH 2/6] chore: remove caching --- .github/workflows/deploy.yml | 2 -- .github/workflows/main.yml | 8 -------- 2 files changed, 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dcf0e0c2..6c080b17 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,8 +18,6 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16 - cache: 'npm' - cache-dependency-path: 'packages/*/package-lock.json' - name: configure Git User run: | git config --global user.email "actions@github.com" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd66f041..bf641d3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - cache: 'npm' - cache-dependency-path: 'packages/*/package-lock.json' - run: npm install - run: npm run build - run: npm run lint @@ -37,8 +35,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - cache: 'npm' - cache-dependency-path: 'packages/*/package-lock.json' - run: npm install - run: npm run build - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node @@ -64,8 +60,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - cache: 'npm' - cache-dependency-path: 'packages/*/package-lock.json' - run: npm install - run: npm run build - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} @@ -88,8 +82,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - cache: 'npm' - cache-dependency-path: 'packages/*/package-lock.json' - run: npm install - run: npm run build - uses: GabrielBB/xvfb-action@v1 From 5a65d2594f871a49bb2736cf79ec55da4291d4a3 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 19:47:26 +0200 Subject: [PATCH 3/6] chore: print os name in job --- .github/workflows/{main.yml => test.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{main.yml => test.yml} (96%) diff --git a/.github/workflows/main.yml b/.github/workflows/test.yml similarity index 96% rename from .github/workflows/main.yml rename to .github/workflows/test.yml index bf641d3e..ebe05d6a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: test-node: needs: check runs-on: ${{ matrix.os }} - name: test ${{ matrix.project }} node ${{ matrix.node }} + name: test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] From 68ac37a6a7346bc555bb7200097e3a6eae3e9e25 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 19:50:31 +0200 Subject: [PATCH 4/6] chore: run transpiled tests in electron --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebe05d6a..20bc4221 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,4 +86,4 @@ jobs: - run: npm run build - uses: GabrielBB/xvfb-action@v1 with: - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail + run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail -f ./dist/cjs/node-test/*.spec.js From bbeebe8a2673b31a61f83886af094a77d016371b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 20:26:33 +0200 Subject: [PATCH 5/6] chore: link before testing on electron --- .github/workflows/{deploy.yml => release.yml} | 0 .github/workflows/test.yml | 1 + 2 files changed, 1 insertion(+) rename .github/workflows/{deploy.yml => release.yml} (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/release.yml similarity index 100% rename from .github/workflows/deploy.yml rename to .github/workflows/release.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 20bc4221..65d3ba5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,6 +84,7 @@ jobs: node-version: 16 - run: npm install - run: npm run build + - run: npx lerna link # use publishConfig.directory - uses: GabrielBB/xvfb-action@v1 with: run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail -f ./dist/cjs/node-test/*.spec.js From 712b042a88c8a656cbbebe40f8159de8d1228317 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 20:47:15 +0200 Subject: [PATCH 6/6] chore: skip rabin tests in electron renderer as they are broken --- packages/ipfs-unixfs-importer/package.json | 3 ++- packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/ipfs-unixfs-importer/package.json b/packages/ipfs-unixfs-importer/package.json index 80a7c65b..2a5fbe9c 100644 --- a/packages/ipfs-unixfs-importer/package.json +++ b/packages/ipfs-unixfs-importer/package.json @@ -49,7 +49,8 @@ "nyc": "^15.0.0", "readable-stream": "^3.6.0", "rimraf": "^3.0.2", - "util": "^0.12.3" + "util": "^0.12.3", + "wherearewe": "^1.0.0" }, "dependencies": { "@ipld/dag-pb": "^2.0.2", diff --git a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js index 9b7f09f9..990f7336 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js @@ -7,12 +7,21 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import asAsyncIterable from './helpers/as-async-iterable.js' import defaultOptions from '../src/options.js' +import { isElectronRenderer } from 'wherearewe' const rawFile = new Uint8Array(Math.pow(2, 20)).fill(1) describe('chunker: rabin', function () { this.timeout(30000) + if (isElectronRenderer) { + it('Does not work on the electron renderer thread - https://github.com/hugomrdias/rabin-wasm/issues/127', function () { + this.skip() + }) + + return + } + it('chunks non flat buffers', async () => { const b1 = new Uint8Array(2 * 256) const b2 = new Uint8Array(1 * 256)