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-with-its-test.yml b/.github/workflows/maven-verify-test.yml similarity index 74% rename from .github/workflows/maven-verify-with-its-test.yml rename to .github/workflows/maven-verify-test.yml index d3833be..5c34b24 100644 --- a/.github/workflows/maven-verify-with-its-test.yml +++ b/.github/workflows/maven-verify-test.yml @@ -15,12 +15,20 @@ # specific language governing permissions and limitations # under the License. -name: Verify +name: Verify - Test 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 + + verify-1: + name: Verify 1 + uses: ./.github/workflows/maven-verify.yml + + verify-2: + name: Verify 2 + uses: ./.github/workflows/maven-verify.yml + with: + ff-goal: test + verify-goal: clean install + verify-fail-fast: false 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..665a30b --- /dev/null +++ b/.github/workflows/maven-verify.yml @@ -0,0 +1,293 @@ +# 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 + + maven_version: + description: The Maven version used for builds + required: false + default: '3.8.7' + 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 + + max-parallel: + description: 'max parallel jobs' + required: false + default: 100 + type: number + + timeout-minutes: + description: 'timeout-minutes used by the builds (defaults to 360)' + required: false + default: 360 + type: number + + jdk-distribution-matrix: + description: "jdk distribution matrix" + required: false + default: '[ "temurin" ]' + type: string + + # 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-jdk: + description: The jdk version used during fail-fast-build job + required: false + default: '11' + type: string + + ff-jdk-distribution: + description: The jdk distribution used during fail-fast-build job + required: false + default: 'temurin' + 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-site-goal: + description: The Maven goal used by verfy jobs to build site + required: false + default: '-DskipTests -P reporting site' + 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 + +# allow single build per branch or PR +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +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 }} + timeout-minutes: ${{ inputs.ff-timeout-minutes }} + # execute on any push or pull request from forked repo + if: inputs.ff-run && ( github.event_name == 'push' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork ) ) + + steps: + - name: Show free disk space + run: df -h + shell: bash + + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up JDK + uses: actions/setup-java@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.1.0:wrapper "-Dmaven=${{ inputs.maven_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@v4 + with: + name: ${{ github.run_number }}-site-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }} + path: | + target/staging/** + + - name: Upload artifact on failure + uses: actions/upload-artifact@v4 + if: failure() && inputs.failure-upload-path != '' + with: + name: ${{ github.run_number }}-failure-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }} + path: ${{ inputs.failure-upload-path }} + + - name: Show free disk space + if: always() + run: df -h + shell: bash + + - name: Clean Ensuring no file handle remains open on windows + run: ./mvnw clean --errors --batch-mode --show-version + + verify: + needs: fail-fast-build + name: ${{ matrix.os }} jdk-${{ matrix.jdk }}-${{ matrix.distribution }} + timeout-minutes: ${{ inputs.timeout-minutes }} + runs-on: ${{ matrix.os }} + if: always() && ( !inputs.ff-run || needs.fail-fast-build.result == 'success' ) + + strategy: + fail-fast: ${{ inputs.verify-fail-fast }} + matrix: + os: ${{ fromJSON( inputs.os-matrix ) }} + jdk: ${{ fromJSON( inputs.jdk-matrix ) }} + distribution: ${{ fromJSON( inputs.jdk-distribution-matrix ) }} + exclude: ${{ fromJSON( inputs.matrix-exclude ) }} + 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.verify-goal != inputs.ff-goal || + inputs.verify-site-goal != inputs.ff-site-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: 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@v4 + with: + persist-credentials: false + + - name: Set up JDK + if: steps.should-run.conclusion == 'success' + uses: actions/setup-java@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.1.0:wrapper "-Dmaven=${{ inputs.maven_version }}" + + - 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@v4 + if: steps.should-run.conclusion == 'success' && failure() && inputs.failure-upload-path != '' + with: + name: ${{ github.run_number }}-failure-${{ matrix.os }}-${{ matrix.jdk }}-${{ matrix.distribution }} + path: ${{ inputs.failure-upload-path }} + + - name: Show free disk space + if: steps.should-run.conclusion == 'success' && always() + 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 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e063da2..bfbcd66 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,12 @@ name: Release Drafter on: - push: - branches: - - main + workflow_call: jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5.15.0 + - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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..76ceeef 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ maven-parent org.apache.maven - 34 + 35 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..852a5d0 --- /dev/null +++ b/src/main/java/org/apache/test/TestApp.java @@ -0,0 +1,51 @@ +package org.apache.test; + +/* + * 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. + */ + +/** + * 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 + } +}