Skip to content

Commit

Permalink
Test new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Hrytsai committed May 16, 2024
1 parent a7b381f commit ce30844
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 0 deletions.
170 changes: 170 additions & 0 deletions .github/workflows/dyn-matrices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Dynamic Matrices
on:
push:
pull_request:
types: [ assigned, opened, synchronize, reopened, edited ]
workflow_dispatch:
inputs:
ref:
description: Branch/tag/hash to use (defaults to master)
required: false
default: master
jobs:
description: Jobs to run (comma-separated, defaults to all)
required: false

jobs:
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 }}
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

run-tests:
name: Unit Tests
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.unit-tests-matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: adopt
- run: bin/build/install-plugin-sdk.sh
- 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@v4
with:
name: unit-tests-coverage-java-${{ matrix.java-version }}
path: '**/target/site/jacoco/**'

integration-tests-jira:
name: Jira
needs: [prepare, run-tests]
if: (github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-jira')) && !needs.prepare.outputs.skip-jira-its
runs-on: ubuntu-20.04
timeout-minutes: 30
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.jira-it-matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- 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@v4
with:
path: ~/.m2/repository
key: maven-unit
- 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@v4
if: failure()
with:
name: webdriver-screenshots-jira-${{ matrix.jira-version }}
path: jira-slack-server-integration/jira-slack-server-integration-plugin/target/webdriverTests/**

integration-tests-confluence:
name: Confluence
needs: [prepare, run-tests]
runs-on: ubuntu-20.04
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.confluence-it-matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- 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@v4
with:
path: ~/.m2/repository
key: maven-unit
- 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@v4
if: failure()
with:
name: webdriver-screenshots-confluence-${{ matrix.confluence-version }}-java-${{ matrix.java-version }}
path: confluence-slack-server-integration-plugin/target/webdriverTests/**

integration-tests-bitbucket:
name: Bitbucket
needs: [prepare, run-tests]
if: (github.event.inputs.jobs == '' || contains(github.event.inputs.jobs, 'integration-tests-bitbucket')) && !needs.prepare.outputs.skip-bitbucket-its
runs-on: ubuntu-20.04
timeout-minutes: 30
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.bitbucket-it-matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
# Dec 13, 2022
# latest Bitbucket 8.6.1 doesn't support latest git 2.38.1 installed on the Ubuntu 20 image Github provides
# 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@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@v4
with:
path: ~/.m2/repository
key: maven-unit
- 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@v4
if: failure()
with:
name: webdriver-screenshots-bitbucket-${{ matrix.bitbucket-version }}-java-${{ matrix.java-version }}
path: bitbucket-slack-server-integration-plugin/target/webdriverTests/**
29 changes: 29 additions & 0 deletions bin/build/matrix-lts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"old": {
"unit-tests": {
"java-version": ["8", "11"]
},
"jira-it": {
"java-version": ["8", "11", "17"],
"jira-version": ["9.4.0", "9.12.0"]
},
"confluence-it": {
"java-version": ["8", "11", "17"],
"confluence-version": ["7.19.0", "8.5.0"],
"exclude": [
{
"java-version": "8",
"confluence-version": "8.5.0"
},
{
"java-version": "17",
"confluence-version": "7.19.0"
}
]
},
"bitbucket-it": {
"java-version": ["8", "11", "17"],
"bitbucket-version": ["8.9.0", "8.19.0"]
}
}
}
20 changes: 20 additions & 0 deletions bin/build/prepare-matrices.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

matrix_file='bin/build/matrix-lts.json'

# Get slack plugin major common version
pl_common_version=$(. ../get-plugin-major-version.sh common)
if [ $pl_common_version -gt 1 ]; then
matrix_key='current'
else
matrix_key='old'
fi
echo "Matrix key - $matrix_key"

echo "skip-jira-its=true" >> $GITHUB_OUTPUT
echo "skip-bitbucket-its=true" >> $GITHUB_OUTPUT

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
30 changes: 30 additions & 0 deletions bin/get-plugin-major-version.sh
Original file line number Diff line number Diff line change
@@ -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='<version>[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT</version>'

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='<version>[0-9]+\.[0-9]+\.[0-9]+</version>'
;;
*)
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%.*.*}"

0 comments on commit ce30844

Please sign in to comment.