From 482c3d08990fb408a7acec642249f5d41df6da4c Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Wed, 15 Nov 2023 10:30:08 +0800 Subject: [PATCH 1/3] Test auto lint --- .github/workflows/lint-code.yml | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/lint-code.yml diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml new file mode 100644 index 00000000000..00cb8444984 --- /dev/null +++ b/.github/workflows/lint-code.yml @@ -0,0 +1,40 @@ +name: Automatically lint code + +on: [pull_request] + +permissions: + contents: write + +jobs: + lint: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.dubbo-version.outputs.version }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 8 + - uses: actions/cache@v3 + name: "Cache local Maven repository" + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + ${{ runner.os }}-maven- + - name: "Lint with Maven" + run: | + ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast spotless:apply + - name: Check for changes + run: git status + - name: Commit and push files + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Found changes" + git add . + git commit -m "Auto lint styles" + git push + fi + From 93c8c2eb1a8ded844f23cb7b4ffe47582d98cedf Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Wed, 15 Nov 2023 10:31:52 +0800 Subject: [PATCH 2/3] Test auto lint --- .github/workflows/lint-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml index 00cb8444984..7f8b20b4cc8 100644 --- a/.github/workflows/lint-code.yml +++ b/.github/workflows/lint-code.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 8 + java-version: 21 - uses: actions/cache@v3 name: "Cache local Maven repository" with: From fca1c8f7250b5cf0494f778a87a8ec29637d0612 Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Wed, 15 Nov 2023 10:52:58 +0800 Subject: [PATCH 3/3] Test auto lint --- .github/workflows/lint-code.yml | 26 ++++++++++++++------------ pom.xml | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml index 7f8b20b4cc8..7cf702aac36 100644 --- a/.github/workflows/lint-code.yml +++ b/.github/workflows/lint-code.yml @@ -3,7 +3,7 @@ name: Automatically lint code on: [pull_request] permissions: - contents: write + pull-requests: write jobs: lint: @@ -26,15 +26,17 @@ jobs: ${{ runner.os }}-maven- - name: "Lint with Maven" run: | - ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast spotless:apply - - name: Check for changes - run: git status - - name: Commit and push files + ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast spotless:check + - name: "Comment if failure" + if: failure() + env: + GITHUB_URL: ${{ github.event.pull_request.comments_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if [ -n "$(git status --porcelain)" ]; then - echo "Found changes" - git add . - git commit -m "Auto lint styles" - git push - fi - + export JSON_DATA=$(jq --null-input --arg body "Lint failure. Please " '{ "body": $body }') + curl -X POST \ + $GITHUB_URL \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + --data "${JSON_DATA}" + diff --git a/pom.xml b/pom.xml index 3c71f71a239..127beff5a24 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,8 @@ https://github.com/apache/dubbo 2011 + + The Apache Software Foundation http://www.apache.org/