Skip to content

Commit

Permalink
sharding jest
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Dec 17, 2024
1 parent c458419 commit b6b3a99
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive

- name: Check for file changes
id: check
Expand Down Expand Up @@ -56,8 +55,11 @@ jobs:
name: docker-image
path: superset-node.tar.gz

unit-tests:
sharded-jest-tests:
needs: frontend-docker-build
strategy:
matrix:
shard: [1, 2, 3, 4, 5] # Define shards (1/5, 2/5, ..., 5/5)needs: frontend-docker-build
runs-on: ubuntu-latest
steps:
- name: Download Docker Image Artifact
Expand All @@ -72,18 +74,34 @@ jobs:
- name: npm run test with coverage
run: |
docker run --rm superset-node-${{ github.sha }} bash -c \
"npm run test -- --coverage --silent"
- name: superset-ui/core coverage
run: |
docker run --rm superset-node-${{ github.sha }} bash -c \
"npm run core:cover"
"npm run test -- --coverage --silent --shard=${{ matrix.shard }}/5"
- name: Upload code coverage
if: "0 == 1"
uses: codecov/codecov-action@v5
with:
flags: javascript
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

unit-tests:
needs: frontend-docker-build
runs-on: ubuntu-latest
steps:
- name: Download Docker Image Artifact
uses: actions/download-artifact@v3
with:
name: docker-image

- name: Load Docker Image
run: |
docker load -i superset-node.tar.gz
- name: superset-ui/core coverage
run: |
docker run --rm superset-node-${{ github.sha }} bash -c \
"npm run core:cover"
lint-frontend:
needs: frontend-docker-build
runs-on: ubuntu-latest
Expand All @@ -100,7 +118,7 @@ jobs:
- name: eslint
run: |
docker run --rm superset-node-${{ github.sha }} bash -c \
"npm run eslint -- . --quiet"
"npm i && npm run eslint -- . --quiet"
- name: tsc
run: |
docker run --rm superset-node-${{ github.sha }} bash -c \
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ RUN mkdir -p /app/superset/static/assets \
/app/superset/translations

# Mount package files and install dependencies if not in dev mode
# NOTE: we mount packages and plugins as they are referenced in package.json as workspaces
# ideally we'd COPY only their package.json. Here npm ci will be cached as long
# as the full content of these folders don't change, yielding a decent cache reuse rate.
# Note that's it's not possible selectively COPY of mount using blobs.
RUN --mount=type=bind,source=./superset-frontend/package.json,target=./package.json \
--mount=type=bind,source=./superset-frontend/package-lock.json,target=./package-lock.json \
--mount=type=cache,target=/root/.cache \
Expand Down

0 comments on commit b6b3a99

Please sign in to comment.