diff --git a/.github/workflows/all-tests.yml b/.github/workflows/all-tests.yml index 68c9ff90..8241db95 100644 --- a/.github/workflows/all-tests.yml +++ b/.github/workflows/all-tests.yml @@ -24,32 +24,50 @@ jobs: # check path to bundled Maven executable; it should be then used in ATLAS_MVN - run: mvn -version + prepare: + name: Prepare Matrix + runs-on: ubuntu-latest + outputs: + unit-tests-matrix: ${{ steps.set-matrix.outputs.unit-tests-matrix }} + jira-it-matrix: ${{ steps.set-matrix.outputs.jira-it-matrix }} + confluence-it-matrix: ${{ steps.set-matrix.outputs.confluence-it-matrix }} + bitbucket-it-matrix: ${{ steps.set-matrix.outputs.bitbucket-it-matrix }} + # TODO: Remove these flags when new major jira (10.x) and bitbucket (9.x) are released + skip-jira-its: ${{ steps.set-matrix.outputs.skip-jira-its }} + skip-bitbucket-its: ${{ steps.set-matrix.outputs.skip-bitbucket-its }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + - id: set-matrix + run: bin/build/prepare-matrices.sh + unit-tests: name: Unit Tests + needs: prepare runs-on: ubuntu-20.04 # around 800 Mb of dependencies need to be loaded; it may take long first time until it's cached timeout-minutes: 30 if: "(github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'unit-tests')) && !contains(github.event.head_commit.message, '[skip ci]')" strategy: - matrix: - java-version: [8, 11] + matrix: ${{ fromJSON(needs.prepare.outputs.unit-tests-matrix) }} fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ref }} - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} distribution: adopt - run: bin/build/install-plugin-sdk.sh - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository key: maven-unit - run: bin/build/override-plugin-sdk-maven.sh - run: bin/build/run-unit-tests.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: unit-tests-coverage-java-${{ matrix.java-version }} path: '**/target/site/jacoco/**' @@ -58,39 +76,33 @@ jobs: name: Jira runs-on: ubuntu-20.04 timeout-minutes: 30 - if: github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-jira') - needs: unit-tests + if: (github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-jira')) && !needs.prepare.outputs.skip-jira-its + needs: [prepare, unit-tests] strategy: - matrix: - java-version: [8, 11, 17] - jira-version: [8.15.0, 9.5.0] - # Java 17 support is added only since Jira 9.5: https://confluence.atlassian.com/jiracore/preparing-for-jira-9-5-1167834011.html - exclude: - - java-version: 17 - jira-version: 8.15.0 + matrix: ${{ fromJSON(needs.prepare.outputs.jira-it-matrix) }} fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ref }} - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} distribution: adopt - run: bin/build/install-plugin-sdk.sh - run: bin/build/override-plugin-sdk-maven.sh - run: bin/build/install-int-test-libs.sh - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository key: maven-unit - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository/com/atlassian/jira key: maven-integration-jira-${{ matrix.jira-version }} - run: bin/build/install-common-modules.sh - run: VERSION=${{ matrix.jira-version }} bin/build/run-jira-its.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: name: webdriver-screenshots-jira-${{ matrix.jira-version }} @@ -101,40 +113,32 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 30 if: github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-confluence') - needs: unit-tests + needs: [prepare, unit-tests] strategy: - matrix: - # every version part should be 0 <= <= 255; otherwise Confluence fails to start - java-version: [8, 11, 17] - confluence-version: [7.10.0, 8.0.0] - exclude: - - java-version: 8 - confluence-version: 8.0.0 # Confluence 8 doesn't support Java 8 anymore - - java-version: 17 - confluence-version: 7.10.0 + matrix: ${{ fromJSON(needs.prepare.outputs.confluence-it-matrix) }} fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ref }} - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} distribution: adopt - run: bin/build/install-plugin-sdk.sh - run: bin/build/override-plugin-sdk-maven.sh - run: bin/build/install-int-test-libs.sh - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository key: maven-unit - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository/com/atlassian/confluence key: maven-integration-confluence-${{ matrix.confluence-version }} - run: bin/build/install-common-modules.sh - run: VERSION=${{ matrix.confluence-version }} bin/build/run-confluence-its.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: name: webdriver-screenshots-confluence-${{ matrix.confluence-version }}-java-${{ matrix.java-version }} @@ -144,19 +148,13 @@ jobs: name: Bitbucket runs-on: ubuntu-20.04 timeout-minutes: 30 - if: github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-bitbucket') - needs: unit-tests + if: (github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-bitbucket')) && !needs.prepare.outputs.skip-bitbucket-its + needs: [prepare, unit-tests] strategy: - matrix: - java-version: [8, 11, 17] - bitbucket-version: [7.6.0, 8.8.0] - # Bitbucket 8.8.0 is the first one that supports Java 17 - exclude: - - java-version: 17 - bitbucket-version: 7.6.0 + matrix: ${{ fromJSON(needs.prepare.outputs.bitbucket-it-matrix) }} fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ref }} # Dec 13, 2022 @@ -164,24 +162,24 @@ jobs: # install last supported git - 2.37.4; remove this trick once Bitbucket implements support for latest git # https://confluence.atlassian.com/bitbucketserver/supported-platforms-776640981.html#Supportedplatforms-dvcsDVCS - run: bin/build/install-supported-git.sh - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: ${{ matrix.java-version }} distribution: adopt - run: bin/build/install-plugin-sdk.sh - run: bin/build/override-plugin-sdk-maven.sh - run: bin/build/install-int-test-libs.sh - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository key: maven-unit - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.m2/repository/com/atlassian/bitbucket key: maven-integration-bitbucket-${{ matrix.bitbucket-version }} - run: bin/build/install-common-modules.sh - run: VERSION=${{ matrix.bitbucket-version }} bin/build/run-bitbucket-its.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: name: webdriver-screenshots-bitbucket-${{ matrix.bitbucket-version }}-java-${{ matrix.java-version }} diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml index 7f9c1b1a..c19926b1 100644 --- a/.github/workflows/release-check.yml +++ b/.github/workflows/release-check.yml @@ -10,8 +10,13 @@ jobs: name: Release Check runs-on: ubuntu-20.04 timeout-minutes: 15 + strategy: + matrix: + branch: [master, release-1.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} - working-directory: bin/release-check run: | PRODUCT="jira" \ diff --git a/bin/build/get-plugin-major-version.sh b/bin/build/get-plugin-major-version.sh new file mode 100755 index 00000000..67664922 --- /dev/null +++ b/bin/build/get-plugin-major-version.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# INPUT ENV VARS +version_type="${1:?Please set pass a version type. Examples: 'jira', 'confluence', 'bitbucket' or 'common'}" +# [-SNAPSHOT] part prevents matching version in a [parent] section +version_pattern='[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT' + +case $version_type in + jira) + pl_path='jira-slack-server-integration/jira-slack-server-integration-plugin/pom.xml' + ;; + confluence) + pl_path='confluence-slack-integration/confluence-slack-server-integration-plugin/pom.xml' + ;; + bitbucket) + pl_path='bitbucket-slack-server-integration-plugin/pom.xml' + ;; + common) + pl_path='pom.xml' + version_pattern='[0-9]+\.[0-9]+\.[0-9]+' + ;; + *) + echo "Invalid version type" + exit 1 + ;; +esac + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +pl_version=$(cat "$SCRIPT_DIR/../../$pl_path" | grep -oE -m 1 $version_pattern | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') +echo "${pl_version%.*.*}" \ No newline at end of file diff --git a/bin/build/java-product-matrix.json b/bin/build/java-product-matrix.json new file mode 100644 index 00000000..781228e1 --- /dev/null +++ b/bin/build/java-product-matrix.json @@ -0,0 +1,58 @@ +{ + "current": { + "unit-tests": { + "java-version": ["17"] + }, + "jira-it": { + "java-version": ["17"], + "jira-version": ["10.0.0"] + }, + "confluence-it": { + "java-version": ["17"], + "confluence-version": ["9.0.0-m81"] + }, + "bitbucket-it": { + "java-version": ["17"], + "bitbucket-version": ["9.0.0"] + } + }, + "old": { + "unit-tests": { + "java-version": ["8", "11"] + }, + "jira-it": { + "java-version": ["8", "11", "17"], + "jira-version": ["8.15.0", "9.5.0"], + "exclude": [ + { + "java-version": "17", + "jira-version": "8.15.0" + } + ] + }, + "confluence-it": { + "java-version": ["8", "11", "17"], + "confluence-version": ["7.10.0", "8.0.0"], + "exclude": [ + { + "java-version": "8", + "confluence-version": "8.0.0" + }, + { + "java-version": "17", + "confluence-version": "7.10.0" + } + ] + }, + "bitbucket-it": { + "java-version": ["8", "11", "17"], + "bitbucket-version": ["7.6.0", "8.8.0"], + "exclude": [ + { + "java-version": "17", + "bitbucket-version": "7.6.0" + } + ] + } + } +} \ No newline at end of file diff --git a/bin/build/prepare-matrices.sh b/bin/build/prepare-matrices.sh new file mode 100755 index 00000000..200a3f17 --- /dev/null +++ b/bin/build/prepare-matrices.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +matrix_file='bin/build/java-product-matrix.json' + +# Get slack plugin major common version +pl_common_version=$(. bin/build/get-plugin-major-version.sh common) +if [ $pl_common_version -gt 1 ]; then + matrix_key='current' +# TODO: Remove these flags when new major jira (10.x) and bitbucket (9.x) are released + echo "skip-jira-its=true" >> $GITHUB_OUTPUT + echo "skip-bitbucket-its=true" >> $GITHUB_OUTPUT +else + matrix_key='old' +fi +echo "Matrix key - $matrix_key" + +echo "unit-tests-matrix=$(jq --compact-output --arg v "$matrix_key" '.[$v]."unit-tests"' $matrix_file)" >> $GITHUB_OUTPUT +echo "jira-it-matrix=$(jq --compact-output --arg v "$matrix_key" '.[$v]."jira-it"' $matrix_file)" >> $GITHUB_OUTPUT +echo "confluence-it-matrix=$(jq --compact-output --arg v "$matrix_key" '.[$v]."confluence-it"' $matrix_file)" >> $GITHUB_OUTPUT +echo "bitbucket-it-matrix=$(jq --compact-output --arg v "$matrix_key" '.[$v]."bitbucket-it"' $matrix_file)" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/bin/release-check/check-release.sh b/bin/release-check/check-release.sh index cf949cf1..5d870d75 100755 --- a/bin/release-check/check-release.sh +++ b/bin/release-check/check-release.sh @@ -47,22 +47,37 @@ esac echo "Determined workflow name: $workflow_name" # RUN TESTS AGAINST SPECIFIC VERSIONS -echo "Running workflow with params: workflow-name=$workflow_name java-version=8.0.252 product-version=$product_version" -first_workflow_link=$(start_workflow $workflow_name 8.0.252 $product_version) -echo "Pipeline URL: $first_workflow_link" +workflow_links=() +pl_common_version=$(. ../build/get-plugin-major-version.sh common) +if [ $pl_common_version -eq 1 ]; then + if [ $product_type != "confluence" ]; then + echo "Running workflow with params: workflow-name=$workflow_name java-version=8.0.252 product-version=$product_version" + first_workflow_link=$(start_workflow $workflow_name 8.0.252 $product_version) + echo "Pipeline URL: $first_workflow_link" + workflow_links+=("$first_workflow_link") + fi -echo "Running workflow with params: workflow-name=$workflow_name java-version=11 product-version=$product_version" -second_workflow_link=$(start_workflow $workflow_name 11 $product_version) -echo "Pipeline URL: $second_workflow_link" + echo "Running workflow with params: workflow-name=$workflow_name java-version=11 product-version=$product_version" + second_workflow_link=$(start_workflow $workflow_name 11 $product_version) + echo "Pipeline URL: $second_workflow_link" + workflow_links+=("$second_workflow_link") +fi echo "Running workflow with params: workflow-name=$workflow_name java-version=17 product-version=$product_version" third_workflow_link=$(start_workflow $workflow_name 17 $product_version) echo "Pipeline URL: $third_workflow_link" +workflow_links+=("$third_workflow_link") -workflow_links="$first_workflow_link, $second_workflow_link, $third_workflow_link" +# Join elements with a multi-character delimiter +function join_by { + local d=${1-} f=${2-} + if shift 2; then + printf %s "$f" "${@/#/$d}" + fi +} # CREATE NEW ISSUE FOR RELEASE echo "Creating a new issue" -new_issue_url=$(RELEASE_LABEL="$release_label" WORKFLOW_LINKS=$workflow_links. ./create-issue.sh) +new_issue_url=$(RELEASE_LABEL="$release_label" WORKFLOW_LINKS="$(join_by ', ' ${workflow_links[@]})" . ./create-issue.sh) echo "New ticket created: $new_issue_url" diff --git a/bin/release-check/plugin-product-compat-matrix.json b/bin/release-check/plugin-product-compat-matrix.json new file mode 100644 index 00000000..931dc794 --- /dev/null +++ b/bin/release-check/plugin-product-compat-matrix.json @@ -0,0 +1,14 @@ +{ + "jira": { + "3": "[0-9]\\.[0-9]+\\.[0-9]+", + "4": "10\\.[0-9]+\\.[0-9]+" + }, + "confluence": { + "3": "[0-8]\\.[0-9]+\\.[0-9]+", + "4": "9\\.[0-9]+\\.[0-9]+" + }, + "bitbucket": { + "4": "[0-8]\\.[0-9]+\\.[0-9]+", + "5": "9\\.[0-9]+\\.[0-9]+" + } +} \ No newline at end of file diff --git a/bin/release-check/run-product-release-check.sh b/bin/release-check/run-product-release-check.sh index 53302dc3..4ffb0c5a 100755 --- a/bin/release-check/run-product-release-check.sh +++ b/bin/release-check/run-product-release-check.sh @@ -12,8 +12,22 @@ if [ "$latest_releases" = "" ]; then exit fi -# TAKE AND CHECKS LATEST VERSION ONLY, MEANING THE GREATEST REVISION VERSION -latest_version=$(echo "$latest_releases" | tail -1) +# TAKE AND CHECKS LATEST COMPATIBLE VERSION ONLY, MEANING THE GREATEST REVISION VERSION +pl_product_version=$(. ../get-plugin-major-version.sh "$PRODUCT") +product_compat_version_regex=$(jq -r --arg pl "$pl_product_version" --arg p "$PRODUCT" '.[$p].[$pl]' ./plugin-product-compat-matrix.json) +latest_version=$(echo "$latest_releases" | grep -oE "$product_compat_version_regex" | tail -1) + +if [ "$latest_version" = "" ]; then + echo "Could not find latest versions" + echo "Product [$PRODUCT]" + echo "Compatible version pattern [$product_compat_version_regex]" + exit +fi + +echo "========================" +echo "LATEST VERSION" +echo "$latest_version" +echo "========================" # RUN CHECK FOR LATEST VERSION PRODUCT_VERSION="$latest_version" . ./check-release.sh