Change to recomanded statement #149
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test ml-commons | |
# This workflow is triggered on pull requests and push to any branches | |
on: | |
push: | |
branches-ignore: | |
- 'backport/**' | |
- 'create-pull-request/**' | |
- 'dependabot/**' | |
pull_request_target: | |
types: [opened, synchronize, reopened] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
Build-ml: | |
strategy: | |
matrix: | |
java: [11, 17] | |
name: Build and Test MLCommons Plugin | |
if: github.repository == 'opensearch-project/ml-commons' | |
environment: ml-commons-cicd-env | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java ${{ matrix.java }} | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
- uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.ML_ROLE }} | |
aws-region: us-west-2 | |
- name: Checkout MLCommons | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Build and Run Tests | |
run: | | |
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text) | |
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text) | |
echo "::add-mask::$OPENAI_KEY" | |
echo "::add-mask::$COHERE_KEY" | |
./gradlew build | |
- name: Publish to Maven Local | |
run: | | |
./gradlew publishToMavenLocal | |
- name: Multi Nodes Integration Testing | |
run: | | |
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text) | |
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text) | |
echo "::add-mask::$OPENAI_KEY" | |
echo "::add-mask::$COHERE_KEY" | |
./gradlew integTest -PnumNodes=3 | |
- name: Pull and Run Docker | |
run: | | |
plugin=`basename $(ls plugin/build/distributions/*.zip)` | |
version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-3` | |
plugin_version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-4` | |
qualifier=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1` | |
candidate_version=`echo $plugin|awk -F- '{print $5}'| cut -d. -f 1-1` | |
docker_version=$version-$qualifier | |
[[ -z $candidate_version ]] && candidate_version=$qualifier && qualifier="" | |
echo plugin version plugin_version qualifier candidate_version docker_version | |
echo "($plugin) ($version) ($plugin_version) ($qualifier) ($candidate_version) ($docker_version)" | |
cd .. | |
if docker pull opensearchstaging/opensearch:$docker_version | |
then | |
echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile | |
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-ml ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-ml; fi" >> Dockerfile | |
echo "ADD ml-commons/plugin/build/distributions/$plugin /tmp/" >> Dockerfile | |
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> Dockerfile | |
docker build -t opensearch-ml:test . | |
echo "imagePresent=true" >> $GITHUB_ENV | |
else | |
echo "imagePresent=false" >> $GITHUB_ENV | |
fi | |
- name: Run Docker Image | |
if: env.imagePresent == 'true' | |
run: | | |
cd .. | |
docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ml:test | |
sleep 90 | |
- name: Run MLCommons Test | |
if: env.imagePresent == 'true' | |
run: | | |
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:admin --insecure |grep opensearch-security|wc -l` | |
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text) | |
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text) | |
echo "::add-mask::$OPENAI_KEY" | |
echo "::add-mask::$COHERE_KEY" | |
if [ $security -gt 0 ] | |
then | |
echo "Security plugin is available" | |
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -Dhttps=true -Duser=admin -Dpassword=admin | |
else | |
echo "Security plugin is NOT available" | |
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" | |
fi | |
- name: Upload Coverage Report | |
uses: codecov/codecov-action@v1 | |
with: | |
flags: ml-commons | |
token: ${{ secrets.CODECOV_TOKEN }} | |
Build-ml-windows: | |
strategy: | |
matrix: | |
java: [11, 17] | |
name: Build and Test MLCommons Plugin on Windows | |
if: github.repository == 'opensearch-project/ml-commons' | |
environment: ml-commons-cicd-env | |
runs-on: windows-latest | |
steps: | |
- name: Setup Java ${{ matrix.java }} | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
- uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.ML_ROLE }} | |
aws-region: us-west-2 | |
# ml-commons | |
- name: Checkout MLCommons | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Build and Run Tests | |
shell: bash | |
run: | | |
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text) | |
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text) | |
echo "::add-mask::$OPENAI_KEY" | |
echo "::add-mask::$COHERE_KEY" | |
./gradlew.bat build | |
- name: Publish to Maven Local | |
run: | | |
./gradlew publishToMavenLocal | |
# - name: Multi Nodes Integration Testing | |
# shell: bash | |
# run: | | |
# export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text) | |
# export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text) | |
# echo "::add-mask::$OPENAI_KEY" | |
# echo "::add-mask::$COHERE_KEY" | |
# ./gradlew integTest -PnumNodes=3 |