|
| 1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: Build and test |
| 5 | + |
| 6 | +# trigger on every commit push and PR for all branches except feature branches and pushes for backport branches |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [ '**', '!feature/**', '!backport/**' ] |
| 10 | + paths-ignore: |
| 11 | + - '**/*.md' |
| 12 | + pull_request: |
| 13 | + branches: [ '**', '!feature/**' ] |
| 14 | + paths-ignore: |
| 15 | + - '**/*.md' |
| 16 | + |
| 17 | +env: |
| 18 | + TEST_BROWSER_HEADLESS: 1 |
| 19 | + CI: 1 |
| 20 | + GCS_UPLOAD_PREFIX: fake |
| 21 | + TEST_OPENSEARCH_DASHBOARDS_HOST: localhost |
| 22 | + TEST_OPENSEARCH_DASHBOARDS_PORT: 6610 |
| 23 | + TEST_OPENSEARCH_TRANSPORT_PORT: 9403 |
| 24 | + TEST_OPENSEARCH_PORT: 9400 |
| 25 | + OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + build-lint-test: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + container: |
| 31 | + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 |
| 32 | + options: --user 1001 |
| 33 | + name: Build and Verify |
| 34 | + steps: |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Setup Node |
| 39 | + uses: actions/setup-node@v2 |
| 40 | + with: |
| 41 | + node-version-file: '.nvmrc' |
| 42 | + registry-url: 'https://registry.npmjs.org' |
| 43 | + |
| 44 | + - name: Setup Yarn |
| 45 | + run: | |
| 46 | + npm uninstall -g yarn |
| 47 | + npm i -g yarn@1.22.10 |
| 48 | +
|
| 49 | + - name: Run bootstrap |
| 50 | + run: yarn osd bootstrap |
| 51 | + |
| 52 | + - name: Run linter |
| 53 | + id: linter |
| 54 | + run: yarn lint |
| 55 | + |
| 56 | + - name: Run unit tests with coverage |
| 57 | + id: unit-tests |
| 58 | + run: yarn test:jest:ci:coverage |
| 59 | + |
| 60 | + - name: Run mocha tests with coverage |
| 61 | + id: mocha-tests |
| 62 | + run: yarn test:mocha:coverage |
| 63 | + |
| 64 | + - name: Upload Code Coverage |
| 65 | + id: upload-code-coverage |
| 66 | + uses: codecov/codecov-action@v3 |
| 67 | + with: |
| 68 | + directory: ./target/opensearch-dashboards-coverage |
| 69 | + |
| 70 | + - name: Run integration tests |
| 71 | + id: integration-tests |
| 72 | + run: yarn test:jest_integration:ci |
| 73 | + |
| 74 | + functional-tests: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + container: |
| 77 | + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 |
| 78 | + options: --user 1001 |
| 79 | + name: Run functional tests |
| 80 | + strategy: |
| 81 | + matrix: |
| 82 | + group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] |
| 83 | + steps: |
| 84 | + - run: echo Running functional tests for ciGroup${{ matrix.group }} |
| 85 | + |
| 86 | + - name: Checkout code |
| 87 | + uses: actions/checkout@v2 |
| 88 | + |
| 89 | + - name: Setup Node |
| 90 | + uses: actions/setup-node@v2 |
| 91 | + with: |
| 92 | + node-version-file: '.nvmrc' |
| 93 | + registry-url: 'https://registry.npmjs.org' |
| 94 | + |
| 95 | + - name: Setup Yarn |
| 96 | + run: | |
| 97 | + npm uninstall -g yarn |
| 98 | + npm i -g yarn@1.22.10 |
| 99 | +
|
| 100 | + # image has the latest chrome v99 |
| 101 | + - name: Setup chromedriver |
| 102 | + run: yarn add --dev chromedriver@99.0.0 |
| 103 | + |
| 104 | + - name: Run bootstrap |
| 105 | + run: yarn osd bootstrap |
| 106 | + |
| 107 | + - name: Build plugins |
| 108 | + run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 |
| 109 | + |
| 110 | + - name: Run CI test group ${{ matrix.group }} |
| 111 | + id: ftr-tests |
| 112 | + run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} |
| 113 | + env: |
| 114 | + CI_GROUP: ciGroup${{ matrix.group }} |
| 115 | + CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} |
| 116 | + JOB: ci${{ matrix.group }} |
| 117 | + CACHE_DIR: ciGroup${{ matrix.group }} |
| 118 | + |
| 119 | + build-min-artifact-tests: |
| 120 | + runs-on: ubuntu-latest |
| 121 | + container: |
| 122 | + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 |
| 123 | + options: --user 1001 |
| 124 | + name: Build min release artifacts |
| 125 | + defaults: |
| 126 | + run: |
| 127 | + working-directory: ./artifacts |
| 128 | + strategy: |
| 129 | + matrix: |
| 130 | + include: |
| 131 | + - name: Linux x64 |
| 132 | + ext: tar.gz |
| 133 | + suffix: linux-x64 |
| 134 | + script: build-platform --linux --skip-os-packages |
| 135 | + - name: Linux ARM64 |
| 136 | + ext: tar.gz |
| 137 | + suffix: linux-arm64 |
| 138 | + script: build-platform --linux-arm --skip-os-packages |
| 139 | + steps: |
| 140 | + - name: Checkout code |
| 141 | + uses: actions/checkout@v2 |
| 142 | + with: |
| 143 | + path: ./artifacts |
| 144 | + |
| 145 | + - name: Setup Node |
| 146 | + uses: actions/setup-node@v2 |
| 147 | + with: |
| 148 | + node-version-file: './artifacts/.nvmrc' |
| 149 | + registry-url: 'https://registry.npmjs.org' |
| 150 | + |
| 151 | + - name: Setup Yarn |
| 152 | + run: | |
| 153 | + npm uninstall -g yarn |
| 154 | + npm i -g yarn@1.22.10 |
| 155 | +
|
| 156 | + - name: Get package version |
| 157 | + run: | |
| 158 | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV |
| 159 | +
|
| 160 | + - name: Get artifact build name |
| 161 | + run: | |
| 162 | + echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV |
| 163 | +
|
| 164 | + - name: Run bootstrap |
| 165 | + run: yarn osd bootstrap |
| 166 | + |
| 167 | + - name: Build `${{ matrix.name }}` |
| 168 | + run: yarn ${{ matrix.script }} --release |
| 169 | + |
| 170 | + - uses: actions/upload-artifact@v3 |
| 171 | + if: success() |
| 172 | + with: |
| 173 | + name: ${{ matrix.suffix }}-${{ env.VERSION }} |
| 174 | + path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} |
| 175 | + retention-days: 1 |
| 176 | + |
| 177 | + bwc-tests: |
| 178 | + needs: [build-min-artifact-tests] |
| 179 | + runs-on: ubuntu-latest |
| 180 | + container: |
| 181 | + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 |
| 182 | + options: --user 1001 |
| 183 | + name: Run backwards compatibility tests |
| 184 | + defaults: |
| 185 | + run: |
| 186 | + working-directory: ./artifacts |
| 187 | + strategy: |
| 188 | + matrix: |
| 189 | + version: [ osd-2.0.0, osd-2.1.0, osd-2.2.0, osd-2.3.0 ] |
| 190 | + steps: |
| 191 | + - name: Checkout code |
| 192 | + uses: actions/checkout@v2 |
| 193 | + with: |
| 194 | + path: ./artifacts |
| 195 | + |
| 196 | + - run: echo Running backwards compatibility tests for version ${{ matrix.version }} |
| 197 | + - run: echo [NOTE] These tests will be ran using Linux x64 release builds without security |
| 198 | + |
| 199 | + - name: Setup Node |
| 200 | + uses: actions/setup-node@v2 |
| 201 | + with: |
| 202 | + node-version-file: './artifacts/.nvmrc' |
| 203 | + registry-url: 'https://registry.npmjs.org' |
| 204 | + |
| 205 | + - name: Setup Yarn |
| 206 | + run: | |
| 207 | + npm uninstall -g yarn |
| 208 | + npm i -g yarn@1.22.10 |
| 209 | +
|
| 210 | + - name: Get package version |
| 211 | + run: | |
| 212 | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV |
| 213 | +
|
| 214 | + - name: Set OpenSearch URL |
| 215 | + run: | |
| 216 | + echo "OPENSEARCH_URL=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch/opensearch-${{ env.VERSION }}-linux-x64.tar.gz" >> $GITHUB_ENV |
| 217 | +
|
| 218 | + - name: Verify if OpenSearch is available for version |
| 219 | + id: verify-opensearch-exists |
| 220 | + run: | |
| 221 | + if curl -I -L ${{ env.OPENSEARCH_URL }}; then |
| 222 | + echo "::set-output name=version-exists::true" |
| 223 | + fi |
| 224 | +
|
| 225 | + - name: Skipping tests |
| 226 | + if: steps.verify-opensearch-exists.outputs.version-exists != 'true' |
| 227 | + run: echo Tests were skipped because an OpenSearch release build does not exist for this version yet! |
| 228 | + |
| 229 | + - name: Setting environment variable to run tests for ${{ matrix.version }} |
| 230 | + if: steps.verify-opensearch-exists.outputs.version-exists == 'true' |
| 231 | + run: echo "BWC_VERSIONS=${{ matrix.version }}" >> $GITHUB_ENV |
| 232 | + |
| 233 | + - name: Download OpenSearch Dashboards |
| 234 | + uses: actions/download-artifact@v3 |
| 235 | + id: download |
| 236 | + with: |
| 237 | + name: linux-x64-${{ env.VERSION }} |
| 238 | + path: ./artifacts/ |
| 239 | + if: steps.verify-opensearch-exists.outputs.version-exists == 'true' |
| 240 | + |
| 241 | + - name: Run tests |
| 242 | + if: steps.verify-opensearch-exists.outputs.version-exists == 'true' |
| 243 | + run: | |
| 244 | + ./bwctest.sh -s false -o ${{ env.OPENSEARCH_URL }} -d ${{ steps.download.outputs.download-path }}/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz |
| 245 | +
|
| 246 | + - uses: actions/upload-artifact@v3 |
| 247 | + if: ${{ failure() && steps.verify-opensearch-exists.outputs.version-exists == 'true' }} |
| 248 | + with: |
| 249 | + name: ${{ matrix.version }}-test-failures |
| 250 | + path: | |
| 251 | + ./artifacts/bwc_tmp/test/cypress/videos/without-security/* |
| 252 | + ./artifacts/bwc_tmp/test/cypress/screenshots/without-security/* |
| 253 | + retention-days: 1 |
0 commit comments