From b10b061ee32394ea8830a082e0b2755f7cbcbe05 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 9 Jul 2024 02:17:52 +1200 Subject: [PATCH] Ensure generated code is up-to-date on PRs (#692) Doesn't pull new versions of spec, merely ensures changes to generator have been captured or manual changes haven't been made to generated code. Signed-off-by: Thomas Farr (cherry picked from commit 3864d486e8ec9540c8a1875e1ec8d5cf89679e7b) --- .github/workflows/code-gen.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/code-gen.yml diff --git a/.github/workflows/code-gen.yml b/.github/workflows/code-gen.yml new file mode 100644 index 0000000000..f305c220ab --- /dev/null +++ b/.github/workflows/code-gen.yml @@ -0,0 +1,42 @@ +name: Code Generation + +on: [pull_request] + +jobs: + up_to_date: + name: Ensure Generated Code Up To Date + runs-on: ubuntu-latest + steps: + - name: Checkout .NET Client + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 5.0.x + 6.0.x + + - name: Cache Nuget Packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.?sproj') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: Run Code Generator + run: ./build.sh codegen --branch main + + - name: Check For Uncommitted Changes + shell: bash -eo pipefail {0} + run: | + output=$(git status --porcelain) + if [ -z "$output" ]; then + echo "Clean working directory" + exit 0 + else + echo "Dirty working directory" + echo "$output" + exit 1 + fi