Skip to content

Commit

Permalink
Ensure Github workflow runs on docker image used by Production Distri…
Browse files Browse the repository at this point in the history
…bution Build

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 18, 2023
1 parent 918c821 commit 858db31
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
CI_ENVIRONMENT: normal

jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch

generate-test-list:
runs-on: ubuntu-latest
outputs:
Expand All @@ -32,16 +37,55 @@ jobs:
run: |
echo "separateTestsNames=$(./gradlew listTasksAsJSON -q --console=plain | tail -n 1)" >> $GITHUB_OUTPUT
test:
test-linux:
name: test
needs:
- generate-test-list
- Get-CI-Image-Tag
if: github.repository == 'opensearch-project/security'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
gradle_task: ${{ fromJson(needs.generate-test-list.outputs.separateTestsNames) }}
jdk: [11, 17, 21]
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root

steps:
- uses: actions/checkout@v4
- name: Checkout security
run: |
# https://github.com/opensearch-project/opensearch-build/issues/4191
chown -R ci-runner:ci-runner `pwd`
su ci-runner -c "source /etc/profile.d/java_home.sh && ./gradlew check -Dorg.gradle.java.home=/opt/java/openjdk-${{ matrix.java }}"
- name: Build and Test
run: |
# https://github.com/opensearch-project/opensearch-build/issues/4191
chown -R ci-runner:ci-runner `pwd`
su ci-runner -c "source /etc/profile.d/java_home.sh && ./gradlew ${{ matrix.gradle_task }} --no-build-cache -Dbuild.snapshot=false -Dorg.gradle.java.home=/opt/java/openjdk-${{ matrix.java }}"
- uses: alehechka/upload-tartifact@v2
if: always()
with:
name: ubuntu-lates-JDK${{ matrix.jdk }}-${{ matrix.gradle_task }}-reports
path: |
./build/reports/
test-windows:
name: test
needs: generate-test-list
strategy:
fail-fast: false
matrix:
gradle_task: ${{ fromJson(needs.generate-test-list.outputs.separateTestsNames) }}
platform: [windows-latest, ubuntu-latest]
jdk: [11, 17, 21]
runs-on: ${{ matrix.platform }}
runs-on: windows-latest

steps:
- name: Set up JDK for build and test
Expand All @@ -63,7 +107,7 @@ jobs:
- uses: alehechka/upload-tartifact@v2
if: always()
with:
name: ${{ matrix.platform }}-JDK${{ matrix.jdk }}-${{ matrix.gradle_task }}-reports
name: windows-latest-JDK${{ matrix.jdk }}-${{ matrix.gradle_task }}-reports
path: |
./build/reports/
Expand Down

0 comments on commit 858db31

Please sign in to comment.