Self-host ECharts runtime asset #3918
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test and build container | |
| on: | |
| push: | |
| branches: [master] | |
| tags: [v*] | |
| pull_request: # we can use docker image in PR for testing | |
| branches: [master] | |
| env: | |
| REGISTRY: ghcr.io | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Code format check | |
| run: | | |
| echo "Using prettier: $(pnpm run format --version)" | |
| pnpm run format:check | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up SSH deploy key for fonts | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY_FONTS }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Setup submodules | |
| run: bash scripts/build-deps.sh | |
| - name: Install Playwright | |
| run: pnpm exec playwright install chromium --with-deps | |
| # use separate build step to avoid playwright timeout issue | |
| # mode=test so the output goes to .svelte-kit-test/ which is where | |
| # the integration test preview server (--mode=test) expects it | |
| - name: Build SvelteKit vite app (test mode) | |
| run: pnpm run build:test | |
| - name: Run unit and integration tests | |
| run: pnpm run test:no-build | |
| - name: Upload Test Results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-test-results | |
| path: | | |
| test-results/ | |
| tests/integration/**/*-snapshots/ | |
| retention-days: 7 | |
| compression-level: 0 # Skip compression since PNGs are already compressed | |
| test-e2e: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up SSH deploy key for fonts | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY_FONTS }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Setup submodules | |
| run: bash scripts/build-deps.sh | |
| - name: Install Playwright | |
| run: pnpm exec playwright install chromium --with-deps | |
| # e2e tests need a production build (--mode=production preview server) | |
| - name: Build SvelteKit vite app (production mode) | |
| run: pnpm run build | |
| - name: Run e2e tests | |
| env: | |
| TS_PRIVATE_R2_ACCOUNT_ID: ${{ secrets.TS_PRIVATE_R2_ACCOUNT_ID }} | |
| TS_PRIVATE_R2_ACCESS_KEY_ID: ${{ secrets.TS_PRIVATE_R2_ACCESS_KEY_ID }} | |
| TS_PRIVATE_R2_SECRET_ACCESS_KEY: ${{ secrets.TS_PRIVATE_R2_SECRET_ACCESS_KEY }} | |
| TS_PRIVATE_R2_BUCKET_NAME: ${{ secrets.TS_PRIVATE_R2_BUCKET_NAME }} | |
| run: pnpm run test:e2e | |
| - name: Upload Test Results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-e2e-results | |
| path: test-results/ | |
| retention-days: 7 | |
| compression-level: 0 | |
| build: | |
| runs-on: ubuntu-latest | |
| # 2023-02 disable because tests are too flaky and do not pass on CI at all | |
| # needs: test | |
| # Only build Docker image for tagged releases | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Set up SSH deploy key for fonts | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY_FONTS }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Read metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository }} | |
| - name: Log in to Github Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| upload-sourcemaps: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Read metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository }} | |
| flavor: latest=false | |
| - name: Log in to Github Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract sourcemaps from Docker image | |
| run: | | |
| docker pull ${{ steps.meta.outputs.tags }} | |
| docker create --name extract ${{ steps.meta.outputs.tags }} | |
| docker cp extract:/app/build ./build | |
| docker rm extract | |
| - name: Upload sourcemaps | |
| id: upload-sourcemaps | |
| continue-on-error: true | |
| env: | |
| SENTRY_ORG: ${{ vars.SENTRY_ORG }} | |
| SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} | |
| SENTRY_URL: ${{ vars.SENTRY_URL }} | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_RELEASE: ${{ vars.SENTRY_PROJECT }}@${{ steps.meta.outputs.version }} | |
| run: | | |
| npx @sentry/cli sourcemaps upload -r $SENTRY_RELEASE build/client build/server/chunks | |
| # GH action should still succeed even if sourcemaps upload failed | |
| - name: Echo failure message | |
| run: echo "Sourcemap upload failed" | |
| if: steps.upload-sourcemaps.outcome == 'failure' |