Skip to content

Commit

Permalink
Update the workflow to run the integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Sep 20, 2023
1 parent 253465b commit c536607
Showing 1 changed file with 97 additions and 66 deletions.
163 changes: 97 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- main
- 1.*
- 2.*
pull_request:

env:
GRADLE_OPTS: -Dhttp.keepAlive=false
Expand All @@ -18,7 +24,7 @@ jobs:
java-version: 17

- name: Checkout security
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Generate list of tasks
id: set-matrix
Expand All @@ -44,15 +50,14 @@ jobs:
java-version: ${{ matrix.jdk }}

- name: Checkout security
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build and Test
uses: gradle/gradle-build-action@v2
with:
cache-disabled: true
arguments: |
${{ matrix.gradle_task }} -Dbuild.snapshot=false
-x test
- name: Coverage
uses: Wandalen/[email protected]
Expand All @@ -62,7 +67,7 @@ jobs:
action: codecov/codecov-action@v3
with: |
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: false
files: ./build/reports/jacoco/test/jacocoTestReport.xml
- uses: actions/upload-artifact@v3
Expand All @@ -76,7 +81,8 @@ jobs:
if: always()
run: echo "Check the artifact ${{ matrix.platform }}-JDK${{ matrix.jdk }}-reports for detailed test results"

backward-compatibility:
integration-tests:
name: integration-tests
strategy:
fail-fast: false
matrix:
Expand All @@ -85,80 +91,105 @@ jobs:
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/setup-java@v3
- name: Set up JDK for build and test
uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: ${{ matrix.jdk }}

- name: Checkout Security Repo
uses: actions/checkout@v2
- name: Checkout security
uses: actions/checkout@v4

- id: build-previous
uses: ./.github/actions/run-bwc-suite
- name: Build and Test
uses: gradle/gradle-build-action@v2
with:
plugin-previous-branch: "2.10"
plugin-next-branch: "current_branch"
report-artifact-name: bwc-${{ matrix.platform }}-jdk${{ matrix.jdk }}
username: admin
password: admin
cache-disabled: true
arguments: |
integrationTest -Dbuild.snapshot=false
# backward-compatibility:
# strategy:
# fail-fast: false
# matrix:
# jdk: [11, 17]
# platform: [ubuntu-latest, windows-latest]
# runs-on: ${{ matrix.platform }}

# steps:
# - uses: actions/setup-java@v3
# with:
# distribution: temurin # Temurin is a distribution of adoptium
# java-version: ${{ matrix.jdk }}

# - name: Checkout Security Repo
# uses: actions/checkout@v4

# - id: build-previous
# uses: ./.github/actions/run-bwc-suite
# with:
# plugin-previous-branch: "2.10"
# plugin-next-branch: "current_branch"
# report-artifact-name: bwc-${{ matrix.platform }}-jdk${{ matrix.jdk }}
# username: admin
# password: admin

code-ql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
- uses: github/codeql-action/init@v1
- uses: github/codeql-action/init@v2
with:
languages: java
- run: ./gradlew clean build -Dbuild.snapshot=false -x test
- uses: github/codeql-action/analyze@v1

build-artifact-names:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11

- run: |
security_plugin_version=$(./gradlew properties -q | grep -E '^version:' | awk '{print $2}')
security_plugin_version_no_snapshot=$(echo $security_plugin_version | sed 's/-SNAPSHOT//g')
security_plugin_version_only_number=$(echo $security_plugin_version_no_snapshot | cut -d- -f1)
test_qualifier=alpha2
echo "SECURITY_PLUGIN_VERSION=$security_plugin_version" >> $GITHUB_ENV
echo "SECURITY_PLUGIN_VERSION_NO_SNAPSHOT=$security_plugin_version_no_snapshot" >> $GITHUB_ENV
echo "SECURITY_PLUGIN_VERSION_ONLY_NUMBER=$security_plugin_version_only_number" >> $GITHUB_ENV
echo "TEST_QUALIFIER=$test_qualifier" >> $GITHUB_ENV
- run: |
echo ${{ env.SECURITY_PLUGIN_VERSION }}
echo ${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}
echo ${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}
echo ${{ env.TEST_QUALIFIER }}
- run: ./gradlew clean assemble && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION }}.zip

