Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run security-dashboards-plugin CI while security-dashboards-plugin is split into 2 separate plugins #7

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
918faa5
Introduce opensearch_security.configuration.admin_pages_enabled setti…
cwperks May 17, 2024
27779f9
Fix typo
cwperks May 17, 2024
8c1d1e5
Define common routes
cwperks May 17, 2024
36b0098
WIP on admin screen only
cwperks May 18, 2024
d66fd63
Only register custom error page if pages are enabled
cwperks May 18, 2024
da3dd2e
Merge branch 'disable-security-pages' into admin-screens-only
cwperks May 18, 2024
4858db3
Organize sections in public/plugin.ts
cwperks May 18, 2024
9ffa45b
Remove comment
cwperks May 18, 2024
c653144
Merge branch 'disable-security-pages' into admin-screens-only
cwperks May 18, 2024
90f4fc6
Update server/plugin.ts
cwperks May 18, 2024
dbb5318
Update datasource
cwperks May 18, 2024
2a93bb0
Merge branch 'disable-security-pages' into admin-screens-only
cwperks May 18, 2024
4ec526d
Remove defineCommonRoutes
cwperks May 18, 2024
6e56a42
Fix top nav bar
cwperks May 18, 2024
6ac1fea
Create common plugin
cwperks May 20, 2024
80b58c7
Pass appropriate handler context
cwperks May 20, 2024
1a2c0dd
Move list
cwperks May 20, 2024
1f54c72
defineCommonRoutes
cwperks May 20, 2024
6426257
Surround with try catch
cwperks May 21, 2024
1df7862
Only register if not already registered
cwperks May 21, 2024
80c1c38
Revert route handler context change
cwperks May 21, 2024
f777798
Add defineRoutes backs
cwperks May 22, 2024
fd776f3
Move up logic for defining routes
cwperks May 22, 2024
70367e8
Add all routes
cwperks May 22, 2024
72b6990
Revert changes
cwperks May 22, 2024
002b3d3
Revert changes
cwperks May 22, 2024
aefb24a
Merge branch 'disable-security-pages' into admin-screens-only
cwperks May 22, 2024
f2c7455
Run with multiple security-dashboards-plugin
cwperks May 22, 2024
7b334f7
Use local action
cwperks May 22, 2024
d39b947
Comment out section
cwperks May 22, 2024
e7a7801
Fix indentation
cwperks May 22, 2024
7144beb
Add shell
cwperks May 22, 2024
e92eb03
rewrite package.json
cwperks May 22, 2024
7498fad
Change package.json before bootstrap
cwperks May 22, 2024
0a0c343
minor change
cwperks May 23, 2024
1400f56
Add debug step
cwperks May 23, 2024
439f303
Move opensearch_dashboards.json logic
cwperks May 23, 2024
9d4639e
Update URL
cwperks May 23, 2024
e3cb5d4
Only run linux
cwperks May 23, 2024
018cc7f
Test change
cwperks May 23, 2024
0868d19
Revert "Test change"
cwperks May 23, 2024
65a1c1c
Update FTR branch
cwperks May 23, 2024
2767f69
Only run on push
cwperks May 24, 2024
c4a9a84
Remove duplication
cwperks May 24, 2024
cd69d85
Minor change
cwperks May 24, 2024
e491ea7
Remove agg view test
cwperks May 24, 2024
8655bec
Use correct prefix
cwperks May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/run-cypress-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ runs:

# OSD bootstrap
- name: Run Dashboard with Security Dashboards Plugin
uses: derek-ho/setup-opensearch-dashboards@v1
uses: ./.github/actions/setup-opensearch-dashboards
with:
plugin_name: security-dashboards-plugin
opensearch_dashboards_yml: ${{ inputs.dashboards_config_file }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: 'Starts Dashboards with Plugin'
description: 'Installs OpenSearch Dashboard with a plugin from github, then checks out the correct dashboards version for the plugin, configures npm/yarn, bootstraps Dashboards, and starts the instance'

inputs:
plugin_name:
description: 'The name of the plugin to use, such as security-dashboards-plugin'
required: true

built_plugin_name:
description: 'The name of the plugin after building, if doing zip install'
required: false

built_plugin_suffix:
description: 'The suffix of the plugin after building, if doing zip instll. Leave empty to indicate default OSD build behavior'
required: false

install_zip:
description: 'Whether the setup should be done using the install plugin flow. Leave empty to indicate dev setup. Only applicable for linux for now'
required: false

plugin_repo:
description: 'The repo of the plugin to use. Leave empty to indicate the repo which is running this action'
required: false

opensearch_dashboards_yml:
description: 'The file to replace opensearch_dashboards.yml. Leave empty to use the default'
required: false

plugin_branch:
description: 'The branch of the repo of the plugin to use. Leave empty to indicate the branch which is running this action'
required: false

outputs:
dashboards-directory:
description: "The directory where the dashboards has been configured"
value: ${{ steps.determine-dashboards-directory.outputs.dashboards-directory }}

dashboards-binary-directory:
description: "The directory of the dashboards binary that was configured"
value: ${{ steps.determine-dashboards-directory-zip-install.outputs.dashboards-directory }}

plugin-directory:
description: "The directory where the plugin has been configured"
value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}


