diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 601ccb1da..822dab705 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,6 +1,7 @@ # -# Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2019, 2024, Datadog, Inc. All rights reserved. +# Copyright (c) 2022, 2026 SAP SE. All rights reserved. # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # @@ -42,17 +43,18 @@ concurrency: jobs: check_copyright_year: + name: Check Copyright Years runs-on: 'ubuntu-latest' defaults: run: shell: bash steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: fetch-depth: 0 - name : Check latest copyright year - run: ./scripts/checkcopyrightyear.sh + run: ./scripts/checkcopyrightyear.sh https://github.com/SAP/jmc.git sap build_and_test: name: Build and Test on ${{ matrix.os }} strategy: @@ -68,27 +70,27 @@ jobs: MAVENPARAMS: --batch-mode --no-transfer-progress steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up Java 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: sapmachine java-version: '17' java-package: jdk mvn-toolchain-id: 'JavaSE-17' - name: Set up Java 21 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: sapmachine java-version: '21' java-package: jdk mvn-toolchain-id: 'JavaSE-21' - name: Set up Maven - uses: stCarolas/setup-maven@v4.5 + uses: stCarolas/setup-maven@v5 with: maven-version: 3.9.8 - name: Cache local Maven repository - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} diff --git a/scripts/checkcopyrightyear.sh b/scripts/checkcopyrightyear.sh index cc4c8700c..7c9bd811b 100755 --- a/scripts/checkcopyrightyear.sh +++ b/scripts/checkcopyrightyear.sh @@ -1,11 +1,47 @@ #!/usr/bin/env bash +# +# Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2026, Red Hat Inc. All rights reserved. +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# The contents of this file are subject to the terms of either the Universal Permissive License +# v 1.0 as shown at https://oss.oracle.com/licenses/upl +# +# or the following license: +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided with +# the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used to +# endorse or promote products derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +# WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +UPSTREAM_URL=${1:-https://github.com/SAP/jmc.git} +UPSTREAM_BRANCH=${2:-sap} # set remote for upstream repository -git remote -v | grep -w upstream || git remote add upstream https://github.com/SAP/jmc.git +git remote -v | grep -w upstream || git remote add upstream "$UPSTREAM_URL" git fetch upstream CURRENT_YEAR=$(date +'%Y') -COMMITTED_FILES=$(git diff --name-only --diff-filter=d upstream/sap...HEAD) +COMMITTED_FILES=$(git diff --name-only --diff-filter=d "upstream/${UPSTREAM_BRANCH}...HEAD") UNCOMMITTED_FILES=$(git diff --name-only --diff-filter=d) MODIFIED_FILES=$(echo -e "$COMMITTED_FILES\n$UNCOMMITTED_FILES" | sort -u | grep -v '^$') counter=0 @@ -26,13 +62,13 @@ do done if [ $counter -ne 0 ] then - # check if the PR branch is up-to-date with upstream/sap + # check if the PR branch is up-to-date with upstream/master # borrowed from: https://stackoverflow.com/a/39402294 - if git merge-base --is-ancestor upstream/sap @ + if git merge-base --is-ancestor "upstream/${UPSTREAM_BRANCH}" @ then echo "Branch is up-to-date." else - echo "Branch is out of date with upstream/sap. Please rebase your branch and try again." + echo "Branch is out of date with upstream/${UPSTREAM_BRANCH}. Please rebase your branch and try again." exit 1 fi echo "There is a total of $counter copyright year(s) that require updating."