From 9aa3f4f62c87d08dc306f1c76610fa1db1ff9c18 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Mon, 13 Apr 2020 00:24:33 +0200 Subject: [PATCH] CI: Allow for generated code in PRs Generated code must now be included in PRs. This is helpful during review, as it provides the reviewer with the ability to see the result of a change. This is also necessary after https://github.com/hemtjanst/zyaml/commit/78cfbb9dfc235b79a615a83e412052e7edfa6a12 as it'll now raise PRs instead, which will include the generated code. --- .github/workflows/ci.yaml | 50 +++++--------------------------- .github/workflows/generated.yaml | 16 ---------- 2 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/generated.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f827519..59e3f4f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,16 +4,12 @@ on: paths-ignore: - 'README.md' - 'LICENSE' - - 'cluster/**' - - 'zdo/**' branches: - master push: paths-ignore: - 'README.md' - 'LICENSE' - - 'cluster/**' - - 'zdo/**' branches: - master @@ -36,6 +32,14 @@ jobs: working-directory: ./zcl run: | go run hemtjan.st/zcl/cmd/zclgen -definition-path ../zyaml + if test -n "$(git status -s)"; then + echo "Repository is in dirty state!" + echo " Update your copy of zyaml to latest master" + echo " Regenerate using cmd/zclgen" + echo "Changed files:" + git status -s + exit 1 + fi - name: Build updated ZCL working-directory: ./zcl run: | @@ -44,41 +48,3 @@ jobs: working-directory: ./zcl run: | go test -v hemtjan.st/zcl/... - update: - name: Push updated ZCL - if: github.ref == 'refs/heads/master' - needs: generate_and_test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - path: zcl - ssh-key: ${{ secrets.BOT_SSH_KEY }} - - uses: actions/checkout@v2 - with: - repository: hemtjanst/zyaml - path: zyaml - - uses: actions/setup-go@v2-beta - with: - go-version: '1.14' - - name: Generate ZCL - working-directory: ./zcl - run: | - go run hemtjan.st/zcl/cmd/zclgen -definition-path ../zyaml - go build hemtjan.st/zcl/... - go mod tidy - - name: Commit - working-directory: ./zcl - run: | - if test -n "$(git status -s)"; then - git config user.name "Hemtjanst Bot" - git config user.email "63548820+hemtjanst-bot@users.noreply.github.com" - git add . - git commit -m "Regenerated library at ${GITHUB_SHA}" - else - echo "No changes to generated code" - fi - - name: Push - working-directory: ./zcl - run: | - git push diff --git a/.github/workflows/generated.yaml b/.github/workflows/generated.yaml deleted file mode 100644 index 4329b2e..0000000 --- a/.github/workflows/generated.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: Prevent generated code in PRs -on: - pull_request: - paths: - - 'cluster/**' - - 'zdo/**' - -jobs: - error: - name: Includes generated code - runs-on: ubuntu-latest - steps: - - name: Exit - run: | - echo "Do not include generated code in your PRs" - exit 1