From eb7905b0336dc9cb3b947a07360c224ac72fd2f4 Mon Sep 17 00:00:00 2001 From: yuhuyoyo Date: Tue, 23 Aug 2022 17:00:33 -0400 Subject: [PATCH 1/2] Add an action to run spotlessApply --- .github/actions/spotless-apply/action.yml | 43 +++++++++++++++++++++++ .github/workflows/tests-nightly.yml | 13 +++++-- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/actions/spotless-apply/action.yml diff --git a/.github/actions/spotless-apply/action.yml b/.github/actions/spotless-apply/action.yml new file mode 100644 index 000000000..91e12e44c --- /dev/null +++ b/.github/actions/spotless-apply/action.yml @@ -0,0 +1,43 @@ +name: 'spotless-apply' +description: 'Run spotlessApply and create PR' +author: 'yuhuyoyo' + +inputs: + reviewers: + description: 'PR reviewers' + required: true + token: + description: 'broadbot token for creating PR' + required: true +outputs: + spotlesscheck: + description: 'success if the code base is spotless and no further action needed' + value: ${{ steps.spotless-check.outcome }} +runs: + using: "composite" + steps: + - name: spotless check + id: spotless-check + run: ./gradlew spotlessCheck + shell: bash + - name: spotless apply + id: spotless-apply + if: failure() && steps.spotless-check.outcome == 'failure' + run: ./gradlew spotlessApply + shell: bash + - name: create PR + id: create-pr + uses: peter-evans/create-pull-request@v4 + if: failure() && steps.spotless-apply.outcome == 'success' + with: + token: ${{ inputs.token }} + commit-message: "Terra CLI spotless apply" + committer: terracli-bot + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + title: "Terra CLI spotless apply" + branch: "actions/spotlessApply" + delete-branch: true + body: | + Run spotlessApply. + *Note: This PR was opened by the [nightly-test GitHub Actions workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).* + reviewers: ${{ inputs.reviewers }} \ No newline at end of file diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index ca8d87a77..b14236cc0 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -3,7 +3,8 @@ on: workflow_dispatch: { } schedule: - cron: '0 5 * * *' # 5AM UTC = 12AM EST - +env: + PR_REVIEWERS: "ddietterich,yuhuyoyo,zloery,mikenev,melissachang" jobs: test-source-and-install: strategy: @@ -23,6 +24,13 @@ jobs: with: java-version: 11 distribution: 'temurin' + - name: Run spotlessApply + id: spotless-apply + if: always() + uses: ./.github/actions/spotless-apply + with: + reviewers: ${{ env.PR_REVIEWERS }} + token: ${{ secrets.BROADBOT_GITHUB_TOKEN }} - name: Cache Gradle packages id: cache_gradle uses: actions/cache@v2 @@ -118,7 +126,8 @@ jobs: L2="Unit: ${{ steps.run_unit_tests.outcome }} " L3="Integ (Source): ${{ steps.run_integration_tests_against_source_code.outcome }} " L4="Integ (Release): ${{ steps.run_integration_tests_against_release.outcome }}" - bold="$L2 | $L3 | $L4" + L5="Lint: ${{ steps.spotless-apply.outputs.spotlesscheck }}" + bold="$L2 | $L3 | $L4 | $L5" text="Link to " if [ "${{ job.status }}" == "success" ]; then text=":white_check_mark: $text" From 8f2f5bc395b923f5726a43d712ac0a2f9b15960a Mon Sep 17 00:00:00 2001 From: yuhuyoyo Date: Tue, 23 Aug 2022 17:30:29 -0400 Subject: [PATCH 2/2] remove reviewer --- .github/actions/spotless-apply/action.yml | 4 ---- .github/workflows/tests-nightly.yml | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/actions/spotless-apply/action.yml b/.github/actions/spotless-apply/action.yml index 91e12e44c..571ee6e8f 100644 --- a/.github/actions/spotless-apply/action.yml +++ b/.github/actions/spotless-apply/action.yml @@ -3,9 +3,6 @@ description: 'Run spotlessApply and create PR' author: 'yuhuyoyo' inputs: - reviewers: - description: 'PR reviewers' - required: true token: description: 'broadbot token for creating PR' required: true @@ -40,4 +37,3 @@ runs: body: | Run spotlessApply. *Note: This PR was opened by the [nightly-test GitHub Actions workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).* - reviewers: ${{ inputs.reviewers }} \ No newline at end of file diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index b14236cc0..40c2c0a12 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -3,8 +3,7 @@ on: workflow_dispatch: { } schedule: - cron: '0 5 * * *' # 5AM UTC = 12AM EST -env: - PR_REVIEWERS: "ddietterich,yuhuyoyo,zloery,mikenev,melissachang" + jobs: test-source-and-install: strategy: @@ -29,7 +28,6 @@ jobs: if: always() uses: ./.github/actions/spotless-apply with: - reviewers: ${{ env.PR_REVIEWERS }} token: ${{ secrets.BROADBOT_GITHUB_TOKEN }} - name: Cache Gradle packages id: cache_gradle