diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 3b06870..0000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter -name-template: $NEXT_PATCH_VERSION -tag-template: $NEXT_PATCH_VERSION -version-template: $MAJOR.$MINOR.$PATCH - -# Emoji reference: https://gitmoji.carloscuesta.me/ -categories: - - title: ":boom: Breaking changes" - labels: - - breaking - - title: 🚨 Removed - label: removed - - title: ":tada: Major features and improvements" - labels: - - major-enhancement - - major-rfe - - title: 🐛 Major bug fixes - labels: - - major-bug - - title: ⚠️ Deprecated - label: deprecated - - title: 🚀 New features and improvements - labels: - - enhancement - - feature - - rfe - - title: 🐛 Bug Fixes - labels: - - bug - - fix - - bugfix - - regression - - title: ":construction_worker: Changes for plugin developers" - labels: - - developer - # Default label used by Dependabot - - title: 📦 Dependency updates - label: dependencies - - title: 📝 Documentation updates - label: documentation - - title: 👻 Maintenance - labels: - - chore - - internal - - maintenance - - title: 🚦 Tests - labels: - - test - - tests -exclude-labels: - - reverted - - no-changelog - - skip-changelog - - invalid - -template: | - - $CHANGES diff --git a/.github/workflows/maven-verify-test.yml b/.github/workflows/maven-verify-test.yml new file mode 100644 index 0000000..af15cae --- /dev/null +++ b/.github/workflows/maven-verify-test.yml @@ -0,0 +1,76 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Verify - Test + +on: [ push, pull_request ] + +jobs: + + # default config + verify-1: + name: Verify 1 + uses: ./.github/workflows/maven-verify.yml + + # override fail fast config + verify-2: + name: Verify 2 - fail fast config + uses: ./.github/workflows/maven-verify.yml + needs: verify-1 + with: + ff-site-run: false + ff-goal: test + ff-jdk: '21' + verify-goal: clean install + verify-fail-fast: false + maven-matrix: '[ "3.9.11", "3.8.9", "3.6.3" ]' + + # test with Maven 4 + verify-3: + name: Verify 3 - with Maven 4 + uses: ./.github/workflows/maven-verify.yml + needs: verify-2 + with: + maven4-enabled: true + ff-site-run: false + + # test with Maven 4 without fail fast job + verify-4: + name: Verify 4 - with Maven 4 - no ff job + uses: ./.github/workflows/maven-verify.yml + needs: verify-3 + with: + maven4-enabled: true + ff-run: false + + # test only fail fast job + verify-5: + name: Verify 5 - disable matrix build + uses: ./.github/workflows/maven-verify.yml + needs: verify-4 + with: + ff-site-run: false + matrix-enabled: false + + # test only Maven 4 + verify-6: + name: Verify 6 - Maven4 build + uses: ./.github/workflows/maven-verify.yml + needs: verify-5 + with: + maven4-build: true + ff-site-run: false diff --git a/.github/workflows/maven-verify-with-its-test.yml b/.github/workflows/maven-verify-with-its-test.yml deleted file mode 100644 index d3833be..0000000 --- a/.github/workflows/maven-verify-with-its-test.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Verify - -on: push - -jobs: - build: - name: Verify - # for testing purpose you can change to your fork and branch - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify-with-its.yml@main diff --git a/.github/workflows/maven-verify-with-its.yml b/.github/workflows/maven-verify-with-its.yml deleted file mode 100644 index e6e147e..0000000 --- a/.github/workflows/maven-verify-with-its.yml +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Verify - -on: - workflow_call: - inputs: - maven_args: - description: The arguments to pass to Maven when building the code - required: false - default: -P run-its -D"invoker.streamLogsOnFailures" - type: string - - os-matrix: - description: 'os matrix as json array' - required: false - default: '[ "ubuntu-latest", "windows-latest", "macOS-latest" ]' - type: string - - jdk-matrix: - description: 'jdk matrix as json array' - required: false - default: '[ "8", "11", "17" ]' - type: string - - matrix-exclude: - description: 'exclude for matrix as json' - required: false - default: '[]' - type: string - - jdk-distribution-matrix: - description: "jdk distribution matrix" - required: false - default: '[ "temurin" ]' - type: string - - # fail fast job setup - ff-os: - description: The os used during fail-fast-build job - required: false - default: 'ubuntu-latest' - type: string - - ff-jdk: - description: The jdk version used during fail-fast-build job - required: false - default: '8' - type: string - - ff-jdk-distribution: - description: The jdk distribution used during fail-fast-build job - required: false - default: 'temurin' - type: string - -jobs: - - # verify build on one node - before matrix will start - fail-fast-build: - name: ${{ inputs.ff-os }} jdk-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }} - runs-on: ${{ inputs.ff-os }} - - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Set up JDK - uses: actions/setup-java@v2.3.1 - with: - java-version: ${{ inputs.ff-jdk }} - distribution: ${{ inputs.ff-jdk-distribution }} - cache: 'maven' - - - name: Build with Maven - run: mvn --errors --batch-mode --show-version ${{ inputs.maven_args }} verify - - verify: - needs: fail-fast-build - name: ${{ matrix.os }} jdk-${{ matrix.jdk }}-${{ matrix.distribution }} - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: ${{ fromJSON( inputs.os-matrix ) }} - jdk: ${{ fromJSON( inputs.jdk-matrix ) }} - distribution: ${{ fromJSON( inputs.jdk-distribution-matrix ) }} - exclude: ${{ fromJSON( inputs.matrix-exclude ) }} - - steps: - - name: Should run - id: should-run - if: > - matrix.os != inputs.ff-os || - matrix.jdk != inputs.ff-jdk || - matrix.distribution != inputs.ff-jdk-distribution - run: echo ok - - - name: Checkout - if: steps.should-run.conclusion == 'success' - uses: actions/checkout@v2.3.4 - - - name: Set up JDK - if: steps.should-run.conclusion == 'success' - uses: actions/setup-java@v2.3.1 - with: - java-version: ${{ matrix.jdk }} - distribution: ${{ matrix.distribution }} - cache: 'maven' - - - name: Build with Maven - if: steps.should-run.conclusion == 'success' - run: mvn --errors --batch-mode --show-version ${{ inputs.maven_args }} verify - - - name: Build Maven Site - if: steps.should-run.conclusion == 'success' - run: mvn --errors --batch-mode --show-version ${{ inputs.maven_args }} site diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml new file mode 100644 index 0000000..ee486ae --- /dev/null +++ b/.github/workflows/maven-verify.yml @@ -0,0 +1,440 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Verify + +on: + workflow_call: + inputs: + maven-args: + description: The arguments to pass to all Maven commands when building the code + required: false + default: '-D"invoker.streamLogsOnFailures"' + type: string + + os-matrix: + description: os matrix as json array + required: false + default: '[ "ubuntu-latest", "windows-latest", "macos-latest" ]' + type: string + + jdk-matrix: + description: jdk matrix as json array + required: false + default: '[ "17", "21", "8" ]' + type: string + + jdk-distribution-matrix: + description: jdk distribution matrix + required: false + default: '[ "zulu" ]' + type: string + + maven-matrix: + description: The Maven version matrix as json array + required: false + default: '[ "3.6.3", "3.9.11" ]' + type: string + + maven4-version: + description: The Maven 4.x version matrix + required: false + default: '4.0.0-rc-4' + type: string + + maven4-enabled: + description: Determinate if use Maven 4 in build matrix + required: false + default: false + type: boolean + + maven4-build: + description: Determinate if use only Maven 4 in all builds + required: false + default: false + type: boolean + + matrix-include: + description: include for matrix as json + required: false + default: '[]' + type: string + + matrix-exclude: + description: exclude for matrix as json + required: false + default: '[]' + type: string + + matrix-enabled: + description: Determinate if use matrix build + required: false + default: true + type: boolean + + max-parallel: + description: max parallel jobs + required: false + default: 20 + type: number + + timeout-minutes: + description: timeout-minutes used by the builds (defaults to 360) + required: false + default: 360 + type: number + + # fail fast job setup + ff-run: + description: Determines should fail-fast-build run at all + required: false + default: true + type: boolean + + ff-os: + description: The os used during fail-fast-build job + required: false + default: 'ubuntu-latest' + type: string + + ff-maven: + description: The Maven version used during fail-fast-build job + required: false + default: '3.9.11' + type: string + + ff-jdk: + description: The jdk version used during fail-fast-build job + required: false + default: '17' + type: string + + ff-jdk-distribution: + description: The jdk distribution used during fail-fast-build job + required: false + default: 'zulu' + type: string + + ff-goal: + description: The Maven goal used by fail-fast-build job + required: false + default: '-P run-its verify' + type: string + + ff-site-run: + description: Determines should fail-fast-build run site step + required: false + default: true + type: boolean + + ff-site-goal: + description: The Maven goal used by fail-fast-build job to build site + required: false + default: '-DskipTests -P reporting site site:stage' + type: string + + ff-timeout-minutes: + description: timeout-minutes used by fail-fast-build jobs (defaults to 360) + required: false + default: 360 + type: number + + verify-goal: + description: The Maven goal used by verfy jobs + required: false + default: '-P run-its verify' + type: string + + verify-fail-fast: + description: Determinate if verification matrix should fail fast + required: false + default: true + type: boolean + + failure-upload-path: + description: A file, directory or wildcard pattern that describes what to upload on failure + required: false + type: string + + install-mercurial: + description: Ensure all build images have Mercurial(hg) installed + required: false + default: false + type: boolean + + install-subversion: + description: Ensure all build images have Subversion(svn) installed + required: false + default: false + type: boolean + + install-gpg: + description: Ensure all build images have GnuPG installed + required: false + default: false + type: boolean + +# allow single build per branch or PR +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# clare all permissions for GITHUB_TOKEN +permissions: {} + +jobs: + + setup-maven-version: + runs-on: "ubuntu-latest" + # execute on any push or pull request from forked repo, skip release commit + if: > + (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)) && + !startsWith(github.event.head_commit.message , '[maven-release-plugin] prepare release') + outputs: + version: ${{ steps.version.outputs.version }} + maven-matrix: ${{ steps.maven.outputs.matrix }} + exclude-matrix: ${{ steps.exclude.outputs.matrix }} + + steps: + - id: version + name: setup Maven version for ff + run: | + if [ "${{ inputs.maven4-build }}" = "true" ]; then + echo "version=${{ inputs.maven4-version }}" >> $GITHUB_OUTPUT + else + echo "version=${{ inputs.ff-maven }}" >> $GITHUB_OUTPUT + fi + cat $GITHUB_OUTPUT + + - id: maven + name: setup Maven matrix + run: | + { + echo 'matrix<> "$GITHUB_OUTPUT" + + cat "$GITHUB_OUTPUT" + + - id: exclude + name: setup exclude matrix + run: | + { + echo 'matrix<> "$GITHUB_OUTPUT" + + cat "$GITHUB_OUTPUT" + + # verify build on one node - before matrix will start + fail-fast-build: + name: ${{ inputs.ff-os }} jdk-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }} ${{ needs.setup-maven-version.outputs.version }} + runs-on: ${{ inputs.ff-os }} + timeout-minutes: ${{ inputs.ff-timeout-minutes }} + needs: setup-maven-version + if: inputs.ff-run + + steps: + - name: Install Subversion on Ubuntu + if: inputs.install-subversion && runner.os == 'Linux' + run: sudo apt install subversion + + - name: Install Subversion on MacOS + if: inputs.install-subversion && runner.os == 'MacOS' + run: brew install subversion + + - name: Show free disk space + run: df -h + shell: bash + + - name: Checkout + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4 + with: + persist-credentials: false + + - name: Set up JDK + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v4 + with: + java-version: ${{ inputs.ff-jdk }} + distribution: ${{ inputs.ff-jdk-distribution }} + cache: 'maven' + + - name: Set up Maven + run: + mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.3:wrapper "-Dmaven=${{ needs.setup-maven-version.outputs.version }}" + + - name: Build with Maven + run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.ff-goal }} + + - name: Build Maven Site + run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.ff-site-goal }} + if: inputs.ff-site-run + + - name: Upload Maven Site + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + if: inputs.ff-site-run + with: + name: ${{ github.run_number }}-site-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }}-${{ needs.setup-maven-version.outputs.version }} + path: | + target/staging/** + + - name: Upload artifact on failure + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + if: failure() && inputs.failure-upload-path != '' + with: + name: ${{ github.run_number }}-failure-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }}-${{ needs.setup-maven-version.outputs.version }} + path: ${{ inputs.failure-upload-path }} + + - name: Show free disk space + if: (!cancelled()) + run: df -h + shell: bash + + - name: Clean Ensuring no file handle remains open on windows + run: ./mvnw clean --errors --batch-mode --show-version "-Dmaven.clean.retryOnError" + + verify: + if: > + (!cancelled()) && inputs.matrix-enabled && ( !inputs.ff-run || needs.fail-fast-build.result == 'success' ) && + !startsWith(github.event.head_commit.message , '[maven-release-plugin] prepare release') + needs: [setup-maven-version, fail-fast-build] + name: ${{ matrix.os }} jdk-${{ matrix.jdk }}-${{ matrix.distribution }} ${{ matrix.maven }} + timeout-minutes: ${{ inputs.timeout-minutes }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: ${{ inputs.verify-fail-fast }} + matrix: + os: ${{ fromJSON( inputs.os-matrix ) }} + jdk: ${{ fromJSON( inputs.jdk-matrix ) }} + distribution: ${{ fromJSON( inputs.jdk-distribution-matrix ) }} + maven: ${{ fromJSON( needs.setup-maven-version.outputs.maven-matrix ) }} + include: ${{ fromJSON( inputs.matrix-include ) }} + exclude: ${{ fromJSON( needs.setup-maven-version.outputs.exclude-matrix ) }} + max-parallel: ${{ inputs.max-parallel }} + + steps: + - name: Should run + id: should-run + if: > + matrix.os != inputs.ff-os || + matrix.jdk != inputs.ff-jdk || + matrix.distribution != inputs.ff-jdk-distribution || + (!inputs.maven4-build && matrix.maven != inputs.ff-maven) || + (inputs.maven4-build && matrix.maven != inputs.maven4-version) || + inputs.verify-goal != inputs.ff-goal + run: echo ok + + # Some projects (like Maven SCM) need the command-line tools for all SCMs installed. + # Git and Subversion are installed on all by default. + # Mercurial is not installed on macOS. + # https://docs.github.com/en/actions/using-github-hosted-runners/customizing-github-hosted-runners#installing-software-on-macos-runners + - name: Install Mercurial (hg) on macOS + if: > + inputs.install-mercurial && + steps.should-run.conclusion == 'success' && + matrix.os == 'macos-latest' + run: | + brew install mercurial + + - name: Install Subversion on Ubuntu + if: > + inputs.install-subversion && + steps.should-run.conclusion == 'success' && + runner.os == 'Linux' + run: | + sudo apt install subversion + + - name: Install Subversion on MacOS + if: > + inputs.install-subversion && + steps.should-run.conclusion == 'success' && + runner.os == 'MacOS' + run: | + brew install subversion + + - name: Install GnuPG + if: > + inputs.install-gpg && + steps.should-run.conclusion == 'success' && + matrix.os == 'windows-latest' + run: | + $env:PATH = "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin" + [Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine") + choco install --yes gpg4win + echo "C:\Program Files (x86)\Gpg4win\..\GnuPG\bin" >> $env:GITHUB_PATH + + - name: Check GnuPG + if: > + inputs.install-gpg && + steps.should-run.conclusion == 'success' + run: gpg --version + + - name: Show free disk space + if: steps.should-run.conclusion == 'success' + run: df -h + shell: bash + + - name: Checkout + if: steps.should-run.conclusion == 'success' + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4 + with: + persist-credentials: false + + - name: Set up JDK + if: steps.should-run.conclusion == 'success' + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v4 + with: + java-version: ${{ matrix.jdk }} + distribution: ${{ matrix.distribution }} + cache: 'maven' + + - name: Set up Maven + if: steps.should-run.conclusion == 'success' + run: mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.3:wrapper "-Dmaven=${{ matrix.maven }}" + + - name: Build with Maven + if: steps.should-run.conclusion == 'success' + run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.verify-goal }} + + - name: Upload artifact on failure + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + if: steps.should-run.conclusion == 'success' && failure() && inputs.failure-upload-path != '' + with: + name: ${{ github.run_number }}-failure-${{ matrix.os }}-${{ matrix.jdk }}-${{ matrix.distribution }}-${{ matrix.maven }} + path: ${{ inputs.failure-upload-path }} + + - name: Show free disk space + if: steps.should-run.conclusion == 'success' && !cancelled() + run: df -h + shell: bash + + - name: Clean Ensuring no file handle remains open on windows + if: steps.should-run.conclusion == 'success' + run: ./mvnw clean --errors --batch-mode --show-version "-Dmaven.clean.retryOnError" diff --git a/.github/workflows/pr-automation.yml b/.github/workflows/pr-automation.yml new file mode 100644 index 0000000..0df833c --- /dev/null +++ b/.github/workflows/pr-automation.yml @@ -0,0 +1,195 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: PR Automation +on: + workflow_call: + inputs: + default-label: + description: The default label to add to PR + required: false + default: 'maintenance' + type: string + +# allow single build per branch or PR +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }} + cancel-in-progress: false + +# clare all permissions for GITHUB_TOKEN +permissions: {} + +jobs: + # dump GitHub context only when the workflow is re runed, + # can help investigate problems + dump-github-context: + runs-on: ubuntu-latest + if: github.run_attempt > 1 + + steps: + - run: echo "ok" + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + shell: bash + + # check PR milestone - if not set - update with current opened milestone + milestone: + permissions: + issues: write + pull-requests: write + + if: > + github.event.action == 'closed' && + github.event.pull_request.merged && + !github.event.pull_request.milestone && + !contains(github.event.pull_request.labels.*.name, 'skip-changelog') + runs-on: ubuntu-latest + steps: + - name: Update milestone + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const milestones = await github.rest.issues.listMilestones({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + console.log(milestones); + const branch = context.payload.pull_request.base.ref + + if (milestones.data.length == 0) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '@' + context.payload.pull_request.merged_by.login + + ' The PR can\'t be associated to a milestone, because there is no open milestone. Please create a new milestone before merge.' + }); + throw new Error('The PR can\'t be associated to a milestone, because there is no open milestone. Please create a new milestone before merge.') + } + + var milestone; + if (milestones.data.length > 1) { + milestone = milestones.data.find(({description}) => description?.includes('branch: ' + branch)); + if (!milestone) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '@' + context.payload.pull_request.merged_by.login + + ' The PR can\'t be associated to a milestone, because there are multiple open milestones. Please add the text "branch: ' + branch + '" to the description to the milestone where this PR belongs to.' + }); + throw new Error('The PR can\'t be associated to a milestone, because there are multiple open milestones. Please add the text "branch: ' + branch + '" to the description to the milestone where this PR belongs to.'); + } + } else { + milestone = milestones.data[0]; + } + + console.log('Set milestone to: ' + milestone.title); + + const result = await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + milestone: milestone.number + }); + + console.log(result); + + # check PR milestone - remove for not merged PR or with skip-changelog label + milestone-rm: + permissions: + issues: write + pull-requests: write + + if: > + github.event.action == 'closed' && + (!github.event.pull_request.merged || contains(github.event.pull_request.labels.*.name, 'skip-changelog')) && + github.event.pull_request.milestone + runs-on: ubuntu-latest + steps: + - name: Remove milestone + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + + const result = await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + milestone: null + }); + + console.log(result); + + # check PR labels - if is empty list add one default + labels: + permissions: + issues: write + pull-requests: write + + if: > + github.event.action == 'closed' && + github.event.pull_request.merged && + toJSON(github.event.pull_request.labels) == '[]' + runs-on: ubuntu-latest + steps: + - name: Comment PR + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '@' + context.payload.pull_request.merged_by.login + + ' Please assign appropriate label to PR according to the type of change.' + }); + + throw new Error('PRs must be labeled'); + + # check PR assignee - if no one is assigned, assign to person who merge PR + assignees: + permissions: + issues: write + pull-requests: write + + if: > + github.event.action == 'closed' && + github.event.pull_request.merged && + toJSON(github.event.pull_request.assignees) == '[]' + runs-on: ubuntu-latest + steps: + + - name: Assign PR + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + + console.log(context.payload.pull_request); + console.log(context.payload.pull_request.merged_by); + + const result = await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + assignees: [ context.payload.pull_request.merged_by.login ] + }); + + console.log(result); diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e063da2..40863e8 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,3 +1,5 @@ + + # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -17,14 +19,82 @@ name: Release Drafter on: - push: - branches: - - main + workflow_call: + inputs: + config-name: + description: | + If your workflow requires multiple release-drafter configs it be helpful to override the config-name. + The config should still be located inside `.github` as that's where we are looking for config files. + required: false + type: string + default: 'release-drafter.yml' + commits-since: + description: | + A date in ISO format marking the initial commit for the release draft. This is applied only when no prior release is available. + required: false + type: string + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false jobs: + detect-version: + # skip release drafter on releases commits + if: (!startsWith(github.event.head_commit.message , '[maven-release-plugin] prepare for next development iteration')) + + name: Detect version + runs-on: ubuntu-latest + permissions: {} + outputs: + version: ${{ steps.version.outputs.version }} + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4 + with: + persist-credentials: 'false' + + - id: has-pom + run: | + if [ -f pom.xml ]; then + echo "status=true" >> $GITHUB_OUTPUT + fi + cat $GITHUB_OUTPUT + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v4 + if: steps.has-pom.outputs.status == 'true' + with: + java-version: '21' + distribution: 'zulu' + cache: 'maven' + + - id: version + if: steps.has-pom.outputs.status == 'true' + run: | + mvn --batch-mode --non-recursive help:evaluate -Dexpression=project.version -Doutput=target/version.txt + V=$(cat target/version.txt) + echo "version=${V%-SNAPSHOT}" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + update_release_draft: + name: Update Release Draft + needs: detect-version + permissions: + # write permission is required to create a github release + contents: write runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5.15.0 + - uses: apache/maven-gh-actions-shared@release-drafter # temporary copy of the release-drafter action + id: release-drafter + with: + config-name: ${{ inputs.config-name }} + version: ${{ needs.detect-version.outputs.version }} + commitish: ${{ github.ref }} + commits-since: ${{ inputs.commits-since }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Verify release drafter status + if: steps.release-drafter.outputs.id == '' + run: exit 1 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..0e56595 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,89 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# https://github.com/actions/stale + +name: Stale + +on: + workflow_call: + +permissions: + issues: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.issue.number }} + cancel-in-progress: false + +jobs: + stale-waiting-for-feedback: + if: github.event_name == 'schedule' + name: 'Manage issues, PRs with waiting-for-feedback label' + runs-on: ubuntu-latest + + steps: + - uses: actions/stale@3a9db7e6a41a89f618792c92c0e97cc736e1b13f # v10 + with: + days-before-stale: '60' + days-before-close: '30' + stale-issue-message: 'This issue is stale because it has been waiting for feedback for 60 days. Remove the stale label or comment on this issue, or it will be automatically closed in 30 days.' + close-issue-message: 'This issue has been closed because no response was received within 90 days.' + stale-pr-message: 'This pull request is stale because it has been waiting for feedback for 60 days. Remove the stale label or comment on this PR, or it will be automatically closed in 30 days.' + close-pr-message: 'This pull request has been closed because no response was received within 90 days.' + any-of-labels: 'waiting-for-feedback' + exempt-all-milestones: 'true' + exempt-issue-labels: 'priority:blocker,priority:critical' + exempt-pr-labels: 'priority:blocker,priority:critical' + + remove-labels: + if: > + github.event_name == 'issue_comment' && github.event.action == 'created' && + (contains(github.event.issue.labels.*.name, 'waiting-for-feedback') || contains(github.event.issue.labels.*.name, 'Stale')) + name: 'Remove waiting-for-feedback label' + runs-on: ubuntu-latest + + steps: + - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + name: Remove waiting-for-feedback + if: contains(github.event.issue.labels.*.name, 'waiting-for-feedback') + with: + script: | + + const result = await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'waiting-for-feedback' + }); + + console.log(result); + + - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + name: Remove Stale + if: contains(github.event.issue.labels.*.name, 'Stale') + with: + script: | + + const result = await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'Stale' + }); + + console.log(result); diff --git a/README.md b/README.md index d3c5035..de6909d 100644 --- a/README.md +++ b/README.md @@ -14,44 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -# Apache Maven shared GitHub Actions - +# Apache Maven Shared GitHub Actions # Usage -Create GitHub workflow in project with content: - -```yaml -name: Verify - -on: - push: - branches-ignore: - - dependabot/** - pull_request: - -jobs: - build: - name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify-with-its.yml@main - -``` - -Excludes from build matrix: - -```yaml -... - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify-with-its.yml@main - with: - matrix-exclude: > - [ - {"jdk": "8"}, # exclude jdk 8 from all builds - {"os": "windows-latest"}, # exclude windows from all builds - {"jdk": "8", "os": "windows-latest"} # exclude jkd 8 on windows - ] -``` - -# Resources - -- [Workflow syntax](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions) -- [Reusing workflows](https://docs.github.com/en/actions/learn-github-actions/reusing-workflows) +https://github.com/apache/maven-gh-actions-shared/ diff --git a/pom.xml b/pom.xml index 454cc8e..945cdf8 100644 --- a/pom.xml +++ b/pom.xml @@ -17,17 +17,15 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + 4.0.0 - - maven-parent - org.apache.maven - 34 - - + + org.apache.maven + maven-parent + 44 + + test test @@ -42,13 +40,19 @@ maven-help-plugin - initialize system + initialize + + + + run-its + + diff --git a/src/main/java/org/apache/test/TestApp.java b/src/main/java/org/apache/test/TestApp.java new file mode 100644 index 0000000..52afbf8 --- /dev/null +++ b/src/main/java/org/apache/test/TestApp.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.test; + +/** + * Test app + */ +public class TestApp { + + public static void main(String[] args) { + m1(); + m2(); + } + + /** + * FIXME in javadoc + */ + private static void m1() { + System.out.println("Hello"); + } + + private static void m2() { + System.out.println("Hello"); + } + + private static void m3() { + // TODO test tag + } +}