From abc3c52dd3fd39866d27b273cda6a67539a6ec16 Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Wed, 5 Jul 2023 13:08:43 -0700 Subject: [PATCH] Handle core label creation Signed-off-by: Prudhvi Godithi --- .../os-increment-plugin-versions.yml | 290 +++++++++--------- .../osd-increment-plugin-versions.yml | 15 +- 2 files changed, 158 insertions(+), 147 deletions(-) diff --git a/.github/workflows/os-increment-plugin-versions.yml b/.github/workflows/os-increment-plugin-versions.yml index db47815a51..20516849b7 100644 --- a/.github/workflows/os-increment-plugin-versions.yml +++ b/.github/workflows/os-increment-plugin-versions.yml @@ -1,143 +1,149 @@ --- -name: Increment OpenSearch Plugins Version - -on: - schedule: - - cron: 0 0 * * * - workflow_dispatch: - inputs: - logLevel: - description: Log level - required: true - default: warning - type: choice - options: - - info - - warning - - debug - -jobs: - plugin-version-increment-sync: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - entry: - - {repo: alerting} - - {repo: anomaly-detection} - - {repo: asynchronous-search} - - {repo: common-utils} - - {repo: cross-cluster-replication} - - {repo: geospatial} - - {repo: index-management} - - {repo: job-scheduler} - - {repo: k-NN} - - {repo: neural-search} - - {repo: ml-commons} - - {repo: notifications, path: notifications} - - {repo: observability} - - {repo: performance-analyzer} - - {repo: performance-analyzer-rca} - - {repo: reporting} - - {repo: security} - - {repo: security-analytics} - - {repo: sql} - branch: - - '1.3' - - 2.x - - '2.8' - - main - - '2.9' - exclude: - - {entry: {repo: geospatial}, branch: '1.3'} - - {entry: {repo: neural-search}, branch: '1.3'} - - {entry: {repo: security-analytics}, branch: '1.3'} - - {entry: {repo: notifications, path: notifications}, branch: '1.3'} - steps: - - name: Check out OpenSearch repo - uses: actions/checkout@v3 - with: - repository: opensearch-project/OpenSearch - ref: ${{ matrix.branch }} - - name: Fetch OpenSearch version - run: | - OPENSEARCH_VERSION=$(cat buildSrc/version.properties | grep opensearch | cut -d= -f2 | grep -oE '[0-9.]+') - echo "OPENSEARCH_VERSION_NUMBER=$OPENSEARCH_VERSION" >> $GITHUB_ENV - OPENSEARCH_VERSION=$OPENSEARCH_VERSION-SNAPSHOT - echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV - - name: Check out plugin repo - uses: actions/checkout@v3 - with: - repository: opensearch-project/${{ matrix.entry.repo }} - ref: ${{ matrix.branch }} - - name: Increment Version in ${{ matrix.entry.repo }} - run: | - echo "OpenSearch Core repo version on branch ${{ matrix.branch }} is ${{ env.OPENSEARCH_VERSION_NUMBER }}" - if [ ${{ matrix.entry.path }} ]; then - echo "The gradle path is ${{ matrix.entry.path }}" - cd ${{ matrix.entry.path }} - fi - ./gradlew updateVersion -DnewVersion=${{ env.OPENSEARCH_VERSION }} - - name: GitHub App token - id: github_app_token - uses: tibdex/github-app-token@v1.6.0 - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - installation_id: 22958780 - - name: Check and Create label - id: check_create_label - uses: actions/github-script@v6 - with: - github-token: ${{ steps.github_app_token.outputs.token }} - result-encoding: string - script: | - const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}"; - let labelFound = false; - try { - const label = await github.rest.issues.getLabel({ - owner: context.repo.owner, - repo: "${{ matrix.entry.repo }}", - name: labelName - }); - labelFound = true; - } catch (error) { - if (error.status === 404) { - const randomColor = Math.floor(Math.random() * 16777215).toString(16); - const newLabel = { - owner: context.repo.owner, - repo: "${{ matrix.entry.repo }}", - name: labelName, - color: randomColor, - description: "Issues targeting release ${{labelName}}" - }; - await github.rest.issues.createLabel(newLabel); - labelFound = true; - } else { - throw error; - } - } - console.log(labelFound); - return labelFound - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ steps.github_app_token.outputs.token }} - committer: opensearch-ci-bot - author: opensearch-ci-bot - commit-message: | - Increment version to ${{ env.OPENSEARCH_VERSION }} - - Signed-off-by: opensearch-ci-bot - delete-branch: true - branch: create-pull-request/${{ env.OPENSEARCH_VERSION }} - title: '[AUTO] Increment version to ${{ env.OPENSEARCH_VERSION }}' - labels: | - v${{ env.OPENSEARCH_VERSION_NUMBER }} - body: | - - Incremented version to **${{ env.OPENSEARCH_VERSION }}**. - - name: Check outputs - run: |- - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + name: Increment OpenSearch Plugins Version + + on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + inputs: + logLevel: + description: Log level + required: true + default: warning + type: choice + options: + - info + - warning + - debug + + jobs: + plugin-version-increment-sync: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + entry: + ## Adding the core repo OpenSearch for the label creation automation + - {repo: OpenSearch} + - {repo: alerting} + - {repo: anomaly-detection} + - {repo: asynchronous-search} + - {repo: common-utils} + - {repo: cross-cluster-replication} + - {repo: geospatial} + - {repo: index-management} + - {repo: job-scheduler} + - {repo: k-NN} + - {repo: neural-search} + - {repo: ml-commons} + - {repo: notifications, path: notifications} + - {repo: observability} + - {repo: performance-analyzer} + - {repo: performance-analyzer-rca} + - {repo: reporting} + - {repo: security} + - {repo: security-analytics} + - {repo: sql} + branch: + - '1.3' + - 2.x + - '2.8' + - main + - '2.9' + exclude: + - {entry: {repo: geospatial}, branch: '1.3'} + - {entry: {repo: neural-search}, branch: '1.3'} + - {entry: {repo: security-analytics}, branch: '1.3'} + - {entry: {repo: notifications, path: notifications}, branch: '1.3'} + steps: + - name: Check out OpenSearch repo + uses: actions/checkout@v3 + with: + repository: opensearch-project/OpenSearch + ref: ${{ matrix.branch }} + - name: Fetch OpenSearch version + run: | + OPENSEARCH_VERSION=$(cat buildSrc/version.properties | grep opensearch | cut -d= -f2 | grep -oE '[0-9.]+') + echo "OPENSEARCH_VERSION_NUMBER=$OPENSEARCH_VERSION" >> $GITHUB_ENV + OPENSEARCH_VERSION=$OPENSEARCH_VERSION-SNAPSHOT + echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV + - name: Check out plugin repo + if: ${{ matrix.entry.repo != 'OpenSearch' }} + uses: actions/checkout@v3 + with: + repository: opensearch-project/${{ matrix.entry.repo }} + ref: ${{ matrix.branch }} + - name: Increment Version in ${{ matrix.entry.repo }} + if: ${{ matrix.entry.repo != 'OpenSearch' }} + run: | + echo "OpenSearch Core repo version on branch ${{ matrix.branch }} is ${{ env.OPENSEARCH_VERSION_NUMBER }}" + if [ ${{ matrix.entry.path }} ]; then + echo "The gradle path is ${{ matrix.entry.path }}" + cd ${{ matrix.entry.path }} + fi + ./gradlew updateVersion -DnewVersion=${{ env.OPENSEARCH_VERSION }} + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.6.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + - name: Check and Create label + id: check_create_label + uses: actions/github-script@v6 + with: + github-token: ${{ steps.github_app_token.outputs.token }} + result-encoding: string + script: | + const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}"; + let labelFound = false; + try { + const label = await github.rest.issues.getLabel({ + owner: context.repo.owner, + repo: "${{ matrix.entry.repo }}", + name: labelName + }); + labelFound = true; + } catch (error) { + if (error.status === 404) { + const randomColor = Math.floor(Math.random() * 16777215).toString(16); + const newLabel = { + owner: context.repo.owner, + repo: "${{ matrix.entry.repo }}", + name: labelName, + color: randomColor, + description: "Issues targeting release " + labelName + }; + await github.rest.issues.createLabel(newLabel); + labelFound = true; + } else { + throw error; + } + } + console.log(labelFound); + return labelFound + - name: Create Pull Request + if: ${{ matrix.entry.repo != 'OpenSearch' }} + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ steps.github_app_token.outputs.token }} + committer: opensearch-ci-bot + author: opensearch-ci-bot + commit-message: | + Increment version to ${{ env.OPENSEARCH_VERSION }} + + Signed-off-by: opensearch-ci-bot + delete-branch: true + branch: create-pull-request/${{ env.OPENSEARCH_VERSION }} + title: '[AUTO] Increment version to ${{ env.OPENSEARCH_VERSION }}' + labels: | + v${{ env.OPENSEARCH_VERSION_NUMBER }} + body: | + - Incremented version to **${{ env.OPENSEARCH_VERSION }}**. + - name: Check outputs + run: |- + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + \ No newline at end of file diff --git a/.github/workflows/osd-increment-plugin-versions.yml b/.github/workflows/osd-increment-plugin-versions.yml index c7dbcc417e..81a4d8b33e 100644 --- a/.github/workflows/osd-increment-plugin-versions.yml +++ b/.github/workflows/osd-increment-plugin-versions.yml @@ -22,6 +22,8 @@ jobs: fail-fast: false matrix: entry: + ## Adding the core repo OpenSearch-Dashboards for the label creation automation + - {repo: OpenSearch-Dashboards} - {repo: dashboards-observability} - {repo: dashboards-reporting} - {repo: dashboards-visualizations, path: gantt-chart} @@ -50,6 +52,7 @@ jobs: ref: ${{ matrix.branch }} path: OpenSearch-Dashboards - name: Check out plugin repo + if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }} uses: actions/checkout@v3 with: repository: opensearch-project/${{ matrix.entry.repo }} @@ -60,18 +63,19 @@ jobs: with: node-version-file: './OpenSearch-Dashboards/.nvmrc' registry-url: 'https://registry.npmjs.org' - - name: Install Yarn + - name: Install Yarn and Setup Dashboard Version 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 + DASHBOARD_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').version") + echo "DASHBOARD_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV - run: node -v - run: yarn -v - name: Bootstrap and Version Increment + if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }} run: | - DASHBOARD_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').version") - echo "DASHBOARD_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV cd OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }} if [ ${{ matrix.entry.path }} ]; then yarn osd bootstrap @@ -85,7 +89,7 @@ jobs: cd ${{ matrix.entry.repo }}/ # tmp `elif` solution for opensearch-dashboards-functional-test (ref: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/1801#issuecomment-1545947935) elif [ ${{ matrix.entry.repo }} == "opensearch-dashboards-functional-test" ]; then - jq --arg DASHBOARD_VERSION "$DASHBOARD_VERSION" '.version = $DASHBOARD_VERSION' package.json > package-tmp.json + jq --arg DASHBOARD_VERSION "${{ env.DASHBOARD_VERSION }}" '.version = ${{ env.DASHBOARD_VERSION }}' package.json > package-tmp.json mv package-tmp.json package.json OSD_PLUGIN_VERSION=$(node -p "require('./package.json').version") echo "OSD_PLUGIN_VERSION=$OSD_PLUGIN_VERSION" >> $GITHUB_ENV @@ -126,7 +130,7 @@ jobs: repo: "${{ matrix.entry.repo }}", name: labelName, color: randomColor, - description: "Issues targeting release ${{labelName}}" + description: "Issues targeting release " + labelName }; await github.rest.issues.createLabel(newLabel); labelFound = true; @@ -137,6 +141,7 @@ jobs: console.log(labelFound); return labelFound - name: Create Pull Request + if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }} id: cpr uses: peter-evans/create-pull-request@v5 with: