knoepfel checking Jsonnet format #921
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: Jsonnet Format Check | |
| run-name: "${{ github.actor }} checking Jsonnet format" | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| "on": | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." | |
| required: false | |
| type: string | |
| workflow_call: | |
| inputs: | |
| checkout-path: | |
| description: "Path to check out code to" | |
| required: false | |
| type: string | |
| skip-relevance-check: | |
| description: "Bypass relevance check" | |
| required: false | |
| type: boolean | |
| default: false | |
| ref: | |
| description: "The branch, ref, or SHA to checkout" | |
| required: false | |
| type: string | |
| repo: | |
| description: "The repository to checkout from" | |
| required: false | |
| type: string | |
| pr-base-sha: | |
| description: "Base SHA of the PR for relevance check" | |
| required: false | |
| type: string | |
| pr-head-sha: | |
| description: "Head SHA of the PR for relevance check" | |
| required: false | |
| type: string | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_act: ${{ steps.setup.outputs.is_act }} | |
| ref: ${{ steps.setup.outputs.ref }} | |
| repo: ${{ steps.setup.outputs.repo }} | |
| base_sha: ${{ steps.setup.outputs.base_sha }} | |
| pr_number: ${{ steps.setup.outputs.pr_number }} | |
| checkout_path: ${{ steps.setup.outputs.checkout_path }} | |
| has_changes: ${{ steps.setup.outputs.has_changes }} | |
| steps: | |
| - name: Workflow setup | |
| id: setup | |
| uses: Framework-R-D/phlex/.github/actions/workflow-setup@main | |
| with: | |
| file-type: jsonnet | |
| head-ref: ${{ inputs.pr-head-sha }} | |
| ref: ${{ inputs.ref }} | |
| repo: ${{ inputs.repo }} | |
| pr-base-sha: ${{ inputs.pr-base-sha }} | |
| checkout-path: ${{ inputs.checkout-path }} | |
| jsonnet-format-check: | |
| needs: setup | |
| if: > | |
| always() && ( | |
| github.event_name == 'workflow_dispatch' || | |
| inputs.skip-relevance-check || | |
| needs.setup.outputs.has_changes == 'true' | |
| ) | |
| runs-on: ubuntu-latest | |
| container: | |
| image: public.ecr.aws/bitnami/jsonnet:latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ needs.setup.outputs.ref }} | |
| repository: ${{ needs.setup.outputs.repo }} | |
| path: ${{ needs.setup.outputs.checkout_path }} | |
| persist-credentials: false | |
| - name: Check Jsonnet formatting | |
| id: lint | |
| working-directory: ${{ needs.setup.outputs.checkout_path }} | |
| run: | | |
| find . \( -name "*.jsonnet" -o -name "*.libsonnet" \) -print0 | xargs -0 -r -I {} \ | |
| bash -c 'jsonnetfmt --test "{}" || (echo "FAILED: {}" && diff -u <(jsonnetfmt "{}") "{}" && exit 1)' | |
| continue-on-error: true | |
| - name: Evaluate Jsonnet formatting result | |
| if: always() && steps.lint.outcome != 'skipped' | |
| env: | |
| REPO: ${{ needs.setup.outputs.repo }} | |
| # yamllint disable rule:line-length | |
| run: | | |
| REPO_NAME="${REPO##*/}" | |
| if [ "${{ steps.lint.outcome }}" = 'success' ]; then | |
| echo "✅ Jsonnet formatting check passed." | |
| else | |
| echo "::error::Jsonnet formatting issues found. Please review the output above for details." | |
| echo "::error::Run 'jsonnetfmt -i <file>' locally or comment '@${REPO_NAME}bot format' on the PR to auto-fix." | |
| exit 1 | |
| fi | |
| # yamllint enable |