Skip to content
name: Cypress 12 experimental tests
on:
push:
branches: ['**']
pull_request:
branches: ['**']
paths-ignore:
- '**/*.md'
- 'docs/**'
- '.lycheeignore'
- 'CODEOWNERS'
- 'changelogs/fragments/**'
env:
CYPRESS_BROWSER: 'chromium'
NODE_OPTIONS: '--max-old-space-size=6144 --dns-result-order=ipv4first'
COVERAGE: true
PROJECT_ARTIFACT_NAME: 'project-artifact'
COMBINATIONS: |
[
[],
["SECURITY"],
["WORKSPACE", "DATA_SOURCE", "QUERY_ENHANCEMENTS", "USE_NEW_HOME_PAGE"]
]
jobs:
build-and-validate:
name: Build and validate
runs-on: ubuntu-latest
steps:
- name: Checkout code
if: false
uses: actions/checkout@v4
- name: Setup Node
if: false
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Setup Yarn
if: false
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Run bootstrap
if: false
run: yarn osd bootstrap
- name: Check for yarn.lock changes
if: false
run: |
if [[ `git status --porcelain yarn.lock` ]]; then
echo -e "\033[31mThe yarn.lock file is out of sync!\033[0m"
git diff
exit 1
fi
- name: Generate dev docs
if: false
run: yarn docs:generateDevDocs
- name: Check for dev docs changes
if: false
run: |
if [[ `git status --porcelain docs/_sidebar.md` ]]; then
echo -e "\033[31mThe dev docs are out of sync; run yarn docs:generateDevDocs and amend the PR.\033[0m"
git diff
exit 1
fi
- name: Run linter
if: false
id: linter
run: yarn lint
- name: Validate NOTICE file
if: false
id: notice-validate
run: yarn notice:validate
- name: Validate licenses
if: false
id: i18n-licenses
run: yarn checkLicenses
- name: Check i18n
if: false
id: i18n-check
run: yarn i18n:check
- name: Build plugins
if: false
run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10
- name: Upload artifact
if: false
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_ARTIFACT_NAME }}
path: .
retention-days: 1
include-hidden-files: true
prepare-cypress-matrix:
name: Prepare Cypress tests
needs: build-and-validate
runs-on: ubuntu-latest
outputs:
test-matrix: ${{ steps.create-list.outputs.list }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Trigger tests for combinations
id: create-list
run: |
inputs_array=()
process_spec() {
local spec_path="$1"
local spec_name="$2"
local counter=1
echo "$COMBINATIONS" | jq -c '.[]' | while read -r combo; do
echo "Preparing tests for $spec_name with combination $counter: $combo"
input_object=$(jq -n \
--arg spec_pattern "$spec_path" \
--arg run_flag "${spec_name}:${counter}" \
--argjson combo "$combo" \
'{
spec_pattern: $spec_pattern,
run_flag: $run_flag
} + ($combo | to_entries | map({key: .value, value: "true"}) | from_entries)')
echo "Generated input_object:"
echo "$input_object" | jq .
inputs_array+=("$input_object")
counter=$((counter + 1))
done
}
# Process spec files at the root
process_spec "cypress/integration/*.spec.js" "root"
# Process spec folders
for folder in ./cypress/integration/*/; do
folder_name=$(basename "$folder")
process_spec "cypress/integration/$folder_name/**/*.spec.js" "$folder_name"
done
# Create the final JSON output
json_output=$(printf '%s\n' "${inputs_array[@]}" | jq -s '{"include": .}')
echo "list=$json_output" >> $GITHUB_OUTPUT
# For debugging
echo "Generated matrix:"
echo "$json_output" | jq .
run-tests:
name: Run tests (cypress:${{ matrix.run_flag }})
needs: [prepare-cypress-matrix, build-and-validate]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.prepare-cypress-matrix.outputs.test-matrix) }}
fail-fast: false
steps:
- name: Download project artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PROJECT_ARTIFACT_NAME }}
path: . # This downloads the artifact to the current directory
- name: Display structure of downloaded files
run: |
ls -R
echo "Flag: ${{ matrix.run_flag }}"
echo "Spec pattern: ${{ matrix.spec_pattern }}"
echo "Security enabled: ${{ matrix.SECURITY || 'false' }}"
echo "Workspace enabled: ${{ matrix.WORKSPACE || 'false' }}"
echo "Data Source enabled: ${{ matrix.DATA_SOURCE || 'false' }}"
echo "Query Enhancements enabled: ${{ matrix.QUERY_ENHANCEMENTS || 'false' }}"
echo "New Home enabled: ${{ matrix.USE_NEW_HOME_PAGE || 'false' }}"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Setup Yarn
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Run bootstrap
run: yarn osd bootstrap
# Lock Chrome version until ChromeDriver's release pipeline is fixed
- name: Download Chrome
id: download-chrome
uses: abhi1693/[email protected]
with:
browser: chrome
# v122
version: 1250586
- name: Setup Chrome
run: |
sudo rm -rf /usr/bin/google-chrome /opt/google/chrome
sudo ln -s ${{steps.download-chrome.outputs.path}}/${{steps.download-chrome.outputs.binary}} /usr/bin/google-chrome
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Get package version
run: |
echo "OSD_VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
- name: Run OpenSearch
run: |
npm i osd-launcher -g
if [ "${{ matrix.SECURITY }}" = "true" ]; then
osd-launcher -os ${{ env.VERSION }} -p dummy --destination ~/
else
osd-launcher -os ${{ env.VERSION }} --no-security --no-plugins -p dummy --destination ~/
fi
/bin/bash -c ~/OpenSearch-v3.0.0/bin/opensearch &
- name: Run OSD
run: |
WORKSPACE_FLAG=$([ "${{ matrix.WORKSPACE }}" = "true" ] && echo "--workspace.enabled=true" || echo "--workspace.enabled=false")
DATA_SOURCE_FLAG=$([ "${{ matrix.DATA_SOURCE }}" = "true" ] && echo "--data_source.enabled=true" || echo "--data_source.enabled=false")
QUERY_ENHANCEMENTS_FLAG=$([ "${{ matrix.QUERY_ENHANCEMENTS }}" = "true" ] && echo "--uiSettings.overrides["query:enhancements:enabled"]=true" || echo "--uiSettings.overrides["query:enhancements:enabled"]=false")
USE_NEW_HOME_PAGE_FLAG=$([ "${{ matrix.USE_NEW_HOME_PAGE }}" = "true" ] && echo "--uiSettings.overrides["home:useNewHomePage"]=true" || echo "--uiSettings.overrides["home:useNewHomePage"]=false")
/bin/bash -c "node scripts/opensearch_dashboards --dev --no-base-path --no-watch --opensearch.ignoreVersionMismatch=true --opensearch.ssl.verificationMode=none --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false $WORKSPACE_FLAG $DATA_SOURCE_FLAG $QUERY_ENHANCEMENTS_FLAG USE_NEW_HOME_PAGE_FLAG" &
- name: Wait for 60 seconds
run: sleep 60s
shell: bash
- name: Run tests
run: yarn test:cypress --spec "${{ matrix.spec_pattern }}"
- name: Upload coverage
id: upload-code-coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
flags: "cypress:${{ matrix.run_flag }}"
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: "cypress:artifact:${{ matrix.run_flag }}"
path: |
cypress/screenshots
cypress/videos
coverage
retention-days: 1