Repository navigation
Collect dataplane AnsibleEE jobs only when deployment has finished #842
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: CRD Size Badge | ||
|
Check warning on line 1 in .github/workflows/crd-size-badge.yaml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - '[0-9]+.[0-9]+-fr[0-9]+' | ||
| pull_request_target: | ||
| branches: | ||
| - main | ||
| - '[0-9]+.[0-9]+-fr[0-9]+' | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| jobs: | ||
| crd-size: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
| with: | ||
| # Never check out the untrusted PR head in this privileged workflow. | ||
| ref: ${{ github.event.pull_request.base.sha || github.sha }} | ||
| - name: Install yq | ||
| uses: mikefarah/yq@504fc38780cc46be8444ea1b72fb55919fc0bfb0 # v4 | ||
| - name: Compute CRD JSON size | ||
| id: size | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | ||
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| CRD_FILE="config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml" | ||
| if [ "$GITHUB_EVENT_NAME" = "pull_request_target" ]; then | ||
| PR_CRD_JSON=$(gh api \ | ||
| -H "Accept: application/vnd.github.raw+json" \ | ||
| "repos/$PR_HEAD_REPO/contents/$CRD_FILE?ref=$PR_HEAD_SHA" \ | ||
| | yq eval -o=json - | jq -c .) | ||
| SIZE=$(printf '%s\n' "$PR_CRD_JSON" | wc -c) | ||
| else | ||
| SIZE=$(yq eval -o=json "$CRD_FILE" | jq -c . | wc -c) | ||
| fi | ||
| echo "bytes=$SIZE" >> "$GITHUB_OUTPUT" | ||
| if [ "$SIZE" -lt 307200 ]; then | ||
| echo "color=green" >> "$GITHUB_OUTPUT" | ||
| echo "status=comfortable" >> "$GITHUB_OUTPUT" | ||
| elif [ "$SIZE" -lt 409600 ]; then | ||
| echo "color=yellow" >> "$GITHUB_OUTPUT" | ||
| echo "status=growing" >> "$GITHUB_OUTPUT" | ||
| elif [ "$SIZE" -lt 768000 ]; then | ||
| echo "color=orange" >> "$GITHUB_OUTPUT" | ||
| echo "status=concerning" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "color=red" >> "$GITHUB_OUTPUT" | ||
| echo "status=approaching etcd limit" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| # Human-readable size | ||
| if [ "$SIZE" -ge 1048576 ]; then | ||
| HUMAN="$(awk "BEGIN {printf \"%.1f\", $SIZE/1048576}")MB" | ||
| else | ||
| HUMAN="$(awk "BEGIN {printf \"%.0f\", $SIZE/1024}")KB" | ||
| fi | ||
| echo "human=$HUMAN" >> "$GITHUB_OUTPUT" | ||
| - name: Compute base branch size | ||
| if: github.event_name == 'pull_request_target' | ||
| id: base_size | ||
| run: | | ||
| CRD_FILE="config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml" | ||
| git fetch origin "${{ github.base_ref }}" --depth=1 | ||
| BASE_SIZE=$(git show "origin/${{ github.base_ref }}:${CRD_FILE}" | yq eval -o=json - | jq -c . | wc -c) | ||
| echo "bytes=$BASE_SIZE" >> "$GITHUB_OUTPUT" | ||
| CHANGE=$(awk "BEGIN {if ($BASE_SIZE == 0) printf \"N/A\"; else printf \"%+.2f\", ((${{ steps.size.outputs.bytes }} - $BASE_SIZE) / $BASE_SIZE) * 100}") | ||
| echo "change=$CHANGE" >> "$GITHUB_OUTPUT" | ||
| - name: Find existing comment | ||
| if: github.event_name == 'pull_request_target' | ||
| uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4 | ||
| id: find_comment | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| comment-author: 'github-actions[bot]' | ||
| body-includes: '<!-- crd-size-badge -->' | ||
| - name: Post or update PR comment | ||
| if: github.event_name == 'pull_request_target' | ||
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 | ||
| with: | ||
| comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| edit-mode: replace | ||
| body: | | ||
| <!-- crd-size-badge --> | ||
| ## OpenStackControlPlane CRD Size Report | ||
| | Metric | Value | | ||
| |--------|-------| | ||
| | **CRD JSON size** | ${{ steps.size.outputs.bytes }} bytes (${{ steps.size.outputs.human }}) | | ||
| | **Base branch size** | ${{ steps.base_size.outputs.bytes }} bytes | | ||
| | **Change** | ${{ steps.base_size.outputs.change }}% | | ||
| | **Status** | ${{ steps.size.outputs.color }} — ${{ steps.size.outputs.status }} | | ||
| <details> | ||
| <summary>Threshold reference</summary> | ||
| | Color | Range | Meaning | | ||
| |-------|-------|---------| | ||
| | :green_circle: green | < 300KB | Comfortable | | ||
| | :yellow_circle: yellow | 300–400KB | Growing | | ||
| | :orange_circle: orange | 400–750KB | Concerning | | ||
| | :red_circle: red | > 750KB | Approaching 1.5MB etcd limit (cut in half to allow space for update) | | ||
| </details> | ||
| - name: Update badge gist | ||
| if: github.event_name == 'push' | ||
| uses: schneegans/dynamic-badges-action@28b0fa8bdeb46170ac397105ece0c1fe58f68910 # v1.9.0 | ||
| with: | ||
| auth: ${{ secrets.GIST_SECRET }} | ||
| gistID: ${{ vars.GIST_ID }} | ||
| filename: crd-size-${{ github.ref_name }}.json | ||
| label: CRD Size | ||
| message: ${{ steps.size.outputs.human }} | ||
| color: ${{ steps.size.outputs.color }} | ||