runs:
using: "composite"
steps:
- id: determine-dashboards-directory
if: ${{ inputs.install_zip != 'true' }}
run: echo "dashboards-directory=OpenSearch-Dashboards" >> $GITHUB_OUTPUT
shell: bash

- id: determine-plugin-directory
run: echo "::set-output name=plugin-directory::./OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}"
shell: bash

- uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: cwperks/OpenSearch-Dashboards
ref: 'support-repeated-plugin'
fetch-depth: 0
filter: |
cypress
test

- uses: actions/checkout@v2
with:
path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}

- id: osd-version
run: |
echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)"
echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x"
echo "::set-output name=plugin-version::$(jq -r '.opensearchDashboardsVersion' opensearch_dashboards.json)"
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}
shell: bash

- id: branch-switch-if-possible
continue-on-error: true # Defaults onto main if the branch switch doesn't work
if: ${{ steps.osd-version.outputs.osd-version }}
run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }}
working-directory: ./OpenSearch-Dashboards
shell: bash

- id: tool-versions
run: |
echo "node_version=$(cat .node-version)" >> $GITHUB_OUTPUT
echo "yarn_version=$(jq -r '.engines.yarn' package.json)" >> $GITHUB_OUTPUT
working-directory: OpenSearch-Dashboards
shell: bash

- uses: actions/setup-node@v1
with:
node-version: ${{ steps.tool-versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: Setup Opensearch Dashboards
run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.tool-versions.outputs.yarn_version }}"
npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }}
yarn cache clean
yarn add sha.js
working-directory: OpenSearch-Dashboards
shell: bash

- name: Bootstrap the OpenSearch Dashboard
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 2
command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss --single-version=loose # loose is passed in to ignore version conflicts on cypress version used in OSD and this repo

- name: Download OpenSearch for Linux
uses: peternied/download-file@v2
if: ${{ inputs.install_zip == 'true' && runner.os == 'Linux' }}
with:
url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ steps.osd-version.outputs.plugin-version }}/latest/linux/x64/tar/builds/opensearch-dashboards/dist/opensearch-dashboards-min-${{ steps.osd-version.outputs.plugin-version }}-linux-x64.tar.gz

# Extract downloaded zip
- name: Extract downloaded tar
if: ${{ inputs.install_zip == 'true' && runner.os == 'Linux' }}
run: |
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
shell: bash

- id: determine-dashboards-directory-zip-install
if: ${{ inputs.install_zip == 'true' }}
run: echo "dashboards-directory=opensearch-dashboards-${{ steps.osd-version.outputs.plugin-version }}-linux-x64" >> $GITHUB_OUTPUT
shell: bash

- name: Build the plugin
if: ${{ inputs.install_zip == 'true' }}
run: |
yarn build
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}
shell: bash

- name: Install the plugin zip
if: ${{ inputs.install_zip == 'true' && inputs.built_plugin_suffix == '' }}
run: |
${{ steps.determine-dashboards-directory-zip-install.outputs.dashboards-directory }}/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}/build/${{ inputs.built_plugin_name }}-${{env.PLUGIN_VERSION}}.zip
shell: bash

- name: Install the plugin zip
if: ${{ inputs.install_zip == 'true' && inputs.built_plugin_suffix != '' }}
run: |
${{ steps.determine-dashboards-directory-zip-install.outputs.dashboards-directory }}/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}/build/${{ inputs.built_plugin_name }}-${{inputs.built_plugin_suffix}}.zip
shell: bash

- name: Replace opensearch_dashboards.yml file if applicable binary
if: ${{ inputs.opensearch_dashboards_yml != '' && inputs.install_zip == 'true' }}
run: |
mv ${{ inputs.opensearch_dashboards_yml }} ${{ steps.determine-dashboards-directory-zip-install.outputs.dashboards-directory }}/config/opensearch_dashboards.yml
shell: bash

- name: Replace opensearch_dashboards.yml file if applicable dev
if: ${{ inputs.opensearch_dashboards_yml != '' && inputs.install_zip != 'true' }}
run: |
mv ${{ inputs.opensearch_dashboards_yml }} ./OpenSearch-Dashboards/config/opensearch_dashboards.yml
shell: bash

- name: Print contents
run: |
cat ./OpenSearch-Dashboards/config/opensearch_dashboards.yml
shell: bash
Loading
Loading