From b7157aa2ee9f0627051a1c00585db1d44c2e906a Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 17:27:36 +0200 Subject: [PATCH 1/5] chore: add missing deps, remove redundant deps Also update gh actions to cache build --- .github/workflows/main.yml | 88 ----------- .github/workflows/test.yml | 168 +++++++++++++++++++++ package.json | 2 +- packages/ipfs-repo-migrations/package.json | 5 +- packages/ipfs-repo/package.json | 8 +- 5 files changed, 173 insertions(+), 98 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 48c5525e..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: ci -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16 - - run: npm install - - run: npm run build - - run: npm run lint - - run: npm run depcheck - 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-repo - - ipfs-repo-migrations - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - 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-repo -# - ipfs-repo-migrations - browser: - - chromium - - firefox - type: - - browser - - webworker - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16 - - 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-repo -# - ipfs-repo-migrations -# type: -# - electron-main -# - electron-renderer -# fail-fast: true -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-node@v1 -# with: -# node-version: 16 -# - 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/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..cf54a04a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,168 @@ +name: Test +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - uses: actions/cache@v2 + env: + CACHE_NAME: cache-node-modules + with: + path: | + ~/.npm + ./node_modules + ./packages/*/node_modules + ./packages/*/dist + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + - run: | + npm install + npm run build + + check: + name: Check + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 16 + - uses: actions/cache@v2 + env: + CACHE_NAME: cache-node-modules + with: + path: | + ~/.npm + ./node_modules + ./packages/*/node_modules + ./packages/*/dist + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + npm install + npm run build + - run: | + npm run lint + npm run dep-check -- -- -- -p + npm run dep-check -- -- -- -- --unused + + test-node: + needs: build + runs-on: ${{ matrix.os }} + name: Unit test ${{ matrix.project }} node ${{ matrix.node }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + project: + - ipfs-repo + - ipfs-repo-migrations + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - uses: actions/cache@v2 + env: + CACHE_NAME: cache-node-modules + with: + path: | + ~/.npm + ./node_modules + ./packages/*/node_modules + ./packages/*/dist + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + npm install + npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node + + test-browser: + needs: build + runs-on: ubuntu-latest + name: Unit test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} + strategy: + matrix: + project: + - ipfs-repo +# - ipfs-repo-migrations + browser: + - chromium + - firefox + type: + - browser + - webworker + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 16 + - uses: actions/cache@v2 + env: + CACHE_NAME: cache-node-modules + with: + path: | + ~/.npm + ./node_modules + ./packages/*/node_modules + ./packages/*/dist + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + npm install + npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} + +# test-electron: +# needs: build +# runs-on: ubuntu-latest +# name: test ${{ matrix.project }} ${{ matrix.type }} +# strategy: +# matrix: +# project: +# - ipfs-repo +# - ipfs-repo-migrations +# type: +# - electron-main +# - electron-renderer +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v1 +# with: +# node-version: 16 +# - uses: actions/cache@v2 +# env: +# CACHE_NAME: cache-node-modules +# with: +# path: | +# ~/.npm +# ./node_modules +# ./packages/*/node_modules +# ./packages/*/dist +# key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} +# - name: Install Dependencies +# if: steps.cache.outputs.cache-hit != 'true' +# run: | +# npm install +# npm run build +# - 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/package.json b/package.json index ddf3d6bf..97c39781 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build": "lerna run build", "clean": "lerna run clean", "lint": "lerna run lint", - "depcheck": "lerna run depcheck", + "dep-check": "lerna run dep-check", "release": "npm run update-contributors && lerna run build && lerna publish", "release:rc": "lerna run build && lerna publish --canary --preid rc --dist-tag next", "update-contributors": "aegir release --lint=false --test=false --bump=false --build=false --changelog=false --commit=false --tag=false --push=false --ghrelease=false --docs=false --publish=false" diff --git a/packages/ipfs-repo-migrations/package.json b/packages/ipfs-repo-migrations/package.json index ee9162e2..cd38ebfa 100644 --- a/packages/ipfs-repo-migrations/package.json +++ b/packages/ipfs-repo-migrations/package.json @@ -48,7 +48,7 @@ "release": "aegir release", "release-minor": "aegir release --type minor", "release-major": "aegir release --type major", - "depcheck": "aegir dep-check" + "dep-check": "aegir dep-check -i interface-blockstore -i assert -i events -i npm-run-all -i util" }, "dependencies": { "@ipld/dag-pb": "^2.0.0", @@ -60,7 +60,6 @@ "interface-datastore": "^6.0.2", "it-length": "^1.0.1", "multiformats": "^9.0.0", - "proper-lockfile": "^4.1.1", "protobufjs": "^6.10.2", "uint8arrays": "^3.0.0", "varint": "^6.0.0" @@ -79,11 +78,9 @@ "datastore-level": "^7.0.1", "datastore-s3": "^8.0.0", "events": "^3.2.0", - "it-all": "^1.0.2", "just-safe-set": "^2.1.0", "level-5": "npm:level@^5.0.0", "level-6": "npm:level@^6.0.0", - "ncp": "^2.0.0", "npm-run-all": "^4.1.5", "rimraf": "^3.0.0", "sinon": "^11.1.1", diff --git a/packages/ipfs-repo/package.json b/packages/ipfs-repo/package.json index c64a1858..9298874c 100644 --- a/packages/ipfs-repo/package.json +++ b/packages/ipfs-repo/package.json @@ -71,7 +71,7 @@ "release-major": "aegir release --type major --target node", "pretest": "aegir build --esm-tests", "test": "aegir test", - "dep-check": "aegir dep-check -i rimraf" + "dep-check": "aegir dep-check -i rimraf -i interface-blockstore -i assert -i events -i npm-run-all -i util" }, "repository": { "type": "git", @@ -97,12 +97,9 @@ "events": "^3.3.0", "ipfs-utils": "^8.1.3", "it-all": "^1.0.2", - "it-drain": "^1.0.1", - "it-first": "^1.0.2", "just-range": "^2.1.0", "rimraf": "^3.0.0", "sinon": "^11.1.1", - "url": "^0.11.0", "util": "^0.12.3" }, "dependencies": { @@ -112,11 +109,12 @@ "datastore-core": "^6.0.7", "debug": "^4.1.0", "err-code": "^3.0.1", - "eslint-plugin-ava": "^12.0.0", "interface-blockstore": "^2.0.2", "interface-datastore": "^6.0.2", "ipfs-repo-migrations": "^11.0.0", + "it-drain": "^1.0.1", "it-filter": "^1.0.2", + "it-first": "^1.0.2", "it-map": "^1.0.5", "it-merge": "^1.0.2", "it-parallel-batch": "^1.0.9", From 95f6855ddaa937511b7077696af16bc2c27946ff Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 17:34:03 +0200 Subject: [PATCH 2/5] chore: update gh actions --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf54a04a..8dd25741 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,7 @@ jobs: with: node-version: 16 - uses: actions/cache@v2 + id: cache env: CACHE_NAME: cache-node-modules with: @@ -62,7 +63,7 @@ jobs: test-node: needs: build runs-on: ${{ matrix.os }} - name: Unit test ${{ matrix.project }} node ${{ matrix.node }} + name: Unit test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] @@ -76,6 +77,7 @@ jobs: with: node-version: ${{ matrix.node }} - uses: actions/cache@v2 + id: cache env: CACHE_NAME: cache-node-modules with: @@ -113,6 +115,7 @@ jobs: with: node-version: 16 - uses: actions/cache@v2 + id: cache env: CACHE_NAME: cache-node-modules with: @@ -147,6 +150,7 @@ jobs: # with: # node-version: 16 # - uses: actions/cache@v2 +# id: cache # env: # CACHE_NAME: cache-node-modules # with: From 977781fd26af264a1e1844c2e2dc885ef42272c3 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 19:09:02 +0200 Subject: [PATCH 3/5] chore: cache invalidation is hard --- .github/workflows/test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8dd25741..4c256c2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: ./node_modules ./packages/*/node_modules ./packages/*/dist - key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }} - run: | npm install npm run build @@ -49,7 +49,7 @@ jobs: ./node_modules ./packages/*/node_modules ./packages/*/dist - key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: | @@ -86,13 +86,13 @@ jobs: ./node_modules ./packages/*/node_modules ./packages/*/dist - key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: | npm install npm run build - - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node + - run: npm run test -- --since ${{ github.event.pull_request.base.sha }} --scope=${{ matrix.project }} -- -- --cov -t node test-browser: needs: build @@ -124,13 +124,13 @@ jobs: ./node_modules ./packages/*/node_modules ./packages/*/dist - key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: | npm install npm run build - - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} + - run: npm run test -- --since ${{ github.event.pull_request.base.sha }} --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} # test-electron: # needs: build @@ -159,7 +159,7 @@ jobs: # ./node_modules # ./packages/*/node_modules # ./packages/*/dist -# key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.run_id }}-${{ github.run_number }} +# key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }} # - name: Install Dependencies # if: steps.cache.outputs.cache-hit != 'true' # run: | @@ -169,4 +169,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 -- --since ${{ github.event.pull_request.base.sha }} --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail From c5091e21610195bd474ef1a52e197cc9e1b6fa50 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 19:14:20 +0200 Subject: [PATCH 4/5] chore: link after building --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c256c2b..9e6e7bbb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,7 @@ jobs: - run: | npm install npm run build + npx lerna link check: name: Check From 8f21c515d1b792fd30040196e21e8eef8642f6fc Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 19:18:29 +0200 Subject: [PATCH 5/5] chore: fix gh actions --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e6e7bbb..8ec77c44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -74,6 +74,8 @@ jobs: - ipfs-repo-migrations steps: - uses: actions/checkout@v2 + with: + fetch-depth: ${{ github.event.pull_request.commits }} - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} @@ -112,6 +114,8 @@ jobs: - webworker steps: - uses: actions/checkout@v2 + with: + fetch-depth: ${{ github.event.pull_request.commits }} - uses: actions/setup-node@v1 with: node-version: 16 @@ -147,6 +151,8 @@ jobs: # - electron-renderer # steps: # - uses: actions/checkout@v2 +# with: +# fetch-depth: ${{ github.event.pull_request.commits }} # - uses: actions/setup-node@v1 # with: # node-version: 16