179 lines
4.8 KiB
YAML
179 lines
4.8 KiB
YAML
name: "Frontend Build CI (unit tests, linting & sanity checks)"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "master"
|
|
- "[0-9].[0-9]*"
|
|
pull_request:
|
|
types: [synchronize, opened, reopened, ready_for_review]
|
|
|
|
# cancel previous workflow jobs for PRs
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
TAG: apache/superset:GHA-${{ github.run_id }}
|
|
|
|
jobs:
|
|
frontend-build:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Check for File Changes
|
|
id: check
|
|
uses: ./.github/actions/change-detector/
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build Docker Image
|
|
if: steps.check.outputs.frontend
|
|
shell: bash
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
docker buildx build \
|
|
-t $TAG \
|
|
--cache-from=type=registry,ref=apache/superset-cache:3.10-slim-bookworm \
|
|
--target superset-node-ci \
|
|
.
|
|
|
|
- name: Save Docker Image as Artifact
|
|
if: steps.check.outputs.frontend
|
|
run: |
|
|
docker save $TAG | gzip > docker-image.tar.gz
|
|
|
|
- name: Upload Docker Image Artifact
|
|
if: steps.check.outputs.frontend
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
path: docker-image.tar.gz
|
|
|
|
sharded-jest-tests:
|
|
needs: frontend-build
|
|
if: needs.frontend-build.result == 'success'
|
|
strategy:
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
fail-fast: false
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download Docker Image Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
|
|
- name: Load Docker Image
|
|
run: docker load < docker-image.tar.gz
|
|
|
|
- name: npm run test with coverage
|
|
run: |
|
|
mkdir -p ${{ github.workspace }}/superset-frontend/coverage
|
|
docker run \
|
|
-v ${{ github.workspace }}/superset-frontend/coverage:/app/superset-frontend/coverage \
|
|
--rm $TAG \
|
|
bash -c \
|
|
"npm run test -- --coverage --shard=${{ matrix.shard }}/8 --coverageReporters=json-summary"
|
|
|
|
- name: Upload Coverage Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-artifacts-${{ matrix.shard }}
|
|
path: superset-frontend/coverage
|
|
|
|
report-coverage:
|
|
needs: [sharded-jest-tests]
|
|
if: needs.frontend-build.result == 'success'
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download Coverage Artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: coverage-artifacts-*
|
|
path: coverage/
|
|
|
|
- name: Show Files
|
|
run: find coverage/
|
|
|
|
- name: Merge Code Coverage
|
|
run: npx nyc merge coverage/ merged-output/coverage-summary.json
|
|
|
|
- name: Upload Code Coverage
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
flags: javascript
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
verbose: true
|
|
files: merged-output/coverage-summary.json
|
|
slug: apache/superset
|
|
|
|
core-cover:
|
|
needs: frontend-build
|
|
if: needs.frontend-build.result == 'success'
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download Docker Image Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
|
|
- name: Load Docker Image
|
|
run: docker load < docker-image.tar.gz
|
|
|
|
- name: superset-ui/core coverage
|
|
run: |
|
|
docker run --rm $TAG bash -c \
|
|
"npm run core:cover"
|
|
|
|
lint-frontend:
|
|
needs: frontend-build
|
|
if: needs.frontend-build.result == 'success'
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download Docker Image Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
|
|
- name: Load Docker Image
|
|
run: docker load < docker-image.tar.gz
|
|
|
|
- name: eslint
|
|
run: |
|
|
docker run --rm $TAG bash -c \
|
|
"npm i && npm run eslint -- . --quiet"
|
|
|
|
- name: tsc
|
|
run: |
|
|
docker run --rm $TAG bash -c \
|
|
"npm run type"
|
|
|
|
validate-frontend:
|
|
needs: frontend-build
|
|
if: needs.frontend-build.result == 'success'
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Download Docker Image Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
|
|
- name: Load Docker Image
|
|
run: docker load < docker-image.tar.gz
|
|
|
|
- name: Build Plugins Packages
|
|
run: |
|
|
docker run --rm $TAG bash -c \
|
|
"npm run plugins:build"
|
|
|
|
- name: Build Plugins Storybook
|
|
run: |
|
|
docker run --rm $TAG bash -c \
|
|
"npm run plugins:build-storybook"
|