- run: ./gradlew clean assemble -Dbuild.snapshot=false && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}.zip

- run: ./gradlew clean assemble -Dbuild.snapshot=false -Dbuild.version_qualifier=${{ env.TEST_QUALIFIER }} && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}-${{ env.TEST_QUALIFIER }}.zip

- run: ./gradlew clean assemble -Dbuild.version_qualifier=${{ env.TEST_QUALIFIER }} && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}-${{ env.TEST_QUALIFIER }}-SNAPSHOT.zip

- run: |
## EXISTING_OS_VERSION outputs the major version, example as 2
EXISTING_OS_VERSION=$(./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1' | cut -d '-' -f1 | cut -d '.' -f1)
## INCREMENT_OS_VERSION in an increment of 1, example if EXISTING_OS_VERSION is 2, INCREMENT_OS_VERSION is 3
INCREMENT_OS_VERSION=$((++EXISTING_OS_VERSION))
./gradlew clean updateVersion -DnewVersion=$INCREMENT_OS_VERSION.0.0-SNAPSHOT
test `./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1'` = $INCREMENT_OS_VERSION.0.0-SNAPSHOT
- name: List files in the build directory if there was an error
run: ls -al ./build/distributions/
if: failure()
- uses: github/codeql-action/analyze@v2

# build-artifact-names:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - uses: actions/setup-java@v3
# with:
# distribution: temurin # Temurin is a distribution of adoptium
# java-version: 11

# - run: |
# security_plugin_version=$(./gradlew properties -q | grep -E '^version:' | awk '{print $2}')
# security_plugin_version_no_snapshot=$(echo $security_plugin_version | sed 's/-SNAPSHOT//g')
# security_plugin_version_only_number=$(echo $security_plugin_version_no_snapshot | cut -d- -f1)
# test_qualifier=alpha2

# echo "SECURITY_PLUGIN_VERSION=$security_plugin_version" >> $GITHUB_ENV
# echo "SECURITY_PLUGIN_VERSION_NO_SNAPSHOT=$security_plugin_version_no_snapshot" >> $GITHUB_ENV
# echo "SECURITY_PLUGIN_VERSION_ONLY_NUMBER=$security_plugin_version_only_number" >> $GITHUB_ENV
# echo "TEST_QUALIFIER=$test_qualifier" >> $GITHUB_ENV

# - run: |
# echo ${{ env.SECURITY_PLUGIN_VERSION }}
# echo ${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}
# echo ${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}
# echo ${{ env.TEST_QUALIFIER }}

# - run: ./gradlew clean assemble && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION }}.zip

# - run: ./gradlew clean assemble -Dbuild.snapshot=false && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_NO_SNAPSHOT }}.zip

# - run: ./gradlew clean assemble -Dbuild.snapshot=false -Dbuild.version_qualifier=${{ env.TEST_QUALIFIER }} && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}-${{ env.TEST_QUALIFIER }}.zip

# - run: ./gradlew clean assemble -Dbuild.version_qualifier=${{ env.TEST_QUALIFIER }} && test -s ./build/distributions/opensearch-security-${{ env.SECURITY_PLUGIN_VERSION_ONLY_NUMBER }}-${{ env.TEST_QUALIFIER }}-SNAPSHOT.zip

# - run: |
# ## EXISTING_OS_VERSION outputs the major version, example as 2
# EXISTING_OS_VERSION=$(./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1' | cut -d '-' -f1 | cut -d '.' -f1)
# ## INCREMENT_OS_VERSION in an increment of 1, example if EXISTING_OS_VERSION is 2, INCREMENT_OS_VERSION is 3
# INCREMENT_OS_VERSION=$((++EXISTING_OS_VERSION))
# ./gradlew clean updateVersion -DnewVersion=$INCREMENT_OS_VERSION.0.0-SNAPSHOT
# test `./gradlew properties | grep opensearch.version | cut -d':' -f2- | awk '{$1=$1};1'` = $INCREMENT_OS_VERSION.0.0-SNAPSHOT

# - name: List files in the build directory if there was an error
# run: ls -al ./build/distributions/
# if: failure()

0 comments on commit c536607

Please sign in to comment.