From 901adb8e35e1c2bc1733fd7d391d6db5befcbbee Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 10 Dec 2024 14:49:56 -0800 Subject: [PATCH] feat(gha): check that docker-compose up superset-init runs --- .github/workflows/superset-docs-verify.yml | 2 +- .github/workflows/superset-frontend.yml | 122 +++++++++++++++------ Dockerfile | 9 +- 3 files changed, 95 insertions(+), 38 deletions(-) diff --git a/.github/workflows/superset-docs-verify.yml b/.github/workflows/superset-docs-verify.yml index 7fcc7309a50bb..f3d04a33c06fc 100644 --- a/.github/workflows/superset-docs-verify.yml +++ b/.github/workflows/superset-docs-verify.yml @@ -24,7 +24,7 @@ jobs: - uses: JustinBeckwith/linkinator-action@v1.11.0 continue-on-error: true # This will make the job advisory (non-blocking, no red X) with: - paths: "**/*.md, **/*.mdx" + paths: "**/*.md, **/*.mdx, !superset-frontend/CHANGELOG.md" linksToSkip: >- ^https://github.com/apache/(superset|incubator-superset)/(pull|issue)/\d+, http://localhost:8088/, diff --git a/.github/workflows/superset-frontend.yml b/.github/workflows/superset-frontend.yml index 9451692f5f7a5..6c4bad6c1dc15 100644 --- a/.github/workflows/superset-frontend.yml +++ b/.github/workflows/superset-frontend.yml @@ -22,59 +22,111 @@ jobs: with: persist-credentials: false submodules: recursive - - name: Check npm lock file version - run: ./scripts/ci_check_npm_lock_version.sh ./superset-frontend/package-lock.json + - name: Check for file changes id: check uses: ./.github/actions/change-detector/ with: token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Node.js + + - name: Setup Docker Environment if: steps.check.outputs.frontend - uses: actions/setup-node@v4 + uses: ./.github/actions/setup-docker with: - node-version: "20" - - name: Install dependencies + dockerhub-user: ${{ secrets.DOCKERHUB_USER }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Setup supersetbot if: steps.check.outputs.frontend - uses: ./.github/actions/cached-dependencies - with: - run: npm-install - - name: eslint + uses: ./.github/actions/setup-supersetbot/ + + - name: Build Docker Image if: steps.check.outputs.frontend - working-directory: ./superset-frontend + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - npm run eslint -- . --quiet - - name: tsc - if: steps.check.outputs.frontend - working-directory: ./superset-frontend + TAG="superset-node-${{ github.sha }}" + docker buildx build --target superset-node-ci -t $TAG . + docker save $TAG | gzip > superset-node.tar.gz + + - name: Upload Docker Image Artifact + uses: actions/upload-artifact@v3 + with: + name: docker-image + path: superset-node.tar.gz + + 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: | - npm run type - - name: Build plugins packages - if: steps.check.outputs.frontend - working-directory: ./superset-frontend - run: npm run plugins:build - - name: Build plugins Storybook - if: steps.check.outputs.frontend - working-directory: ./superset-frontend - run: npm run plugins:build-storybook - - name: superset-ui/core coverage - if: steps.check.outputs.frontend + docker load -i superset-node.tar.gz + + - name: npm run test with coverage working-directory: ./superset-frontend run: | - npm run core:cover - - name: unit tests - if: steps.check.outputs.frontend + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run test -- --coverage --silent" + - name: superset-ui/core coverage working-directory: ./superset-frontend run: | - npm run test -- --coverage --silent - # todo: remove this step when fix generator as a project in root jest.config.js - - name: generator-superset unit tests - if: steps.check.outputs.frontend - working-directory: ./superset-frontend/packages/generator-superset - run: npm run test + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run core:cover" - name: Upload code coverage uses: codecov/codecov-action@v5 with: flags: javascript token: ${{ secrets.CODECOV_TOKEN }} verbose: true + + lint-frontend: + 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: eslint + run: | + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run eslint -- . --quiet" + - name: tsc + run: | + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run type" + + validate-frontend: + 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: Build plugins packages + run: | + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run plugins:build" + - name: Build plugins Storybook + working-directory: ./superset-frontend + run: | + docker run --rm superset-node-${{ github.sha }} bash -c \ + "npm run plugins:build-storybook" diff --git a/Dockerfile b/Dockerfile index 4f24360988101..91af4312c60a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,9 +24,9 @@ ARG PY_VER=3.10-slim-bookworm ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64} ###################################################################### -# superset-node used for building frontend assets +# superset-node-ci used as a base for building frontend assets and CI ###################################################################### -FROM --platform=${BUILDPLATFORM} node:20-bullseye-slim AS superset-node +FROM --platform=${BUILDPLATFORM} node:20-bullseye-slim AS superset-node-ci ARG BUILD_TRANSLATIONS="false" # Include translations in the final build ENV BUILD_TRANSLATIONS=${BUILD_TRANSLATIONS} ARG DEV_MODE="false" # Skip frontend build in dev mode @@ -66,6 +66,11 @@ RUN --mount=type=bind,source=./superset-frontend/package.json,target=./package.j # Runs the webpack build process COPY superset-frontend /app/superset-frontend +###################################################################### +# superset-node used for compile frontend assets +###################################################################### +FROM superset-node-ci AS superset-node + # Build the frontend if not in dev mode RUN --mount=type=cache,target=/app/superset-frontend/.temp_cache \ --mount=type=cache,target=/root/.npm \