-
Notifications
You must be signed in to change notification settings - Fork 159
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
Support Windows runner for CI workflows #1275
Changes from 64 commits
3434d63
59e6a36
2e3aae4
02f785c
ba4f774
8c6162d
58dbad1
ad6fe0f
1069183
8b216d9
864bdd7
0a95a68
235ca60
3b3f1e8
93e73c7
6284ec4
4387414
236ad95
1a6def3
0468402
2b117ae
6ad568b
4a62d9f
f7dba31
82e3a9c
a7cd2b2
00986d2
787c9ba
facdfe5
9326f3f
5edfd44
6204d6a
07a2f85
b66d256
9fcb57e
e0880e7
9ea1746
8c7111e
068373d
af37758
aed95c2
95c793f
722851f
50c48f2
fc01542
d6966e9
869cf3b
cc596f4
ca7c6dd
c619e88
9a9b362
bb352bb
b3dc358
8b798eb
a11e5ae
57b9c58
8dde509
af67535
84dd998
9954325
1836b5b
dc40463
a304c2c
5e4542b
895c627
6ae66d6
91da046
f49f3d6
6100ab8
c4f2472
3dbbe4d
9da6a34
0c95b14
677e6c1
6a6c6e2
e9fcee4
edfd2f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ outputs: | |
plugin-directory: | ||
description: "The directory where the plugin has been configured" | ||
value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} | ||
|
||
|
||
runs: | ||
using: "composite" | ||
|
@@ -33,28 +34,39 @@ runs: | |
ref: 'main' | ||
fetch-depth: 0 | ||
|
||
- run: mkdir -p plugins | ||
working-directory: OpenSearch-Dashboards | ||
shell: bash | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} | ||
|
||
- id: osd-version | ||
continue-on-error: true | ||
- id: osd-version-linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: | | ||
echo "::set-output name=osd-version::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-4)" | ||
echo "::set-output name=osd-version-linux::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-4)" | ||
echo "::set-output name=osd-x-version::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-3)" | ||
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} | ||
shell: bash | ||
|
||
- id: branch-switch-if-possible | ||
- id: osd-version-windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: | | ||
echo "::set-output name=osd-version-linux::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-4)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean |
||
echo "::set-output name=osd-x-version::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-3)" | ||
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} | ||
shell: pwsh | ||
|
||
- id: branch-switch-if-possible-linux | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 }}x | ||
if: ${{ runner.os == 'Linux' && steps.osd-version-linux.outputs.osd-version-linux }} | ||
run: git checkout ${{ steps.osd-version-linux.outputs.osd-version }} || git checkout ${{ steps.osd-version-linux.outputs.osd-x-version }}x | ||
working-directory: ./OpenSearch-Dashboards | ||
shell: bash | ||
|
||
- id: branch-switch-if-possible-windows | ||
continue-on-error: true # Defaults onto main if the branch switch doesn't work | ||
if: ${{ runner.os == 'Windows' && steps.osd-version-linux.outputs.osd-version-windows }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above: |
||
run: git checkout ${{ steps.osd-version-windows.outputs.osd-version }} || git checkout ${{ steps.osd-version-windows.outputs.osd-x-version }}x | ||
working-directory: ./OpenSearch-Dashboards | ||
shell: pwsh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you seeing a difference between bash/pwsh when running these commands? If it does, use |
||
|
||
- id: tool-versions | ||
run: | | ||
|
@@ -68,14 +80,30 @@ runs: | |
node-version: ${{ steps.tool-versions.outputs.node_version }} | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- run: | | ||
- name: Setup Opensearch Dashboards on Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
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 | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
working-directory: OpenSearch-Dashboards | ||
shell: bash | ||
|
||
- uses: nick-fields/retry@v2 | ||
- name: Setup Opensearch Dashboards on Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
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: pwsh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks identical to the step above except shell type. you can use action conditions to specify the shell at run time |
||
|
||
- name: Bootstrap the OpenSearch Dashboard | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: nick-fields/retry@v2 | ||
with: | ||
timeout_minutes: 20 | ||
max_attempts: 2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Cypress Tests | ||
|
||
on: [push, pull_request] | ||
on: [ push, pull_request ] | ||
|
||
env: | ||
TEST_BROWSER_HEADLESS: 1 | ||
|
@@ -16,22 +16,45 @@ env: | |
jobs: | ||
tests: | ||
name: Run Cypress tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest , windows-latest ] | ||
jdk: [ 11, 17 ] | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.jdk }} | ||
|
||
- name: Checkout Branch | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download OpenSearch Security Plugin | ||
- name: Download OpenSearch Security Plugin on Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: wget --progress=bar:force:noscroll -O opensearch-security.zip https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.OPENSEARCH_VERSION }}/latest/linux/x64/tar/builds/opensearch/plugins/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip | ||
|
||
- name: Create Setup Script | ||
- name: Download OpenSearch Security Plugin on Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: Invoke-WebRequest -Uri https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.OPENSEARCH_VERSION }}/latest/windows/x64/zip/builds/opensearch/plugins/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip -Outfile opensearch-security.zip | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Create Setup Script for Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: | | ||
cat > setup.sh <<'EOF' | ||
chmod +x ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/plugins/${{ env.PLUGIN_NAME }}/tools/install_demo_configuration.sh | ||
/bin/bash -c "yes | ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/plugins/${{ env.PLUGIN_NAME }}/tools/install_demo_configuration.sh" | ||
EOF | ||
|
||
- name: Create Setup Script for Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: | | ||
New-Item .\setup.bat -type file | ||
Set-Content .\setup.bat -Value "powershell.exe -noexit -command `".\opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT\plugins\${{ env.PLUGIN_NAME }}\tools\install_demo_configuration.bat -y -i -c`"" | ||
Get-Content .\setup.bat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See if you can use action condition to combine this step with the one above using action conditions |
||
|
||
- name: Run Opensearch with A Single Plugin | ||
uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main | ||
with: | ||
|
@@ -44,8 +67,7 @@ jobs: | |
with: | ||
plugin_name: security-dashboards-plugin | ||
|
||
- name: Configure and Run OpenSearch Dashboards | ||
continue-on-error: false | ||
- name: Configure and Run OpenSearch Dashboards with Cypress Test Cases | ||
run: | | ||
cd ./OpenSearch-Dashboards | ||
echo 'server.host: "0.0.0.0"' >> ./config/opensearch_dashboards.yml | ||
|
@@ -59,23 +81,9 @@ jobs: | |
echo 'opensearch_security.readonly_mode.roles: ["kibana_read_only"]' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch_security.cookie.secure: false' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch_security.multitenancy.enable_aggregation_view: true' >> ./config/opensearch_dashboards.yml | ||
yarn start --no-base-path --no-watch & | ||
sleep 300 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ${{ env.FTR_PATH }} | ||
repository: opensearch-project/opensearch-dashboards-functional-test | ||
ref: 'main' | ||
|
||
- name: Get Cypress version | ||
id: cypress_version | ||
run: | | ||
echo "::set-output name=cypress_version::$(cat ./${{ env.FTR_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')" | ||
|
||
- name: Run tests | ||
uses: cypress-io/github-action@v2 | ||
with: | ||
working-directory: ${{ env.FTR_PATH }} | ||
command: yarn cypress:run-with-security-and-aggregation-view --browser chromium --spec ${{ env.SPEC }} | ||
nohup yarn start --no-base-path --no-watch & | ||
sleep 500 | ||
git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test.git | ||
cd opensearch-dashboards-functional-test | ||
npm install cypress --save-dev | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
yarn cypress:run-with-security-and-aggregation-view --browser chrome --spec "cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,21 +12,49 @@ env: | |
jobs: | ||
tests: | ||
name: Run integration tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest , windows-latest ] | ||
jdk: [ 11, 17 ] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout Branch | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.jdk }} | ||
|
||
- uses: browser-actions/setup-geckodriver@latest | ||
RyanL1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- run: geckodriver --version | ||
|
||
- uses: browser-actions/setup-firefox@latest | ||
- run: firefox --version | ||
|
||
- name: Download OpenSearch Security Plugin | ||
- name: Set up Firefox browser for Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
uses: browser-actions/setup-firefox@latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note; this applies to a couple of different places in these changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review Peter! I have changed the firfox one to a specific version. But for the gecko I think it only has the version control of |
||
with: | ||
browser: firefox | ||
version: latest | ||
|
||
# Browser-action version does not work on Windows | ||
- name: Set up Firefox browser for Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
uses: RyanL1997/setup-browser@main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any changes in this fork, lets use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any changes in your fork, can you link the commit with the changes you needed? I'm fine using your fork and should use the same fork for both linux/windows workflows |
||
with: | ||
browser: firefox | ||
version: latest | ||
|
||
- name: Download OpenSearch Security Plugin on Linux | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets reduce the duplication between the cypress and integration tests workflow. There are a couple ways this can be done.
I would prefer the first option to make a common action they reuse, that could be re-used by other teams, what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review! I have created a new action for the plugin download and script setup~ |
||
if: ${{ runner.os == 'Linux' }} | ||
run: wget --progress=bar:force:noscroll -O opensearch-security.zip https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.OPENSEARCH_VERSION }}/latest/linux/x64/tar/builds/opensearch/plugins/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip | ||
|
||
- name: Create Setup Script | ||
- name: Download OpenSearch Security Plugin on Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: Invoke-WebRequest -Uri https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.OPENSEARCH_VERSION }}/latest/windows/x64/zip/builds/opensearch/plugins/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip -Outfile opensearch-security.zip | ||
|
||
- name: Create Setup Script for Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: | | ||
cat > setup.sh <<'EOF' | ||
|
@@ -35,6 +63,14 @@ jobs: | |
echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/config/opensearch.yml | ||
EOF | ||
|
||
- name: Create Setup Script for Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: | | ||
New-Item .\setup.bat -type file | ||
Set-Content .\setup.bat -Value "powershell.exe -noexit -command `".\opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT\plugins\${{ env.PLUGIN_NAME }}\tools\install_demo_configuration.bat -y -i -c`"" | ||
Add-Content -Path .\setup.bat -Value "echo plugins.security.unsupported.restapi.allow_securityconfig_modification: true >> .\opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT\config\opensearch.yml" | ||
Get-Content .\setup.bat | ||
|
||
- name: Run Opensearch with A Single Plugin | ||
uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main | ||
with: | ||
|
@@ -51,9 +87,18 @@ jobs: | |
run: node scripts/build_opensearch_dashboards_platform_plugins.js | ||
working-directory: ${{ steps.install-dashboards.outputs.dashboards-directory }} | ||
|
||
- name: Run integration tests | ||
- name: Run integration tests on Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: | | ||
echo "check if opensearch is ready" | ||
curl -XGET https://localhost:9200 -u 'admin:admin' -k | ||
yarn test:jest_server --coverage | ||
working-directory: ${{ steps.install-dashboards.outputs.plugin-directory }} | ||
|
||
- name: Run integration tests on Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: | | ||
echo "check if opensearch is ready" | ||
curl -XGET https://localhost:9200 -u 'admin:admin' -k | ||
node .\test\run_jest_tests.js --config .\test\jest.config.server.js --testPathIgnorePatterns saml_auth.test.ts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are all of the tests in |
||
working-directory: ${{ steps.install-dashboards.outputs.plugin-directory }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Unit Tests | ||
|
||
on: [push, pull_request] | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
unit-tests: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks identical to
osd-version-linux
, lets make this into a single command.