forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (145 loc) · 5.97 KB
/
release_cypress_workflow.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
name: Orchestrator cypress workflow
run-name: release_cypress_workflow ${{ inputs.UNIQUE_ID != '' && inputs.UNIQUE_ID || '' }} # Unique id number appended to the workflow run-name to reference the run within the orchestrator.
# Trigger on dispatch event sent from FT repo orchestrator
on:
workflow_dispatch:
inputs:
test_repo:
description: 'Cypress test repo'
default: ''
required: false
type: string
test_branch:
description: 'Cypress test branch (default: source branch)'
required: false
type: string
specs:
description: 'Test group to run'
required: false
type: string
build_id:
description: 'Build Id'
required: false
type: string
OS_URL:
description: 'OpenSearch release artifact'
required: false
type: string
OSD_URL:
description: 'OpenSearch Dashboards release artifact'
required: false
type: string
UNIQUE_ID:
description: 'Unique Id for the workflow execution'
required: true
type: string
SECURITY_ENABLED:
required: false
type: string
env:
TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || github.repository }}
TEST_BRANCH: "${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }}"
OSD_PATH: 'osd'
CYPRESS_BROWSER: 'electron'
JOB_ID: ${{ inputs.UNIQUE_ID}}
OPENSEARCH: ${{ inputs.OS_URL != '' && inputs.OS_URL || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/latest/linux/x64/tar/dist/opensearch/opensearch-$VERSION-linux-x64.tar.gz' }}
DASHBOARDS: ${{ inputs.OSD_URL != '' && inputs.OSD_URL || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/$VERSION/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-$VERSION-linux-x64.tar.gz' }}
OPENSEARCH_DIR: 'cypress/opensearch'
DASHBOARDS_DIR: 'cypress/opensearch-dashboards'
SECURITY_ENABLED: ${{ inputs.SECURITY_ENABLED != '' && inputs.SECURITY_ENABLED || 'false' }}
jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch-dashboards
cypress-tests:
needs: Get-CI-Image-Tag
runs-on: ubuntu-latest
strategy:
matrix:
spec_group: [10, 11] # Add more spec files as needed
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: --user root
env:
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
name: Run cypress tests (osd:ciGroup${{ matrix.spec_group }}) ${{ inputs.UNIQUE_ID}}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: ./${{ env.OSD_PATH }}
repository: ${{ env.TEST_REPO }}
ref: '${{ env.TEST_BRANCH }}'
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './${{ env.OSD_PATH }}/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Setup Yarn
run: |
npm uninstall -g yarn
npm i -g yarn@1.22.10
yarn config set network-timeout 1000000 -g
- name: Setup spec files
if: ${{ inputs.specs == '' }}
shell: bash
run: |
cd ${{ env.OSD_PATH }}
IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.spec_group }})
FORMATTED_SPEC=''
for i in "${SPEC_ARRAY[@]}"; do
FORMATTED_SPEC+="cypress/integration/core_opensearch_dashboards/${i},"
done
SPEC=${FORMATTED_SPEC} # Set SPEC to FORMATTED_SPEC
echo "SPEC=${FORMATTED_SPEC}" >> $GITHUB_ENV
echo "SPEC found: $SPEC"
- name: Get Cypress version
id: cypress_version
run: |
echo "name=cypress_version::$(cat ./${{ env.OSD_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')" >> $GITHUB_OUTPUT
- name: Get package version (Linux)
run: |
cd ${{ env.OSD_PATH }}
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
- name: Run bootstrap
run: |
cd ${{ env.OSD_PATH }}
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
yarn osd bootstrap"
- name: Download and extract OpenSearch artifacts
run: |
CWD=$(pwd)
mkdir -p $CWD/${{ env.OPENSEARCH_DIR }}
source ${{ env.OSD_PATH }}/scripts/common/utils.sh
open_artifact $CWD/${{ env.OPENSEARCH_DIR }} ${{ env.OPENSEARCH }}
- name: Download and extract OpenSearch Dashboards artifacts
run: |
CWD=$(pwd)
mkdir -p $CWD/${{ env.DASHBOARDS_DIR }}
source ${{ env.OSD_PATH }}/scripts/common/utils.sh
open_artifact $CWD/${{ env.DASHBOARDS_DIR }} ${{ env.DASHBOARDS }}
- name: Run Cypress tests
run: |
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "source ${{ env.OSD_PATH }}/scripts/cypress_tests.sh && run_dashboards_cypress_tests"
# Screenshots are only captured on failures
- uses: actions/upload-artifact@v3
if: failure()
with:
name: release-osd-cypress-screenshots
path: ${{ env.OSD_PATH }}/cypress/screenshots
retention-days: 1
- uses: actions/upload-artifact@v3
if: always()
with:
name: release-osd-cypress-videos
path: ${{ env.OSD_PATH }}/cypress/videos
retention-days: 1