From 736c4f9c0f03e78e0a028bffd1ad4d2685232387 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Mon, 24 Jun 2024 14:33:05 +0300 Subject: [PATCH] Add a workflow to check for local generated file changes --- .github/workflows/check-local-changes.sh | 13 ++++++ .github/workflows/check-local-changes.yml | 54 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/check-local-changes.sh create mode 100644 .github/workflows/check-local-changes.yml diff --git a/.github/workflows/check-local-changes.sh b/.github/workflows/check-local-changes.sh new file mode 100644 index 0000000000..f4e78c23e1 --- /dev/null +++ b/.github/workflows/check-local-changes.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +function check() { + if [[ -z "$(git status --porcelain ./*/src/generated/resources/*)" ]]; + then + echo "0" + else + echo "1" + fi +} + +echo ::set-output name=changed::$(check) diff --git a/.github/workflows/check-local-changes.yml b/.github/workflows/check-local-changes.yml new file mode 100644 index 0000000000..9aafd84473 --- /dev/null +++ b/.github/workflows/check-local-changes.yml @@ -0,0 +1,54 @@ +name: Check PR local changes + +on: + pull_request: + types: + - synchronize + - opened + - ready_for_review + - reopened + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1000 + fetch-tags: true + + # GradleUtils will append the branch name to the version, + # but for that we need a properly checked out branch + - name: Create branch for commit + run: + git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }} + + - name: Setup JDK 21 + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'temurin' + + - name: Setup with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: setup + cache-read-only: false + + - name: Run datagen with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: :runData :tests:runData + cache-read-only: false + + - name: Check local changes + id: check + run: ./.github/workflows/check-local-changes.sh + + - name: Output changed files + run: git status --porcelain ./*/src/generated/resources/* + + - name: Fail if local changes are detected + if: ${{ steps.check.outputs.changed == "1" }} + run: exit 1