Adding release workflow for the asynchronous search (#330) (#333) #761
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: Test and Build Workflow | |
# This workflow is triggered on pull requests to master or a OpenSearch release branch | |
on: | |
pull_request: | |
branches: | |
- "*" | |
push: | |
branches: | |
- "*" | |
jobs: | |
linux-build: | |
strategy: | |
matrix: | |
java: | |
- 8 | |
- 11 | |
- 14 | |
# Job name | |
name: Build Asynchronous Search | |
# This job runs on Linux. | |
runs-on: ubuntu-latest | |
steps: | |
# This step uses the setup-java Github action: https://github.com/actions/setup-java | |
- name: Set Up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
# This step uses the checkout Github action: https://github.com/actions/checkout | |
- name: Checkout Branch | |
uses: actions/checkout@v2 | |
- name: Build with Gradle | |
run: ./gradlew build -Dopensearch.version=1.3.12-SNAPSHOT | |
- name: Pull and Run Docker for security tests | |
run: | | |
version=1.3.12-SNAPSHOT | |
plugin_version=1.3.12.0-SNAPSHOT | |
pwd=`pwd` | |
echo $pwd | |
cd .. | |
pwd1=`pwd` | |
echo $pwd1 | |
list_of_all_files=`ls asynchronous-search/build/distributions/` | |
echo "listing distributions" | |
echo $list_of_all_files | |
if docker pull opensearchstaging/opensearch:$version | |
then | |
echo "FROM docker.opensearch.org/opensearch:$version" >> Dockerfile | |
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-asynchronous-search ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-asynchronous-search; fi" >> Dockerfile | |
echo "ADD asynchronous-search/build/distributions/opensearch-asynchronous-search-$plugin_version.zip /tmp/" >> Dockerfile | |
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-asynchronous-search-$plugin_version.zip" >> Dockerfile | |
docker build -t opensearch-asynchronous-search: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-asynchronous-search:test | |
sleep 90 | |
- name: Run Asynchronous Search Test | |
if: env.imagePresent == 'true' | |
run: | | |
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:admin --insecure |grep opensearch-security|wc -l` | |
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 failed logs | |
uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: logs | |
path: build/testclusters/integTest-*/logs/* | |
- name: Create Artifact Path | |
run: | | |
mkdir -p asynchronous-search-artifacts | |
cp ./build/distributions/*.zip asynchronous-search-artifacts | |
- name: Uploads coverage | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v1 | |
with: | |
name: asynchronous-search-plugin-ubuntu | |
path: asynchronous-search-artifacts | |
windows-build: | |
# Job name | |
name: Build Asynchronous Search | |
# This job runs on Windows. | |
runs-on: windows-latest | |
steps: | |
# This step uses the setup-java Github action: https://github.com/actions/setup-java | |
- name: Set Up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
# This step uses the checkout Github action: https://github.com/actions/checkout | |
- name: Checkout Branch | |
uses: actions/checkout@v2 | |
- name: Build with Gradle | |
run: ./gradlew.bat build -D"opensearch.version=1.3.12-SNAPSHOT" -x integTest -x jacocoTestReport | |
env: | |
_JAVA_OPTIONS: -Xmx4096M | |
- name: Create Artifact Path | |
run: | | |
mkdir -p asynchronous-search-artifacts | |
cp ./build/distributions/*.zip asynchronous-search-artifacts | |
# This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v1 | |
with: | |
name: asynchronous-search-plugin-windows | |
path: asynchronous-search-artifacts | |
mac-os-build: | |
# Job name | |
name: Build Asynchronous Search | |
# This job runs on Mac OS. | |
runs-on: macos-latest | |
steps: | |
# This step uses the setup-java Github action: https://github.com/actions/setup-java | |
- name: Set Up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
# This step uses the checkout Github action: https://github.com/actions/checkout | |
- name: Checkout Branch | |
uses: actions/checkout@v2 | |
- name: Build with Gradle | |
run: ./gradlew build -Dopensearch.version=1.3.12-SNAPSHOT -x integTest -x jacocoTestReport | |
env: | |
_JAVA_OPTIONS: -Xmx4096M | |
- name: Create Artifact Path | |
run: | | |
mkdir -p asynchronous-search-artifacts | |
cp ./build/distributions/*.zip asynchronous-search-artifacts | |
# This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v1 | |
with: | |
name: asynchronous-search-plugin-mac | |
path: asynchronous-search-artifacts |