From 6390397400c49e7fc3ef60a545f685e32c0cea9b Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 31 Oct 2023 18:24:52 -0400 Subject: [PATCH] Onboard jenkins prod docker images to github actions (#907) Signed-off-by: Peter Zhu --- .github/workflows/dco.yml | 18 ----- .github/workflows/release-workflow.yml | 95 ----------------------- .github/workflows/unit-tests-workflow.yml | 46 +++++++++-- 3 files changed, 41 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/dco.yml delete mode 100644 .github/workflows/release-workflow.yml diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml deleted file mode 100644 index cf30ea89d..000000000 --- a/.github/workflows/dco.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Developer Certificate of Origin Check - -on: [pull_request] - -jobs: - check: - runs-on: ubuntu-latest - - steps: - - name: Get PR Commits - id: 'get-pr-commits' - uses: tim-actions/get-pr-commits@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: DCO Check - uses: tim-actions/dco@v1.1.0 - with: - commits: ${{ steps.get-pr-commits.outputs.commits }} diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml deleted file mode 100644 index 9bdf05da1..000000000 --- a/.github/workflows/release-workflow.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Release workflow -# This workflow is triggered on creating tags to main or an opensearch release branch -on: - push: - tags: - - 'v*' - -jobs: - build: - name: Build Index Management Dashboards - runs-on: ubuntu-latest - steps: - - name: Checkout Index Management Dashboards plugin - uses: actions/checkout@v2 - with: - path: index-management-dashboards-plugin - - name: Get OpenSearch-Dashboards version - id: opensearch_dashboards_version - run: | - echo "::set-output name=opensearch_dashboards_version::$(node -p "(require('./index-management-dashboards-plugin/opensearch_dashboards.json').opensearchDashboardsVersion).match(/[.0-9]+/)[0]")" - - name: Checkout OpenSearch-Dashboards - uses: actions/checkout@v2 - with: - repository: opensearch-project/OpenSearch-Dashboards - ref: ${{ steps.opensearch_dashboards_version.outputs.opensearch_dashboards_version }} - token: ${{ secrets.GITHUB_OPENSEARCH_DASHBOARDS_OSS }} - path: OpenSearch-Dashboards - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: './OpenSearch-Dashboards/.nvmrc' - registry-url: 'https://registry.npmjs.org' - - name: Install Yarn - # Need to use bash to avoid having a windows/linux specific step - shell: bash - run: | - YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn") - echo "Installing yarn@$YARN_VERSION" - npm i -g yarn@$YARN_VERSION - - run: node -v - - run: yarn -v - - name: Bootstrap plugin/OpenSearch-Dashboards - run: | - mkdir -p OpenSearch-Dashboards/plugins - mv index-management-dashboards-plugin OpenSearch-Dashboards/plugins - cd OpenSearch-Dashboards/plugins/index-management-dashboards-plugin - yarn osd bootstrap - - name: Build plugin - id: build_zip - run: | - cd OpenSearch-Dashboards/plugins/index-management-dashboards-plugin - yarn build - zip_path=`ls $(pwd)/build/*.zip` - echo "::set-output name=zip_path::$zip_path" - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_STAGING_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Upload Artifacts to S3 - run: | - zip=${{ steps.build_zip.outputs.zip_path }} - - # inject build number before the suffix - zip_outfile=`basename ${zip%.zip}-build-${GITHUB_RUN_NUMBER}.zip` - # TODO: Change s3 location - s3_prefix="s3://staging.artifacts.opendistroforelasticsearch.amazon.com/snapshots/kibana-plugins/index-management/" - - echo "Copying ${zip} to ${s3_prefix}${zip_outfile}" - aws s3 cp --quiet $zip ${s3_prefix}${zip_outfile} - - name: Create Github Draft Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: true - prerelease: false - - name: Upload Release Asset - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: opendistro_index_management_dashboards.zip - asset_path: ${{ steps.build_zip.outputs.zip_path }} - asset_content_type: application/zip - - name: Upload Workflow Artifacts - uses: actions/upload-artifact@v1 - with: - name: index-management-plugin - path: ${{ steps.build_zip.outputs.zip_path }} diff --git a/.github/workflows/unit-tests-workflow.yml b/.github/workflows/unit-tests-workflow.yml index 6bc63e6c7..5e847a1c7 100644 --- a/.github/workflows/unit-tests-workflow.yml +++ b/.github/workflows/unit-tests-workflow.yml @@ -9,11 +9,50 @@ on: env: OPENSEARCH_DASHBOARDS_VERSION: '2.x' jobs: - tests: + Get-CI-Image-Tag: + uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main + with: + product: opensearch-dashboards + + tests-linux: + needs: Get-CI-Image-Tag + name: Run unit tests + runs-on: ubuntu-latest + 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 + + steps: + # Enable longer filenames for windows + - name: Checkout OpenSearch-Dashboards + uses: actions/checkout@v2 + with: + repository: opensearch-project/OpenSearch-Dashboards + ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }} + path: OpenSearch-Dashboards + - name: Checkout Index Management Dashboards plugin + uses: actions/checkout@v2 + with: + path: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin + - name: Bootstrap / Run tests + run: | + chown -R 1000:1000 `pwd` + cd ./OpenSearch-Dashboards/ + su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && + cd ./plugins/index-management-dashboards-plugin && + whoami && yarn osd bootstrap && yarn run test:jest --coverage" + + - name: Uploads coverage + uses: codecov/codecov-action@v1 + + tests-windows-macos: name: Run unit tests strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: # Enable longer filenames for windows @@ -52,6 +91,3 @@ jobs: run: | cd OpenSearch-Dashboards/plugins/index-management-dashboards-plugin yarn run test:jest --coverage - - name: Uploads coverage - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: codecov/codecov-action@v1