-
Notifications
You must be signed in to change notification settings - Fork 49
211 lines (196 loc) · 8.18 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch
linux-build:
strategy:
matrix:
java: [ 21 ]
needs: Get-CI-Image-Tag
# Job name
name: Linux - Build Asynchronous Search
# This job runs on Linux.
outputs:
build-test-linux: ${{ steps.step-build-test-linux.outputs.build-test-linux }}
runs-on: ubuntu-latest
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: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
steps:
- name: Run start commands
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
# This step uses the setup-java Github action: https://github.com/actions/setup-java
- name: Set up JDK ${{ matrix.java }} for build and test
uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: ${{ matrix.java }}
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout Branch
uses: actions/checkout@v4
- name: Build with Gradle
id: step-build-test-linux
run: |
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "./gradlew build"
plugin=`basename $(ls build/distributions/*.zip)`
echo plugin $plugin
mv -v build/distributions/$plugin ./
echo "build-test-linux=$plugin" >> $GITHUB_OUTPUT
- name: Uploads coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: async-plugin-linux-${{ matrix.java }}
path: ${{ steps.step-build-test-linux.outputs.build-test-linux }}
if-no-files-found: error
linux-test-docker:
strategy:
matrix:
java: [ 21 ]
needs: linux-build
# Job name
name: Test Asynchronous Search with opensearchstaging docker
# 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@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: ${{ matrix.java }}
- name: Checkout Branch
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: async-plugin-linux-${{ matrix.java }}
- name: Pull and Run Docker for security tests
run: |
plugin=${{ needs.linux-build.outputs.build-test-linux }}
version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-3`
plugin_version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-4`
qualifier=`echo $plugin|awk -F- '{print $5}'| cut -d. -f 1-1`
if [ -n "$qualifier" ] && [ "$qualifier" != "SNAPSHOT" ]; then
qualifier=-${qualifier}
else
qualifier=""
fi
docker_version=$version$qualifier
echo plugin version plugin_version qualifier docker_version
echo "($plugin) ($version) ($plugin_version) ($qualifier) ($docker_version)"
pwd && ls -l ./$plugin
if docker pull opensearchstaging/opensearch:$docker_version
then
echo "FROM opensearchstaging/opensearch:$docker_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 $plugin /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> 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 "OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!" -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:myStrongPassword123! --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=myStrongPassword123!
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@v4
if: failure()
with:
name: logs
path: build/testclusters/integTest-*/logs/*
windows-build:
strategy:
matrix:
java: [ 21 ]
# Job name
name: Windows - 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 ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: ${{ matrix.java }}
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout Branch
uses: actions/checkout@v4
- name: Build with Gradle
run: ./gradlew.bat build -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@v4
with:
name: asynchronous-search-plugin-windows
path: asynchronous-search-artifacts
mac-os-build:
strategy:
matrix:
java: [ 21 ]
# Job name
name: MacOS - 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 ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: ${{ matrix.java }}
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout Branch
uses: actions/checkout@v4
- name: Build with Gradle
run: ./gradlew build -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@v4
with:
name: asynchronous-search-plugin-mac
path: asynchronous-search-artifacts