fix(esbuild): remove extra css files created in build output #595
Workflow file for this run
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: Sample Metrics | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, labeled, unlabeled] | |
| branches: [main] | |
| paths: | |
| - "component-samples/**" | |
| - "core-samples/**" | |
| - "core-tutorials/**" | |
| - "!core-samples/.metrics/**" | |
| workflow_dispatch: | |
| concurrency: | |
| group: "sample-metrics-${{ github.event.pull_request.number || github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| context: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| skip_zip: ${{ steps.push-zip.outputs.skip }} | |
| skip_metrics: ${{ steps.push-metrics.outputs.skip }} | |
| samples: ${{ steps.extract-samples.outputs.samples }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: Check whether to push zip files | |
| id: push-zip | |
| run: | | |
| # If this is workflow_dispatch, compile and push zip files | |
| github_event="${{ github.event_name }}" | |
| if [ "$github_event" == "workflow_dispatch" ]; then | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # This step involves analyzing if any files changed in the branch, if so we'll create zip files | |
| # The scripts/create-zips.js file sets the folders that are used to create the zips | |
| current_branch=${{ github.head_ref }} | |
| # did any files change in component or core samples | |
| # compare against version before the last commit in the branch | |
| samples_changed=$(git diff --name-only ${{ github.head_ref }} origin/${{ github.base_ref }} -- "./core-samples" "./component-samples") | |
| if [ -z "$samples_changed" ]; then | |
| echo "no samples changed, skipping creation of zip files" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "samples changed: $samples_changed" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check whether to push sample metrics | |
| id: push-metrics | |
| run: | | |
| # If this is workflow_dispatch, compile and push zip files | |
| github_event="${{ github.event_name }}" | |
| if [ "$github_event" == "workflow_dispatch" ]; then | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # This step involves analyzing the package.json files changed in the branch, if so we'll build the samples | |
| # package.json files changed in the branch | |
| packages_changed=$(git diff --name-only "${{ github.head_ref }}" origin/"${{ github.base_ref }}" -- "./core-samples/**/package.json") | |
| if [ -z "$packages_changed" ]; then | |
| echo "no package.json files changed, skipping build analysis" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "package.json files changed: $packages_changed" | |
| echo "analyzing builds" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Extract samples to run metrics | |
| id: extract-samples | |
| if: steps.push-metrics.outputs.skip == 'false' | |
| run: | | |
| samples=$(jq -c 'keys' .github/scripts/samplesInfo.json) | |
| echo "Samples to run metrics on: $samples" | |
| echo "samples=$samples" >> $GITHUB_OUTPUT | |
| analyze-core-samples: | |
| runs-on: ubuntu-22.04 | |
| needs: [context] | |
| strategy: | |
| matrix: | |
| samples: ${{ fromJson(needs.context.outputs.samples) }} | |
| if: needs.context.outputs.skip_metrics == 'false' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| check-latest: true | |
| - name: install dependencies for sample metrics script | |
| working-directory: .github/scripts | |
| run: | | |
| npm i | |
| - name: run sample metrics script | |
| working-directory: .github/scripts | |
| env: | |
| SAMPLE_TARGET: ${{ matrix.samples }} | |
| run: | | |
| node analyze-single-build.js | |
| # https://github.com/actions/runner/pull/2477 | |
| # parallel matrix doesn't yet support dynamic outputs | |
| # hence storing individual output in text files and re-joining them later | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: analysis-${{ matrix.samples }}.txt | |
| path: .github/scripts/analysis-${{ matrix.samples }}.txt | |
| push-metrics-and-zips: | |
| runs-on: ubuntu-22.04 | |
| needs: [analyze-core-samples, context] | |
| if: always() && (needs.context.outputs.skip_zip == 'false' || needs.context.outputs.skip_metrics == 'false') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| check-latest: true | |
| - name: Setup up git config | |
| run: | | |
| git branch | |
| git status | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: install dependencies for sample metrics script | |
| working-directory: .github/scripts | |
| run: | | |
| npm i | |
| - name: create zip files | |
| if: needs.context.outputs.skip_zip == 'false' | |
| working-directory: .github/scripts | |
| run: | | |
| node create-zips.js | |
| - name: commit zip files | |
| if: needs.context.outputs.skip_zip == 'false' | |
| run: | | |
| git add zips | |
| - uses: actions/download-artifact@v4 | |
| if: needs.context.outputs.skip_metrics == 'false' | |
| with: | |
| path: analysis-texts | |
| pattern: analysis-*.txt | |
| merge-multiple: true | |
| # from each analysis-*.txt file, create a single analysis.txt file | |
| - name: combine analysis files | |
| if: needs.context.outputs.skip_metrics == 'false' | |
| working-directory: .github/scripts | |
| env: | |
| ANALYSIS_OUTPUTS_PATH: ../../analysis-texts | |
| run: | | |
| # combine all analysis-*.txt files into a single analysis.txt file | |
| node validate-and-combine-metrics.js | |
| - name: commit analysis files | |
| if: needs.context.outputs.skip_metrics == 'false' | |
| run: | | |
| git add core-samples/.metrics/*.csv | |
| - name: commit and push changes | |
| run: | | |
| git commit -m "ci: analyze core esm sample builds" || true | |
| git push origin ${{ github.head_ref }} | |
| errors: | |
| runs-on: ubuntu-latest | |
| needs: [push-metrics-and-zips] | |
| if: needs.push-metrics-or-zips.result == 'failure' && failure() | |
| steps: | |
| - name: Capture error | |
| run: | | |
| echo "Error in the build analysis" |