|
| 1 | +name: Build and test workflow |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "*" |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - "*" |
| 9 | +env: |
| 10 | + OPENSEARCH_DASHBOARDS_VERSION: 'main' |
| 11 | + |
| 12 | +jobs: |
| 13 | + Get-CI-Image-Tag: |
| 14 | + uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main |
| 15 | + with: |
| 16 | + product: opensearch-dashboards |
| 17 | + |
| 18 | + build-and-test-linux: |
| 19 | + needs: Get-CI-Image-Tag |
| 20 | + name: Build the plugin and run unit tests |
| 21 | + runs-on: ubuntu-latest |
| 22 | + container: |
| 23 | + # using the same image which is used by opensearch-build team to build the OpenSearch Distribution |
| 24 | + # this image tag is subject to change as more dependencies and updates will arrive over time |
| 25 | + image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} |
| 26 | + # need to switch to root so that github actions can install runner binary on container without permission issues. |
| 27 | + options: --user root |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout OpenSearch Dashboards |
| 31 | + uses: actions/checkout@v2 |
| 32 | + with: |
| 33 | + repository: opensearch-project/OpenSearch-Dashboards |
| 34 | + ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }} |
| 35 | + path: OpenSearch-Dashboards |
| 36 | + - name: Checkout Anomaly Detection OpenSearch Dashboards plugin |
| 37 | + uses: actions/checkout@v2 |
| 38 | + with: |
| 39 | + path: OpenSearch-Dashboards/plugins/anomaly-detection-dashboards-plugin |
| 40 | + - name: Bootstrap / build / unit test the plugin |
| 41 | + run: | |
| 42 | + chown -R 1000:1000 `pwd` |
| 43 | + cd ./OpenSearch-Dashboards/ |
| 44 | + su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && |
| 45 | + cd ./plugins/anomaly-detection-dashboards-plugin && |
| 46 | + whoami && yarn osd bootstrap && yarn build && yarn run test:jest --coverage" |
| 47 | + - name: Uploads coverage |
| 48 | + uses: codecov/codecov-action@v1 |
| 49 | + |
| 50 | + # TODO: once github actions supports windows and macos docker containers, we can |
| 51 | + # merge these in to the above step's matrix. |
| 52 | + build-and-test-windows-macos: |
| 53 | + name: Build the plugin and run unit tests |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + os: [macos-latest, windows-latest] |
| 57 | + runs-on: ${{ matrix.os }} |
| 58 | + steps: |
| 59 | + # Enable longer filenames for windows |
| 60 | + - name: Enable longer filenames |
| 61 | + if: ${{ matrix.os == 'windows-latest' }} |
| 62 | + run: git config --system core.longpaths true |
| 63 | + - name: Checkout OpenSearch Dashboards |
| 64 | + uses: actions/checkout@v2 |
| 65 | + with: |
| 66 | + repository: opensearch-project/OpenSearch-Dashboards |
| 67 | + ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }} |
| 68 | + path: OpenSearch-Dashboards |
| 69 | + - name: Setup Node |
| 70 | + uses: actions/setup-node@v3 |
| 71 | + with: |
| 72 | + node-version-file: './OpenSearch-Dashboards/.nvmrc' |
| 73 | + registry-url: 'https://registry.npmjs.org' |
| 74 | + - name: Install Yarn |
| 75 | + # Need to use bash to avoid having a windows/linux specific step |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn") |
| 79 | + echo "Installing yarn@$YARN_VERSION" |
| 80 | + npm i -g yarn@$YARN_VERSION |
| 81 | + - run: node -v |
| 82 | + - run: yarn -v |
| 83 | + - name: Checkout Anomaly Detection OpenSearch Dashboards plugin |
| 84 | + uses: actions/checkout@v2 |
| 85 | + with: |
| 86 | + path: OpenSearch-Dashboards/plugins/anomaly-detection-dashboards-plugin |
| 87 | + - name: Bootstrap the plugin |
| 88 | + run: | |
| 89 | + cd OpenSearch-Dashboards/plugins/anomaly-detection-dashboards-plugin |
| 90 | + yarn osd bootstrap |
| 91 | + - name: Build the plugin |
| 92 | + run: | |
| 93 | + cd OpenSearch-Dashboards/plugins/anomaly-detection-dashboards-plugin |
| 94 | + yarn build |
| 95 | + - name: Run unit tests |
| 96 | + run: | |
| 97 | + cd OpenSearch-Dashboards/plugins/anomaly-detection-dashboards-plugin |
| 98 | + yarn run test:jest --coverage |
| 99 | + - name: Uploads coverage |
| 100 | + uses: codecov/codecov-action@v1 |
| 101 | + |
0 commit comments