diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74f431ac3..bee23239a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,11 @@ on: branches: - master - develop + - 0.2.x paths-ignore: - - "CHANGELOG" - "**.md" + - "docs/**" + - "**/CHANGELOG" pull_request: types: @@ -15,17 +17,18 @@ on: - synchronize - reopened paths-ignore: - - "CHANGELOG" - "**.md" + - "docs/**" + - "**/CHANGELOG" jobs: build: runs-on: ubuntu-latest strategy: matrix: - java: [8, 9, 11] - # most recent LTS releases and latest stable build - clickhouse: ["19.14", "20.3", "20.8", "latest"] + java: [8, 11] + # most recent LTS releases as well as latest stable builds + clickhouse: ["19.14", "20.3", "20.8", "20.10", "20.12", "21.2", "latest"] name: Build using JDK ${{ matrix.java }} against ClickHouse ${{ matrix.clickhouse }} steps: - name: Check out Git repository diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d13b22284..1f158a1ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: version: description: "Release version" required: true - default: "0.2.6-SNAPSHOT" + default: "0.3.0-SNAPSHOT" jobs: release: @@ -19,13 +19,14 @@ jobs: - name: Install Java and Maven uses: actions/setup-java@v1 with: - java-version: 1.8 - - run: sed -i -e 's|^\( \).*\(\)$|\1${{ github.event.inputs.version }}\2|' pom.xml + java-version: 8 + - run: find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ github.event.inputs.version }}|g' -e 's|${parent.groupId}|tech.clickhouse|g' '{}' \; + - run: find . -type f -name "log4j.properties" -exec sed -i -e 's|DEBUG|WARN|g' '{}' \; - name: Release Maven package uses: samuelmeuli/action-maven-publish@v1 with: maven_profiles: release - maven_args: --batch-mode + maven_args: -q --batch-mode gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} nexus_username: ${{ secrets.SONATYPE_USER }} diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 229a4aeee..f509ff779 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -14,23 +14,126 @@ on: pr: description: "Pull request#" required: false + pull_request: + types: + - opened + - synchronize + - reopened + paths-ignore: + - "**.md" + - "docs/**" + - "**/CHANGELOG" + issue_comment: + types: + - created + - edited jobs: - verify: + verify-commented-pr: runs-on: ubuntu-latest - name: Verify branch/PR using JDK ${{ github.event.inputs.java }} against ClickHouse ${{ github.event.inputs.clickhouse }} + name: Verify commented PR + if: github.event_name == 'issue_comment' && github.event.issue.pull_request steps: + - uses: zhicwu/pull-request-comment-trigger@master + id: check + with: + trigger: '@verify' + reaction: rocket + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + - name: Extra parameters from PR comment + if: steps.check.outputs.triggered == 'true' + uses: actions/github-script@v3 + id: commented + env: + COMMENT_BODY: '${{ github.event.comment.body }}' + with: + script: | + const keyword = '@verify'; + let buildArgs = process.env.COMMENT_BODY; + core.info(`Got commented body: ${buildArgs}`); + buildArgs = buildArgs.substring(buildArgs.lastIndexOf(keyword) + keyword.length); + const args = buildArgs.match(/[^\s]+/g); + core.info(`Got commented arguments: ${args}`); + + return { + pr: context.issue.number, + clickhouse: args && args.length > 0 ? args[0] : "latest", + java: args && args.length > 1 ? args[1] : "8" + }; - name: Check out repository uses: actions/checkout@v2 - if: github.event.inputs.pr == '' - - name: Check out PR ${{ github.event.inputs.pr }} + - name: Check out commented PR + if: steps.check.outputs.triggered == 'true' + run: | + git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin pull/${{ fromJSON(steps.commented.outputs.result).pr }}/merge:merged-pr && git checkout merged-pr + - name: Set up JDK + if: steps.check.outputs.triggered == 'true' + uses: actions/setup-java@v1 + with: + java-version: ${{ fromJSON(steps.commented.outputs.result).java }} + continue-on-error: true + - name: Verify with Maven + if: steps.check.outputs.triggered == 'true' + run: mvn --batch-mode --update-snapshots -DclickhouseVersion=${{ fromJSON(steps.commented.outputs.result).clickhouse }} verify + id: maven + continue-on-error: true + - name: Comment PR + uses: actions/github-script@v3 + if: steps.check.outputs.triggered == 'true' + env: + CLICKHOUSE_VRESION: ${{ fromJSON(steps.commented.outputs.result).clickhouse }} + JAVA_VERSION: ${{ fromJSON(steps.commented.outputs.result).java }} + PREV_STEP_RESULT: '${{ steps.maven.outcome }}' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { issue: { number: issue_number }, repo: { owner, repo } } = context; + const result = process.env.PREV_STEP_RESULT; + const buildUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`; + const flag = result === 'success' + ? ':green_circle:' + : (result === 'failure' ? ':red_circle:' : ':yellow_circle:'); + const msg = `${flag} verify using JDK [${process.env.JAVA_VERSION}] and ClickHouse [${process.env.CLICKHOUSE_VRESION}]: [${result}](${buildUrl})`; + github.issues.createComment({ issue_number, owner, repo, body: msg }); + + verify-on-demand: + runs-on: ubuntu-latest + name: Verify on demand + if: github.event_name == 'workflow_dispatch' + steps: + - name: Check out repository uses: actions/checkout@v2 + - name: Check out PR + run: | + git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr if: github.event.inputs.pr != '' - with: - ref: refs/remotes/pull/${{ github.event.inputs.pr }}/merge - name: Set up JDK ${{ github.event.inputs.java }} uses: actions/setup-java@v1 with: java-version: ${{ github.event.inputs.java }} + continue-on-error: true - name: Verify with Maven run: mvn --batch-mode --update-snapshots -DclickhouseVersion=${{ github.event.inputs.clickhouse }} verify + id: maven + continue-on-error: true + - name: 'Comment PR' + uses: actions/github-script@v3 + if: github.event.inputs.pr != '' + env: + PR_NO: ${{ github.event.inputs.pr }} + CLICKHOUSE_VRESION: ${{ github.event.inputs.clickhouse }} + JAVA_VERSION: ${{ github.event.inputs.java }} + PREV_STEP_RESULT: '${{ steps.maven.outcome }}' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue_number = process.env.PR_NO; + const { repo: { owner, repo } } = context; + const result = process.env.PREV_STEP_RESULT; + const buildUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`; + const flag = result === 'success' + ? ':green_circle:' + : (result === 'failure' ? ':red_circle:' : ':yellow_circle:'); + const msg = `${flag} verify using JDK [${process.env.JAVA_VERSION}] and ClickHouse [${process.env.CLICKHOUSE_VRESION}]: [${result}](${buildUrl})`; + github.issues.createComment({ issue_number, owner, repo, body: msg });