Skip to content

Commit

Permalink
Add test and readme for release
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Feb 21, 2024
1 parent c59bada commit f157aef
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
pull_request:

jobs:
test-no-plugins:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- uses: ./ # Use the action
with:
opensearch-version: 3.0.0
security-enabled: false

- name: Checks that OpenSearch is healthy
run: curl http://localhost:9200/_cat/plugins -v
shell: bash

test-with-security:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: Download security plugin
uses: suisei-cn/[email protected]
with:
url: https://aws.oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.opensearch.plugin&a=opensearch-security&v=3.0.0.0-SNAPSHOT&p=zip
target: plugin-artifacts/
filename: security.zip

- uses: ./ # Use the action
with:
opensearch-version: 3.0.0
security-enabled: true
plugins: "file:${{ github.workspace }}/security.zip"
admin-password: "myStrongPassword123!"

- name: Checks that OpenSearch is healthy
run: curl https://localhost:9200/_cat/plugins -u 'admin:myStrongPassword123!' -k -v
shell: bash
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# start-opensearch
Github action to start an OpenSearch instance

```yaml
inputs:
opensearch-version:
description: 'The version of OpenSearch that should be used, e.g "3.0.0"'
required: true

plugins:
description: 'A comma separated list of plugins to install. Leave empty to not install any. Each entry should be a full path prefixed with `file: `, for example: `file:$(pwd)/my-plugin.zip`'
required: false

security-enabled:
description: 'Whether security is enabled'
required: true

admin-password:
description: 'The admin password uses for the cluster'
required: false

security_config_file:
description: 'Path to a security config file to replace the default. Leave empty if security is not enabled or using the default config'
required: false
```
## Usage:
```yaml
steps:
- name: Run Opensearch with A Single Plugin
uses: derek-ho/start-opensearch@v1
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugins: "file:${{ github.workspace }}/${{ env.PLUGIN_NAME }}.zip"
security-enabled: true
admin-password: ${{ steps.random-password.outputs.generated_name }}
```
# Changelog
## v1
- Initial Release
18 changes: 15 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: true

plugins:
description: 'A comma separated list of plugins to install. Leave empty to not install any. Each entry should be of the following formats: either a full link to the plugin zip, or a full path prefixed with `file: `, for example: `file:$(pwd)/my-plugin.zip`'
description: 'A comma separated list of plugins to install. Leave empty to not install any. Each entry should be a full path prefixed with `file: `, for example: `file:$(pwd)/my-plugin.zip`'
required: false

security-enabled:
Expand Down Expand Up @@ -61,17 +61,29 @@ runs:
del opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip
shell: pwsh

- name: Install plugin(s) into OpenSearch
- name: Install plugin(s) into OpenSearch for Linux
if: ${{ runner.os == 'Linux'}}
run: |
chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin
plugins="${{ inputs.plugins }}"
if [ -n "$plugins" ]; then
echo "$plugins" | tr ',' '\n' | while read -r plugin; do
/bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install \"$plugin\""
/bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install ${plugin}"
done
fi
shell: bash

- name: Install plugin(s) into OpenSearch for Windows
if: ${{ runner.os == 'Windows'}}
run: |
$pluginNames = "${{ inputs.plugins }}" -split ','
if ($pluginNames.Length -gt 0) {
foreach ($plugin in $pluginNames) {
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install ${plugin}
}
}
shell: pwsh

- name: Replace security configuration file if applicable
if: ${{ inputs.security_config_file != '' }}
run: |
Expand Down

0 comments on commit f157aef

Please sign in to comment.