diff --git a/.github/workflows/build_and_test_workflow.yml b/.github/workflows/build_and_test_workflow.yml index bd5845ae9c8..e77d3490bfb 100644 --- a/.github/workflows/build_and_test_workflow.yml +++ b/.github/workflows/build_and_test_workflow.yml @@ -27,81 +27,28 @@ env: OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true jobs: - build-lint-test-linux: - runs-on: ubuntu-latest - container: - image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 - options: --user 1001 - name: Build and Verify on Linux - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: '.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: Configure Yarn Cache - run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV - - - name: Initialize Yarn Cache - uses: actions/cache@v3 - with: - path: ${{ env.YARN_CACHE_LOCATION }} - key: yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - yarn- - - - name: Run bootstrap - run: yarn osd bootstrap - - - name: Run linter - id: linter - run: yarn lint - - - name: Validate NOTICE file - id: notice-validate - run: yarn notice:validate - - - name: Run unit tests with coverage - id: unit-tests - run: yarn test:jest:ci:coverage - - - name: Run mocha tests with coverage - id: mocha-tests - run: yarn test:mocha:coverage - - - name: Upload Code Coverage - id: upload-code-coverage - uses: codecov/codecov-action@v3 - with: - directory: ./target/opensearch-dashboards-coverage - flags: Linux - - - name: Run integration tests - id: integration-tests - run: yarn test:jest_integration:ci - - build-lint-test-windows: - runs-on: windows-latest - name: Build and Verify on Windows + build-lint-test: + name: Build and Verify on ${{ matrix.name }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + include: + - os: ubuntu-latest + name: Linux + - os: windows-latest + name: Windows + runs-on: ${{ matrix.os }} steps: - - name: Configure git's autocrlf + - name: Configure git's autocrlf (Windows only) + if: matrix.os == 'windows-latest' run: | git config --global core.autocrlf false - name: Checkout code uses: actions/checkout@v3 - - name: Setup JDK + - name: Setup JDK (Windows only) + if: matrix.os == 'windows-latest' uses: actions/setup-java@v3 with: java-version: '11' @@ -119,7 +66,12 @@ jobs: npm i -g yarn@1.22.10 yarn config set network-timeout 1000000 -g - - name: Configure Yarn Cache + - name: Configure Yarn Cache (Linux) + if: matrix.os != 'windows-latest' + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Configure Yarn Cache (Windows) + if: matrix.os == 'windows-latest' run: | echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" @@ -132,7 +84,12 @@ jobs: restore-keys: | yarn- - - name: Run bootstrap + - name: Run bootstrap (Linux) + if: matrix.os != 'windows-latest' + run: yarn osd bootstrap + + - name: Run bootstrap (Windows) + if: matrix.os == 'windows-latest' run: yarn osd bootstrap || yarn osd bootstrap - name: Run linter @@ -156,93 +113,37 @@ jobs: uses: codecov/codecov-action@v3 with: directory: ./target/opensearch-dashboards-coverage - flags: Windows + flags: ${{ matrix.name }} - name: Run integration tests id: integration-tests run: yarn test:jest_integration:ci - functional-tests-linux: - runs-on: ubuntu-latest - container: - image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 - options: --user 1001 - name: Run functional tests on Linux + functional-tests: + name: Run functional tests on ${{ matrix.name }} (ciGroup${{ matrix.group }}) strategy: matrix: - group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] - steps: - - run: echo Running functional tests for ciGroup${{ matrix.group }} - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: '.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: Configure Yarn Cache - run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV - - - name: Initialize Yarn Cache - uses: actions/cache@v3 - with: - path: ${{ env.YARN_CACHE_LOCATION }} - key: yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - yarn- - - - name: Setup chromedriver - run: node scripts/upgrade_chromedriver.js - - - name: Run bootstrap - run: yarn osd bootstrap - - - name: Build plugins - run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 - - - name: Run CI test group ${{ matrix.group }} - id: ftr-tests - run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} - env: - CI_GROUP: ciGroup${{ matrix.group }} - CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} - JOB: ci${{ matrix.group }} - CACHE_DIR: ciGroup${{ matrix.group }} - - - uses: actions/upload-artifact@v3 - if: failure() - with: - name: failure-artifacts - path: | - test/*/failure_debug/ - test/*/screenshots/ - - functional-tests-windows: - runs-on: windows-latest - name: Run functional tests on Windows - strategy: - matrix: - group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] + os: [ubuntu-latest, windows-latest] + group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] + include: + - os: ubuntu-latest + name: Linux + - os: windows-latest + name: Windows + runs-on: ${{ matrix.os }} steps: - run: echo Running functional tests for ciGroup${{ matrix.group }} - - name: Configure git's autocrlf + - name: Configure git's autocrlf (Windows only) + if: matrix.os == 'windows-latest' run: | git config --global core.autocrlf false - name: Checkout code uses: actions/checkout@v3 - - name: Setup JDK + - name: Setup JDK (Windows only) + if: matrix.os == 'windows-latest' uses: actions/setup-java@v3 with: java-version: '11' @@ -260,7 +161,12 @@ jobs: npm i -g yarn@1.22.10 yarn config set network-timeout 1000000 -g - - name: Configure Yarn Cache + - name: Configure Yarn Cache (Linux) + if: matrix.os != 'windows-latest' + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Configure Yarn Cache (Windows) + if: matrix.os == 'windows-latest' run: | echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" @@ -276,7 +182,12 @@ jobs: - name: Setup chromedriver run: node scripts/upgrade_chromedriver.js - - name: Run bootstrap + - name: Run bootstrap (Linux) + if: matrix.os != 'windows-latest' + run: yarn osd bootstrap + + - name: Run bootstrap (Windows) + if: matrix.os == 'windows-latest' run: yarn osd bootstrap || yarn osd bootstrap - name: Build plugins @@ -299,91 +210,33 @@ jobs: test/*/failure_debug/ test/*/screenshots/ - build-min-artifact-tests-linux: - runs-on: ubuntu-latest - container: - image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 - options: --user 1001 - name: Build min release artifacts on Linux - defaults: - run: - working-directory: ./artifacts + build-min-artifact-tests: + name: Build min release artifacts on ${{ matrix.name }} strategy: matrix: include: - - name: Linux x64 + - os: ubuntu-latest + name: Linux x64 ext: tar.gz suffix: linux-x64 script: build-platform --linux --skip-os-packages - - name: Linux ARM64 + - os: ubuntu-latest + name: Linux ARM64 ext: tar.gz suffix: linux-arm64 script: build-platform --linux-arm --skip-os-packages - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - path: ./artifacts - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: './artifacts/.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: Configure Yarn Cache - run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV - - - name: Initialize Yarn Cache - uses: actions/cache@v3 - with: - path: ${{ env.YARN_CACHE_LOCATION }} - key: yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - yarn- - - - name: Get package version - run: | - echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV - - - name: Get artifact build name - run: | - echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV - - - name: Run bootstrap - run: yarn osd bootstrap - - - name: Build `${{ matrix.name }}` - run: yarn ${{ matrix.script }} --release - - - uses: actions/upload-artifact@v3 - if: success() - with: - name: ${{ matrix.suffix }}-${{ env.VERSION }} - path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} - retention-days: 1 - - build-min-artifact-tests-windows: - runs-on: windows-latest - name: Build min release artifacts on Windows - defaults: - run: - working-directory: artifacts - strategy: - matrix: - include: - - name: Windows x64 + - os: windows-latest + name: Windows x64 ext: zip suffix: windows-x64 script: build-platform --windows --skip-os-packages + runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: ./artifacts steps: - - name: Configure git's autocrlf + - name: Configure git's autocrlf (Windows only) + if: matrix.os == 'windows-latest' run: | git config --global core.autocrlf false working-directory: . @@ -391,12 +244,12 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - path: artifacts + path: ./artifacts - name: Setup Node uses: actions/setup-node@v3 with: - node-version-file: 'artifacts/.nvmrc' + node-version-file: './artifacts/.nvmrc' registry-url: 'https://registry.npmjs.org' - name: Setup Yarn @@ -405,7 +258,12 @@ jobs: npm i -g yarn@1.22.10 yarn config set network-timeout 1000000 -g - - name: Configure Yarn Cache + - name: Configure Yarn Cache (Linux) + if: matrix.os != 'windows-latest' + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Configure Yarn Cache (Windows) + if: matrix.os == 'windows-latest' run: | echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" @@ -418,11 +276,23 @@ jobs: restore-keys: | yarn- - - name: Get package version + - name: Get package version (Linux) + if: matrix.os != 'windows-latest' + run: | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV + + - name: Get artifact build name (Linux) + if: matrix.os != 'windows-latest' + run: | + echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV + + - name: Get package version (Windows) + if: matrix.os == 'windows-latest' run: | echo "VERSION=$(yarn --silent pkg-version)" >> $env:GITHUB_ENV - - name: Get artifact build name + - name: Get artifact build name (Windows) + if: matrix.os == 'windows-latest' run: | echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $env:GITHUB_ENV @@ -436,11 +306,11 @@ jobs: if: success() with: name: ${{ matrix.suffix }}-${{ env.VERSION }} - path: artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} + path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} retention-days: 1 bwc-tests: - needs: [build-min-artifact-tests-linux] + needs: [build-min-artifact-tests] runs-on: ubuntu-latest container: image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1e354ba99..18dd5f24b20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [CI] Automate ChromeDriver installation for running functional tests ([#2990](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2990)) - Create the Release Notes for the 1.3.7 release ([#3066](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3066)) - [CI] Improve workflows by retaining Yarn's cache folder ([#3194](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3194)) +- [CI] Reduce redundancy by using matrix strategy on Windows and Linux workflows ([#3514](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3514)) ### 📝 Documentation