From d87fe31a2bcf92ce7a1cfb69832785c92deabc6b Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 16:52:57 -0500 Subject: [PATCH 01/10] ci: try multiple test workers --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 41942c319..1fc9f94c1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lint": "ng lint hypertrace-ui", "lint:fix": "ng lint --fix hypertrace-ui", "prettier:check": "prettier --check '**'", - "test:ci": "ng test hypertrace-ui -i --ci --coverage", + "test:ci": "ng test hypertrace-ui --maxWorkers=2 --ci --coverage", "docs": "compodoc -p tsconfig.json" }, "private": true, From cabe4a7f5c6edfd5255065b7356345c6782422fc Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:19:24 -0500 Subject: [PATCH 02/10] ci: try chunking tests --- .github/workflows/build-and-test.yml | 43 ++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b1f567269..76921cafc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -53,8 +53,45 @@ jobs: - name: Prettier Check run: npm run prettier:check + setup-test-batches: + runs-on: ubuntu-20.04 + env: + PARALLELISM: 2 + outputs: + test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} + test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('package.json') }}- + ${{ runner.os }}-node- + + - name: NPM Install + run: npm ci + + - id: set-test-chunks + name: Set Chunks + run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM '[_nwise(length / $PARALLELISM | floor)]')" + + - id: set-test-chunk-ids + name: Set Chunk IDs + run: echo "::set-output name=test-chunk-ids::$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" + env: + CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} test: + name: test (chunk ${{ matrix.chunk }}) runs-on: ubuntu-20.04 + needs: setup-test-batches + strategy: + matrix: + chunk: ${{ fromJson(needs['setup-test-batches'].outputs['test-chunk-ids']) }} steps: - name: Check out code uses: actions/checkout@v2 @@ -73,10 +110,10 @@ jobs: - name: NPM Install run: npm ci - - name: Test - run: npm run test:ci - + run: npm run test:ci -- $(echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.'' ) + env: + CHUNKS: ${{ needs['setup-test-batches'].outputs['test-chunks'] }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: From bec34416ca075eb6acab64a76dd112b50856e149 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:25:11 -0500 Subject: [PATCH 03/10] ci: try tweak quoting --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 76921cafc..74b8d45e1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -78,7 +78,7 @@ jobs: - id: set-test-chunks name: Set Chunks - run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM '[_nwise(length / $PARALLELISM | floor)]')" + run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM "[_nwise(length / $PARALLELISM | floor)]"")" - id: set-test-chunk-ids name: Set Chunk IDs From f635fcdd16708c62272d65cce587ac10bfa6a347 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:28:03 -0500 Subject: [PATCH 04/10] ci: fix quotes again --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 74b8d45e1..23a18be18 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -78,7 +78,7 @@ jobs: - id: set-test-chunks name: Set Chunks - run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM "[_nwise(length / $PARALLELISM | floor)]"")" + run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM "[_nwise(length / $PARALLELISM | floor)]")" - id: set-test-chunk-ids name: Set Chunk IDs From 9bab8493376ac9caa0d7a9380fb4805e00302eb9 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:36:21 -0500 Subject: [PATCH 05/10] ci: more bad quoting --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 23a18be18..a751e1bb8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -111,7 +111,7 @@ jobs: - name: NPM Install run: npm ci - name: Test - run: npm run test:ci -- $(echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.'' ) + run: npm run test:ci -- $(echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.') env: CHUNKS: ${{ needs['setup-test-batches'].outputs['test-chunks'] }} - name: Upload coverage to Codecov From 360a77a51c9bc63535d1caab6336c01781234a1d Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:45:12 -0500 Subject: [PATCH 06/10] ci: make output raw --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a751e1bb8..80ece6c1a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -111,7 +111,7 @@ jobs: - name: NPM Install run: npm ci - name: Test - run: npm run test:ci -- $(echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.') + run: npm run test:ci -- $(echo $CHUNKS | jq -r '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.') env: CHUNKS: ${{ needs['setup-test-batches'].outputs['test-chunks'] }} - name: Upload coverage to Codecov From 524d85f29e778e372c38278c80a4097b44cb1b88 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 21:54:07 -0500 Subject: [PATCH 07/10] ci: cache compiled modules --- .github/workflows/build-and-test.yml | 62 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 80ece6c1a..cbe4ee4cd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -5,23 +5,34 @@ on: branches: - main jobs: - build: + npm-install-if-needed: runs-on: ubuntu-20.04 steps: - name: Check out code uses: actions/checkout@v2 - - name: Cache node modules + - id: cache + name: Cache node modules uses: actions/cache@v2 with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('package.json') }}- - ${{ runner.os }}-node- + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: NPM Install + if: steps.cache.outputs.cache-hit != 'true' run: npm ci + build: + runs-on: ubuntu-20.04 + needs: [npm-install-if-needed] + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Build run: npm run build:ci @@ -33,20 +44,16 @@ jobs: path: dist lint: runs-on: ubuntu-20.04 + needs: [npm-install-if-needed] steps: - name: Check out code uses: actions/checkout@v2 - - name: Cache node modules + - name: Restore node modules uses: actions/cache@v2 with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('package.json') }}- - ${{ runner.os }}-node- - - name: NPM Install - run: npm ci + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Lint run: npm run lint @@ -55,6 +62,7 @@ jobs: run: npm run prettier:check setup-test-batches: runs-on: ubuntu-20.04 + needs: [npm-install-if-needed] env: PARALLELISM: 2 outputs: @@ -67,14 +75,8 @@ jobs: - name: Cache node modules uses: actions/cache@v2 with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('package.json') }}- - ${{ runner.os }}-node- - - - name: NPM Install - run: npm ci + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - id: set-test-chunks name: Set Chunks @@ -88,7 +90,7 @@ jobs: test: name: test (chunk ${{ matrix.chunk }}) runs-on: ubuntu-20.04 - needs: setup-test-batches + needs: [npm-install-if-needed, setup-test-batches] strategy: matrix: chunk: ${{ fromJson(needs['setup-test-batches'].outputs['test-chunk-ids']) }} @@ -102,18 +104,14 @@ jobs: - name: Cache node modules uses: actions/cache@v2 with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('package.json') }}- - ${{ runner.os }}-node- + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - - name: NPM Install - run: npm ci - name: Test run: npm run test:ci -- $(echo $CHUNKS | jq -r '.[${{ matrix.chunk }}] | .[] | "--testPathPattern "+.') env: CHUNKS: ${{ needs['setup-test-batches'].outputs['test-chunks'] }} + - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: @@ -139,7 +137,7 @@ jobs: merge-publish: if: github.event_name == 'push' runs-on: ubuntu-20.04 - needs: [build, lint, test, validate-helm-charts] + needs: [npm-install-if-needed, build, lint, test, validate-helm-charts] steps: - name: Check out code uses: actions/checkout@v2 From ea08cc7e89d79fe4549d2b7971e31811a2795301 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 22:04:58 -0500 Subject: [PATCH 08/10] ci: merge test results --- .github/workflows/build-and-test.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cbe4ee4cd..a412b44d1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -117,23 +117,42 @@ jobs: with: fail_ci_if_error: true - - name: Publish Unit Test Results - uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6 + - name: Upload Unit Test Results if: always() + uses: actions/upload-artifact@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + name: Unit Test Results (chunk ${{ matrix.chunk }}) files: test-results/**/*.xml validate-helm-charts: runs-on: ubuntu-20.04 steps: - name: Check out code uses: actions/checkout@v2 + - name: Set up Helm uses: azure/setup-helm@v1 with: version: v3.3.0 + - name: validate charts uses: hypertrace/actions/validate-charts@main + publish-test-results: + name: "Publish Unit Tests Results" + needs: test + runs-on: ubuntu-20.04 + # Only run if prereq jobs completed - successfully or not + if: success() || failure() + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + + - name: Publish Unit Test Results + uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: artifacts/**/*.xml merge-publish: if: github.event_name == 'push' runs-on: ubuntu-20.04 From e8a9640ec6ed6f0d136c0e4398c913f4c47983e6 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 22:10:31 -0500 Subject: [PATCH 09/10] ci: typo, bump test parallelism --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a412b44d1..ba95e8730 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-20.04 needs: [npm-install-if-needed] env: - PARALLELISM: 2 + PARALLELISM: 3 outputs: test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} @@ -122,7 +122,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: Unit Test Results (chunk ${{ matrix.chunk }}) - files: test-results/**/*.xml + path: test-results/**/*.xml validate-helm-charts: runs-on: ubuntu-20.04 steps: From 2fb872564cd54894f8379868809aff690c636a75 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 22:19:39 -0500 Subject: [PATCH 10/10] ci: tweak matrix --- .github/workflows/build-and-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ba95e8730..9c7757605 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-20.04 needs: [npm-install-if-needed] env: - PARALLELISM: 3 + PARALLELISM: 4 outputs: test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} @@ -80,7 +80,7 @@ jobs: - id: set-test-chunks name: Set Chunks - run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM "[_nwise(length / $PARALLELISM | floor)]")" + run: echo "::set-output name=test-chunks::$(npx jest --listTests --json | jq -cM "[_nwise(length / $PARALLELISM | ceil)]")" - id: set-test-chunk-ids name: Set Chunk IDs @@ -92,6 +92,7 @@ jobs: runs-on: ubuntu-20.04 needs: [npm-install-if-needed, setup-test-batches] strategy: + fail-fast: false matrix: chunk: ${{ fromJson(needs['setup-test-batches'].outputs['test-chunk-ids']) }} steps: