calculate differences #2
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: Quality Gates | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| platform: | ||
| required: true | ||
| type: string | ||
| run-id: | ||
| required: true | ||
| type: string | ||
| env: | ||
| PYTHON_VERSION: "3.12" | ||
| jobs: | ||
| get-merge-base: | ||
| needs: check-file-changes | ||
| if: needs.check-file-changes.outputs.builders_changed == 'false' | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| run_id: ${{ steps.find_run.outputs.run_id }} | ||
| steps: | ||
| - name: Fetch master and PR branch | ||
| run: | | ||
| git fetch origin master:refs/remotes/origin/master | ||
| git fetch origin ${{ github.head_ref }}:refs/remotes/origin/temp-${{ github.head_ref }} | ||
| - name: Get merge base commit | ||
| id: merge_base | ||
| run: | | ||
| base=$(git merge-base origin/temp-${{ github.head_ref }} origin/master) | ||
| - name: Find workflow run at exact merge-base SHA | ||
| id: find_run | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| MERGE_BASE=${{ steps.merge_base.outputs.sha }} | ||
| count=$(git rev-list --count ${{ steps.merge_base.outputs.sha }}..origin/master) | ||
| count_plus_one=$((count + 1)) | ||
| run_id=$( | ||
| ( | ||
| gh run list --workflow "Measure Disk Usage" --limit $count_plus_one --branch "master" --json databaseId,headSha,event | ||
| gh run list --workflow "Fetch Previous Sizes JSON" --limit $count_plus_one --branch "master" --json databaseId,headSha,event | ||
| ) | jq -s '[.[][]] | .[] | select(.headSha == "'"$MERGE_BASE"'") | .databaseId' | head -n 1 | ||
| ) | ||
| if [ -z "$run_id" ]; then | ||
| echo "No workflow run found for that SHA" >> $GITHUB_STEP_SUMMARY | ||
| exit 1 | ||
| fi | ||
| download-artifacts: | ||
| needs: get-merge-base | ||
| runs-on: ubuntu-22.04 | ||
| strategy: | ||
| matrix: | ||
| platform: [macos-x86_64, macos-aarch64, linux-x86_64, linux-aarch64, windows-x86_64] | ||
| steps: | ||
| - name: Download artifact from merge-base run | ||
| run: gh run download ${{ needs.get-merge-base.outputs.run_id }} --name ${{ matrix.platform }}_compressed_status.json | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Rename previous sizes artifact | ||
| run: | | ||
| mv ${{ matrix.platform }}_compressed_status.json ${{ matrix.platform }}_prev_compressed_status.json | ||
| - name: Download current sizes artifact | ||
| run: gh run download ${{ inputs.run-id }} --name ${{ inputs.platform }}_compressed_status.json | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Rename current sizes artifact | ||
| run: | | ||
| mv ${{ matrix.platform }}_compressed_status.json ${{ matrix.platform }}_curr_compressed_status.json | ||
| calculate-diffs: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Set up Python ${{ env.PYTHON_VERSION }} | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| - name: Calculate diffs | ||
| run: | | ||
| python -m ddev.cli.size.utils.gha_diff --prev-sizes ${{ matrix.platform }}_prev_compressed_status.json --curr-sizes ${{ matrix.platform }}_curr_compressed_status.json > $GITHUB_STEP_SUMMARY | ||