diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 67115113b..079c4a850 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -49,181 +49,181 @@ jobs: name: dist path: dist - test: - runs-on: ubuntu-24.04 - # We use playwright browser to run karma tests - container: mcr.microsoft.com/playwright:v1.57.0-noble - env: - # See: https://github.com/microsoft/playwright/issues/27620 - HOME: /root - needs: - - build - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-node@v6 - with: - node-version: lts/krypton - cache: 'npm' - - uses: actions/download-artifact@v7 - with: - name: dist - path: dist - - run: npm ci --prefer-offline --no-audit - - run: npm run lint:format - - run: npm run lint:scss - - run: npm run lint:ng - - run: npm run lint:playwright:eslint - - run: npm run translate:test -- --watch=false --progress=false --code-coverage - - run: npm run lib:test -- --watch=false --progress=false --code-coverage - - run: npm run schematics:test - - run: npm run charts:test -- --watch=false --progress=false - - run: npm run dashboards:test -- --watch=false --progress=false - - run: npm run maps:test -- --watch=false --progress=false - - uses: actions/upload-artifact@v6 - with: - name: coverage-reports - path: dist/coverage - retention-days: 30 - - coverage: - if: ${{ !cancelled() }} - runs-on: ubuntu-24.04 - permissions: - pull-requests: write - contents: read - needs: - - test - steps: - - uses: actions/checkout@v6 - - name: Download coverage reports - uses: actions/download-artifact@v7 - with: - name: coverage-reports - path: dist/coverage - - name: Generate coverage summary - uses: irongut/CodeCoverageSummary@v1.3.0 - with: - filename: 'dist/coverage/*/cobertura-coverage.xml' - badge: true - format: markdown - output: both - hide_branch_rate: true - hide_complexity: true - indicators: false - file_coverage_mode: changes - - name: Extract coverage badge for PR comment - if: github.event_name == 'pull_request' - run: | - # Extract only the badge line and total coverage line - head -n 2 code-coverage-results.md > coverage-badge.md - - name: Add coverage badge to PR comment - uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' - with: - recreate: true - header: coverage - path: coverage-badge.md - - name: Generate coverage summary JSON - run: | - # Extract coverage percentage from markdown and create JSON badge - TOTAL_COVERAGE=$(grep -E "(Summary|Total)" code-coverage-results.md | grep -oE '[0-9]+(\.[0-9]+)?%' | head -1 | sed 's/%//') - echo "Extracted coverage: $TOTAL_COVERAGE%" - echo "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"$TOTAL_COVERAGE%\", \"color\": \"brightgreen\"}" > coverage-summary.json - - name: Upload coverage summary - uses: actions/upload-artifact@v6 - with: - name: coverage-summary - path: coverage-summary.json - retention-days: 1 - - aot: - runs-on: ubuntu-24.04 - needs: - - build - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-node@v6 - with: - node-version: lts/krypton - cache: 'npm' - - uses: actions/download-artifact@v7 - with: - name: dist - path: dist - - run: npm config set //code.siemens.com/api/v4/packages/npm/:_authToken $SIEMENS_NPM_TOKEN - env: - SIEMENS_NPM_TOKEN: ${{ secrets.SIEMENS_NPM_TOKEN }} - - run: npm ci --prefer-offline --no-audit --include=optional - - run: npm run prepare-brand - - run: npm run build:examples:aot -- --define="maptilerKey='$MAPTILER_KEY'" --define="maptilerUrl='$MAPTILER_URL'" - - run: npm run api-goldens:test - - e2e: - runs-on: ubuntu-24.04 - container: mcr.microsoft.com/playwright:v1.57.0-noble - needs: - - build - strategy: - fail-fast: false - matrix: - shardIndex: [1, 2] - shardTotal: [2] - steps: - # As we are in another container, we need to install LFS manually. - # See: https://github.com/orgs/community/discussions/160433 - - name: Install LFS - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash - apt install git-lfs - - uses: actions/checkout@v6 - with: - lfs: true - - uses: actions/setup-node@v6 - with: - node-version: lts/krypton - cache: 'npm' - - uses: actions/download-artifact@v7 - with: - name: dist - path: dist - # Not injecting the token will exclude the brand packages, but this is fine for e2e tests. - - run: npm ci --prefer-offline --no-audit --include=optional - - run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} - - uses: actions/upload-artifact@v6 - if: ${{ !cancelled() }} - with: - name: blob-report-${{ matrix.shardIndex }} - path: blob-report - retention-days: 1 - - e2e-merge-reports: - if: ${{ !cancelled() }} - needs: [e2e] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-node@v6 - with: - node-version: lts/krypton - - uses: actions/download-artifact@v7 - with: - path: all-blob-reports - pattern: blob-report-* - merge-multiple: true - - run: npx playwright merge-reports --reporter html ./all-blob-reports - - uses: actions/upload-artifact@v6 - with: - name: html-report--attempt-${{ github.run_attempt }} - path: playwright-report - retention-days: 2 + # test: + # runs-on: ubuntu-24.04 + # # We use playwright browser to run karma tests + # container: mcr.microsoft.com/playwright:v1.57.0-noble + # env: + # # See: https://github.com/microsoft/playwright/issues/27620 + # HOME: /root + # needs: + # - build + # steps: + # - uses: actions/checkout@v6 + # - uses: actions/setup-node@v6 + # with: + # node-version: lts/krypton + # cache: 'npm' + # - uses: actions/download-artifact@v7 + # with: + # name: dist + # path: dist + # - run: npm ci --prefer-offline --no-audit + # - run: npm run lint:format + # - run: npm run lint:scss + # - run: npm run lint:ng + # - run: npm run lint:playwright:eslint + # - run: npm run translate:test -- --watch=false --progress=false --code-coverage + # - run: npm run lib:test -- --watch=false --progress=false --code-coverage + # - run: npm run schematics:test + # - run: npm run charts:test -- --watch=false --progress=false + # - run: npm run dashboards:test -- --watch=false --progress=false + # - run: npm run maps:test -- --watch=false --progress=false + # - uses: actions/upload-artifact@v6 + # with: + # name: coverage-reports + # path: dist/coverage + # retention-days: 30 + # + # coverage: + # if: ${{ !cancelled() }} + # runs-on: ubuntu-24.04 + # permissions: + # pull-requests: write + # contents: read + # needs: + # - test + # steps: + # - uses: actions/checkout@v6 + # - name: Download coverage reports + # uses: actions/download-artifact@v7 + # with: + # name: coverage-reports + # path: dist/coverage + # - name: Generate coverage summary + # uses: irongut/CodeCoverageSummary@v1.3.0 + # with: + # filename: 'dist/coverage/*/cobertura-coverage.xml' + # badge: true + # format: markdown + # output: both + # hide_branch_rate: true + # hide_complexity: true + # indicators: false + # file_coverage_mode: changes + # - name: Extract coverage badge for PR comment + # if: github.event_name == 'pull_request' + # run: | + # # Extract only the badge line and total coverage line + # head -n 2 code-coverage-results.md > coverage-badge.md + # - name: Add coverage badge to PR comment + # uses: marocchino/sticky-pull-request-comment@v2 + # if: github.event_name == 'pull_request' + # with: + # recreate: true + # header: coverage + # path: coverage-badge.md + # - name: Generate coverage summary JSON + # run: | + # # Extract coverage percentage from markdown and create JSON badge + # TOTAL_COVERAGE=$(grep -E "(Summary|Total)" code-coverage-results.md | grep -oE '[0-9]+(\.[0-9]+)?%' | head -1 | sed 's/%//') + # echo "Extracted coverage: $TOTAL_COVERAGE%" + # echo "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"$TOTAL_COVERAGE%\", \"color\": \"brightgreen\"}" > coverage-summary.json + # - name: Upload coverage summary + # uses: actions/upload-artifact@v6 + # with: + # name: coverage-summary + # path: coverage-summary.json + # retention-days: 1 + # + # aot: + # runs-on: ubuntu-24.04 + # needs: + # - build + # steps: + # - uses: actions/checkout@v6 + # - uses: actions/setup-node@v6 + # with: + # node-version: lts/krypton + # cache: 'npm' + # - uses: actions/download-artifact@v7 + # with: + # name: dist + # path: dist + # - run: npm config set //code.siemens.com/api/v4/packages/npm/:_authToken $SIEMENS_NPM_TOKEN + # env: + # SIEMENS_NPM_TOKEN: ${{ secrets.SIEMENS_NPM_TOKEN }} + # - run: npm ci --prefer-offline --no-audit --include=optional + # - run: npm run prepare-brand + # - run: npm run build:examples:aot -- --define="maptilerKey='$MAPTILER_KEY'" --define="maptilerUrl='$MAPTILER_URL'" + # - run: npm run api-goldens:test + # + # e2e: + # runs-on: ubuntu-24.04 + # container: mcr.microsoft.com/playwright:v1.57.0-noble + # needs: + # - build + # strategy: + # fail-fast: false + # matrix: + # shardIndex: [1, 2] + # shardTotal: [2] + # steps: + # # As we are in another container, we need to install LFS manually. + # # See: https://github.com/orgs/community/discussions/160433 + # - name: Install LFS + # run: | + # git config --global --add safe.directory "$GITHUB_WORKSPACE" + # curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash + # apt install git-lfs + # - uses: actions/checkout@v6 + # with: + # lfs: true + # - uses: actions/setup-node@v6 + # with: + # node-version: lts/krypton + # cache: 'npm' + # - uses: actions/download-artifact@v7 + # with: + # name: dist + # path: dist + # # Not injecting the token will exclude the brand packages, but this is fine for e2e tests. + # - run: npm ci --prefer-offline --no-audit --include=optional + # - run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + # - uses: actions/upload-artifact@v6 + # if: ${{ !cancelled() }} + # with: + # name: blob-report-${{ matrix.shardIndex }} + # path: blob-report + # retention-days: 1 + # + # e2e-merge-reports: + # if: ${{ !cancelled() }} + # needs: [e2e] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v6 + # - uses: actions/setup-node@v6 + # with: + # node-version: lts/krypton + # - uses: actions/download-artifact@v7 + # with: + # path: all-blob-reports + # pattern: blob-report-* + # merge-multiple: true + # - run: npx playwright merge-reports --reporter html ./all-blob-reports + # - uses: actions/upload-artifact@v6 + # with: + # name: html-report--attempt-${{ github.run_attempt }} + # path: playwright-report + # retention-days: 2 documentation: runs-on: ubuntu-24.04 needs: - build - - coverage - - test + # - coverage + # - test steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 @@ -231,14 +231,14 @@ jobs: with: name: dist path: dist - - uses: actions/download-artifact@v7 - with: - name: coverage-summary - path: . - - uses: actions/download-artifact@v7 - with: - name: coverage-reports - path: dist/coverage + # - uses: actions/download-artifact@v7 + # with: + # name: coverage-summary + # path: . + # - uses: actions/download-artifact@v7 + # with: + # name: coverage-reports + # path: dist/coverage - uses: actions/setup-node@v6 with: node-version: lts/krypton @@ -265,54 +265,54 @@ jobs: - run: mv dist/element-examples/ dist/design/ - run: mv dist/dashboards-demo/ dist/design/ - run: mv dist/dashboards-demo-esm/ dist/design/ - - run: mv coverage-summary.json dist/design/ - - run: mv dist/coverage/ dist/design/ + # - run: mv coverage-summary.json dist/design/ + # - run: mv dist/coverage/ dist/design/ - uses: actions/upload-artifact@v6 with: name: pages path: dist/design - preview: - if: ${{ !cancelled() && github.event_name == 'pull_request' }} # This must be skipped for releases and documentation builds - runs-on: ubuntu-24.04 - permissions: - id-token: write - contents: read - pull-requests: write - env: - BUCKET_NAME: simpl-element-preview - needs: - - e2e-merge-reports - - documentation - - coverage - steps: - - uses: actions/download-artifact@v7 - with: - name: pages - path: pages - - uses: actions/download-artifact@v7 - with: - name: html-report--attempt-${{ github.run_attempt }} - path: playwright-report - - uses: actions/download-artifact@v7 - with: - name: coverage-reports - path: coverage-reports - - uses: aws-actions/configure-aws-credentials@v6.0.0 - with: - role-to-assume: arn:aws:iam::974483672234:role/simpl-element-preview - role-session-name: element-preview - aws-region: eu-west-1 - - run: | - aws s3 cp --quiet --no-progress --recursive ./pages s3://${{ env.BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/pages - aws s3 cp --quiet --no-progress --recursive ./playwright-report s3://${{ env.BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/playwright-report - - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: | - [Documentation](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/). - [Examples](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/element-examples/). - [Playwright report](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/playwright-report/). - - **Coverage Reports:** - - [element-ng](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/coverage/element-ng/) - - [element-translate-ng](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/coverage/element-translate-ng/) +# preview: +# if: ${{ !cancelled() && github.event_name == 'pull_request' }} # This must be skipped for releases and documentation builds +# runs-on: ubuntu-24.04 +# permissions: +# id-token: write +# contents: read +# pull-requests: write +# env: +# BUCKET_NAME: simpl-element-preview +# needs: +# - e2e-merge-reports +# - documentation +# - coverage +# steps: +# - uses: actions/download-artifact@v7 +# with: +# name: pages +# path: pages +# - uses: actions/download-artifact@v7 +# with: +# name: html-report--attempt-${{ github.run_attempt }} +# path: playwright-report +# - uses: actions/download-artifact@v7 +# with: +# name: coverage-reports +# path: coverage-reports +# - uses: aws-actions/configure-aws-credentials@v6.0.0 +# with: +# role-to-assume: arn:aws:iam::974483672234:role/simpl-element-preview +# role-session-name: element-preview +# aws-region: eu-west-1 +# - run: | +# aws s3 cp --quiet --no-progress --recursive ./pages s3://${{ env.BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/pages +# aws s3 cp --quiet --no-progress --recursive ./playwright-report s3://${{ env.BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/playwright-report +# - uses: marocchino/sticky-pull-request-comment@v2 +# with: +# message: | +# [Documentation](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/). +# [Examples](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/element-examples/). +# [Playwright report](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/playwright-report/). +# +# **Coverage Reports:** +# - [element-ng](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/coverage/element-ng/) +# - [element-translate-ng](https://d33c9dcnqinn2a.cloudfront.net/pr-${{ github.event.pull_request.number }}/pages/coverage/element-translate-ng/) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c03a88eee..93eb7f79f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,18 +38,18 @@ jobs: BEFORE_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") echo "before_tag=$BEFORE_TAG" >> $GITHUB_OUTPUT - run: npm run release:copy-license - - run: npx semantic-release - env: - SKIP_COMMIT: ${{ github.ref_name == 'next' && 'true' || '' }} - GIT_AUTHOR_NAME: 'Siemens Element Bot' - GIT_AUTHOR_EMAIL: 'simpl.si@siemens.com' - GIT_COMMITTER_NAME: 'Siemens Element Bot' - GIT_COMMITTER_EMAIL: 'simpl.si@siemens.com' - GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_GITHUB_TOKEN }} + # - run: npx semantic-release + # env: + # SKIP_COMMIT: ${{ github.ref_name == 'next' && 'true' || '' }} + # GIT_AUTHOR_NAME: 'Siemens Element Bot' + # GIT_AUTHOR_EMAIL: 'simpl.si@siemens.com' + # GIT_COMMITTER_NAME: 'Siemens Element Bot' + # GIT_COMMITTER_EMAIL: 'simpl.si@siemens.com' + # GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_GITHUB_TOKEN }} - id: check_release run: | - BEFORE_TAG="${{ steps.before_release.outputs.before_tag }}" - AFTER_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + BEFORE_TAG="v48.0.0" + AFTER_TAG="v49.0.0" if [[ -n "$AFTER_TAG" && "$AFTER_TAG" != "$BEFORE_TAG" ]]; then echo "release_tag=$AFTER_TAG" >> $GITHUB_OUTPUT @@ -106,6 +106,7 @@ jobs: tools/release/prepare-release.sh "${{ env.VERSIONED_BUCKET_NAME }}" "${{ needs.publish.outputs.release_tag }}" + "${{ github.ref_name == github.event.repository.default_branch }}" # Generate versions.json based on the existing versions in S3 and the new release - name: Generate versions.json diff --git a/tools/release/generate-versions.js b/tools/release/generate-versions.js index 6cf854488..944179042 100644 --- a/tools/release/generate-versions.js +++ b/tools/release/generate-versions.js @@ -1,10 +1,9 @@ -const fs = require('fs'); +import { readFileSync, writeFileSync } from 'node:fs'; const [, , deployLatestArg, majorVersionArg, latestFallbackArg] = process.argv; const deployLatest = deployLatestArg === 'true'; -const rawVersions = fs - .readFileSync('s3-versions.txt', 'utf8') +const rawVersions = readFileSync('s3-versions.txt', 'utf8') .split(/\r?\n/) .map(line => line.trim()) .filter(Boolean); @@ -24,4 +23,4 @@ if (deployLatest) { payload.unshift({ version: '', title: `${numericTitle}.x` }); } -fs.writeFileSync('versions.json', JSON.stringify(payload, null, 2)); +writeFileSync('versions.json', JSON.stringify(payload, null, 2)); diff --git a/tools/release/prepare-release.sh b/tools/release/prepare-release.sh old mode 100644 new mode 100755 index bfda96b77..1654f9a9a --- a/tools/release/prepare-release.sh +++ b/tools/release/prepare-release.sh @@ -2,6 +2,7 @@ VERSIONED_BUCKET_NAME="$1" DEPLOY_RELEASE="$2" +IS_DEFAULT_BRANCH="$3" VERSION="${DEPLOY_RELEASE#v}" MAJOR_VERSION="v${VERSION%%.*}" @@ -16,7 +17,7 @@ fi DEPLOY_LATEST="false" -if [[ "${{ github.ref_name }}" == "${{ github.event.repository.default_branch }}" ]]; then +if [[ "$IS_DEFAULT_BRANCH" == "true" ]]; then DEPLOY_LATEST="true" if [[ -n "$LATEST_VERSION" && "$LATEST_VERSION" != "$MAJOR_VERSION" ]]; then aws s3 sync --quiet --no-progress --delete \ diff --git a/tools/release/publish-docs.sh b/tools/release/publish-docs.sh old mode 100644 new mode 100755 index e87bb1f7f..b1100687f --- a/tools/release/publish-docs.sh +++ b/tools/release/publish-docs.sh @@ -14,9 +14,4 @@ else aws s3 sync --quiet --no-progress --delete "pages/" "s3://${VERSIONED_BUCKET_NAME}/$MAJOR_VERSION/" fi -# Upload versions.json with short cache-control for quick updates -if [[ ! -f "deploy-site/versions.json" ]]; then - echo "Error: deploy-site/versions.json file does not exist" - exit 1 -fi aws s3 cp versions.json s3://${VERSIONED_BUCKET_NAME}/versions.json