From a226a45d2b50bd73bf0297f89d672f3460ac295c Mon Sep 17 00:00:00 2001 From: Siyaram Meena Date: Wed, 4 Sep 2024 12:23:15 +0530 Subject: [PATCH] update version --- .github/workflows/check-coverage.yml | 98 ++++++++-------- .github/workflows/check-dist.yml | 108 +++++++++--------- .github/workflows/deploy-extension.yml | 9 +- ...blish-test.yml => publish-QAExtension.yml} | 80 +++---------- extension_version.txt | 2 +- 5 files changed, 122 insertions(+), 175 deletions(-) rename .github/workflows/{publish-test.yml => publish-QAExtension.yml} (60%) diff --git a/.github/workflows/check-coverage.yml b/.github/workflows/check-coverage.yml index 05e828d..fa9f0e5 100644 --- a/.github/workflows/check-coverage.yml +++ b/.github/workflows/check-coverage.yml @@ -1,49 +1,49 @@ -#name: Check Code Coverage -# -#on: -# push: -# branches: -# - main -# paths-ignore: -# - '**.md' -# pull_request: -# branches: -# - main -# paths-ignore: -# - '**.md' -# workflow_dispatch: -# -#jobs: -# code-coverage: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# -# - name: Set Node.js 20.x -# uses: actions/setup-node@v4 -# with: -# node-version: 20.x -# -# - name: Install dependencies -# run: cd synopsys-task && npm ci -# -# - name: Unit Test Cases -# id: unit-test-cases -# shell: bash -# run: | -# cd synopsys-task && npm run test -# coverageFile="coverage/index.html" -# -# ### fetching line coverage from coverage/index.html file -# coverageSpan=$(grep -B 1 'Lines' $coverageFile | head -n 1) -# coverageHtml=$(echo "$coverageSpan" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') -# coverageInPercent=$(echo $coverageHtml | sed -n 's/.*\([0-9.]*%\).*/\1/p' | tr -d ' ') -# echo "Line Coverage: $coverageInPercent" -# -# ### remove percentage sign from coverageInPercent and convert to a floatin-point number -# coverageValue=$(echo "$coverageInPercent" | tr -d '%' | sed 's/,/./g') -# ### check if the coverage is below 90% -# if [[ $coverageValue < 90 ]]; then -# echo "##[error]Line coverage is below 90%" -# exit 1 -# fi \ No newline at end of file +name: Check Code Coverage + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + code-coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install dependencies + run: cd synopsys-task && npm ci + + - name: Unit Test Cases + id: unit-test-cases + shell: bash + run: | + cd synopsys-task && npm run test + coverageFile="coverage/index.html" + + ### fetching line coverage from coverage/index.html file + coverageSpan=$(grep -B 1 'Lines' $coverageFile | head -n 1) + coverageHtml=$(echo "$coverageSpan" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + coverageInPercent=$(echo $coverageHtml | sed -n 's/.*\([0-9.]*%\).*/\1/p' | tr -d ' ') + echo "Line Coverage: $coverageInPercent" + + ### remove percentage sign from coverageInPercent and convert to a floatin-point number + coverageValue=$(echo "$coverageInPercent" | tr -d '%' | sed 's/,/./g') + ### check if the coverage is below 90% + if [[ $coverageValue < 90 ]]; then + echo "##[error]Line coverage is below 90%" + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index d0b655c..a562790 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,54 +1,54 @@ -## `dist/index.js` is a special file in Actions. -## When you reference an action with `uses:` in a workflow, -## `index.js` is the code that will run. -## For our project, we generate this file through a build process from other source files. -## We need to make sure the checked-in `index.js` actually matches what we expect it to be. -#name: Check dist/ -# -#on: -# push: -# branches: -# - main -# paths-ignore: -# - '**.md' -# pull_request: -# branches: -# - main -# paths-ignore: -# - '**.md' -# workflow_dispatch: -# -#jobs: -# check-dist: -# runs-on: ubuntu-latest -# -# steps: -# - uses: actions/checkout@v4 -# -# - name: Set Node.js 20.x -# uses: actions/setup-node@v4 -# with: -# node-version: 20.x -# -# - name: Install dependencies -# run: cd synopsys-task && npm ci -# -# - name: Rebuild the dist/ directory -# run: cd synopsys-task && npm run build && npm run package -# -# - name: Compare the expected and actual dist/ directories -# run: | -# cd synopsys-task -# if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then -# echo "Detected uncommitted changes after build. See status below:" -# git diff -# exit 1 -# fi -# id: diff -# -# # If index.js was different than expected, upload the expected version as an artifact -# - uses: actions/upload-artifact@v3 -# if: ${{ failure() && steps.diff.conclusion == 'failure' }} -# with: -# name: dist -# path: synopsys-task/dist/ \ No newline at end of file +# `dist/index.js` is a special file in Actions. +# When you reference an action with `uses:` in a workflow, +# `index.js` is the code that will run. +# For our project, we generate this file through a build process from other source files. +# We need to make sure the checked-in `index.js` actually matches what we expect it to be. +name: Check dist/ + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + check-dist: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install dependencies + run: cd synopsys-task && npm ci + + - name: Rebuild the dist/ directory + run: cd synopsys-task && npm run build && npm run package + + - name: Compare the expected and actual dist/ directories + run: | + cd synopsys-task + if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff + exit 1 + fi + id: diff + + # If index.js was different than expected, upload the expected version as an artifact + - uses: actions/upload-artifact@v3 + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + with: + name: dist + path: synopsys-task/dist/ \ No newline at end of file diff --git a/.github/workflows/deploy-extension.yml b/.github/workflows/deploy-extension.yml index 7cbc7fe..7b81d3b 100644 --- a/.github/workflows/deploy-extension.yml +++ b/.github/workflows/deploy-extension.yml @@ -1,4 +1,4 @@ -name: deploy-extension-test +name: deploy-synopsys-extension on: workflow_dispatch: @@ -14,7 +14,7 @@ jobs: env: DEPLOY_PUBLISHER_NAME: ${{ secrets.DEPLOY_PUBLISHER_NAME }} DEPLOY_ORGANIZATION_NAME: ${{ secrets.DEPLOY_ORG_NAME }} - USER_TOKEN: ${{ secrets.USER_TOKEN }} #personal_access_token of azure devops account + USER_TOKEN: ${{ secrets.DEPLOY_USER_TOKEN }} #personal_access_token of azure devops account run: | vss_extension=$(cat vss-extension.json) extension_name=$(echo $vss_extension | jq -r '.name' ) @@ -33,8 +33,3 @@ jobs: # exit 1 # fi - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: extension-artifact - path: vss-extension.json diff --git a/.github/workflows/publish-test.yml b/.github/workflows/publish-QAExtension.yml similarity index 60% rename from .github/workflows/publish-test.yml rename to .github/workflows/publish-QAExtension.yml index 2b4bcb8..0fff458 100644 --- a/.github/workflows/publish-test.yml +++ b/.github/workflows/publish-QAExtension.yml @@ -1,4 +1,4 @@ -name: publish-test +name: publish-QAExtension on: push: @@ -14,8 +14,8 @@ on: workflow_dispatch: jobs: - publish-test: - if: "!contains(github.event.commits[0].message, '[skip ci]')" + if: "!contains(github.event.commits[0].message, '[skip ci]')" + publish-QAExtension: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,51 +26,6 @@ jobs: with: node-version: 20.x -# - name: versioning -# id: version-update -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} -# run: | -# vss_extension_dev=$(cat vss-extension-dev.json) -# extension_name=$(echo $vss_extension_dev | jq -r '.name' ) -# echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV -# current_extension_version=$(echo $vss_extension_dev | jq -r '.version') -# echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV -# echo "current extension version: " $current_extension_version -# major=$(echo $current_extension_version | awk -F. '{print $1}') -# minor=$(echo $current_extension_version | awk -F. '{print $2}') -# patch=$(echo $current_extension_version | awk -F. '{print $3}') -# COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1) -# COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_HEADER" | awk -F: '{print $1}') -# echo "commit message: " $COMMIT_MESSAGE_HEADER -# if [[ "$COMMIT_MESSAGE" == "BREAKING CHANGE" ]]; then -# new_version=$((major+1)).0.0 -# echo "Updating extension version $current_extension_version --> $new_version" -# elif [[ "$COMMIT_MESSAGE" == "perf" ]]; then -# new_version=$((major+1)).0.0 -# echo "Updating extension version $current_extension_version --> $new_version" -# elif [[ "$COMMIT_MESSAGE" == "feat" ]]; then -# new_version=$major.$((minor+1)).0 -# echo "Updating extension version $current_extension_version --> $new_version" -# elif [[ "$COMMIT_MESSAGE" == "fix" ]]; then -# new_version=$major.$minor.$((patch+1)) -# echo "Updating extension version $current_extension_version --> $new_version" -# else -# new_version=$current_extension_version -# echo "Extension version will not be updated. Current version: $new_version" -# fi -# -# if [[ "$current_extension_version" != "$new_version" ]]; then -# echo "Updating vss-extension-dev.json with the new version: ${new_version}" -# jq --arg new_version "$new_version" '.version = $new_version' vss-extension-dev.json > vss-extension-dev.json.tmp && mv vss-extension-dev.json.tmp vss-extension-dev.json -# echo "Updated vss-extension-dev.json file" -# cat vss-extension-dev.json -# else -# echo "vss-extension-dev.json file" -# cat vss-extension-dev.json -# fi -# echo "NEW_VERSION=$new_version" >> $GITHUB_ENV - - name: versioning id: version-update env: @@ -82,10 +37,10 @@ jobs: current_extension_version=$(echo $vss_extension_dev | jq -r '.version') echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV echo "current extension version: " $current_extension_version - previous_extension_version=$(grep 'extension_version' extension_version.txt | cut -d '=' -f 2) - echo "previous extension version:" $previous_extension_version - previous_major=$(echo $previous_extension_version | awk -F. '{print $1}') - previous_minor=$(echo $previous_extension_version | awk -F. '{print $2}') + previous_published_extension_version=$(grep 'published_extension_version' extension_version.txt | cut -d '=' -f 2) + echo "previous published extension version:" $previous_published_extension_version + previous_major=$(echo $previous_published_extension_versionn | awk -F. '{print $1}') + previous_minor=$(echo $previous_published_extension_version | awk -F. '{print $2}') current_major=$(echo $current_extension_version | awk -F. '{print $1}') current_minor=$(echo $current_extension_version | awk -F. '{print $2}') current_patch=$(echo $current_extension_version | awk -F. '{print $3}') @@ -97,27 +52,21 @@ jobs: echo "Updated vss-extension-dev.json file" cat vss-extension-dev.json echo "Updating extension_version.txt with the new version: ${new_version}" - sed -i "s/extension_version=.*/extension_version=$new_version/" extension_version.txt + sed -i "s/previous_published_extension_version=.*/previous_published_extension_version=$new_version/" extension_version.txt echo "Updated extension_version.txt file" cat extension_version.txt cd synopsys-task - echo "Updating package.json version to: ${new_version}" echo "Updating package.json with the new version: ${new_version}" jq --arg new_version "$new_version" '.version = $new_version' package.json > package.json.tmp && mv package.json.tmp package.json echo "Updated package.json file" cat package.json - echo "Updating package-lock.json version to: ${new_version}" echo "Updating package-lock.json with the new version: ${new_version}" jq --arg new_version "$new_version" '(.version = $new_version) | (.packages[""].version = $new_version)' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json - echo "Updated package-lock.json file" - echo "Updating task.json version to: ${new_version}" echo "Updating task.json with the new version: ${new_version}" jq --argjson patch_version $((current_patch+1)) '.version.Patch |= $patch_version' task.json > task.json.tmp && mv task.json.tmp task.json - echo "Updated task.json file" - else new_version=$current_extension_version @@ -125,8 +74,8 @@ jobs: fi echo "NEW_VERSION=$new_version" >> $GITHUB_ENV - - name: publish-extension - id: publish-extension + - name: publish-QAExtension + id: publish-qaextension if: ${{ steps.version-update.conclusion == 'success' }} env: PUBLISHER_NAME: ${{ secrets.PUBLISHER_NAME }} @@ -138,6 +87,9 @@ jobs: echo "Extension Name:" $extension_name extension_version=$(echo $vss_extension_dev | jq -r '.version') echo "Extension Version:" $extension_version + echo "Install dependencies && Rebuild the dist/ directory" + cd synopsys-task && npm ci && npm run build && npm run package + cd ../ echo "Installing tfx-cli..." npm i -g tfx-cli echo "Creating extension $extension_name with version $extension_version" @@ -156,9 +108,9 @@ jobs: # tfx extension publish --publisher ${PUBLISHER_NAME} --manifest-globs vss-extension-dev.json --share-with ${ORGANIZATION_NAME} --token ${USER_TOKEN} | tee tfx_output.log # tfx extension publish --publisher TestCIPub --manifest-globs vss-extension-dev.json --token ${USER_TOKEN} | tee tfx_output.log - - name: update extension version + - name: push extension version in file id: update-extension-version - if: ${{ steps.publish-extension.conclusion == 'success' && env.NEW_VERSION != env.CURRENT_VERSION }} + if: ${{ steps.publish-qaextension.conclusion == 'success' && env.NEW_VERSION != env.CURRENT_VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} run: | @@ -170,7 +122,7 @@ jobs: git add package.json package-lock.json task.json git commit -m "update extension version [skip ci]" git push origin main - echo "Successful updated version in vss-extension-dev.json..." + echo "Successful updated version in vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file" # git config --local user.name "github-actions[bot]" # git config --local user.email "github-actions[bot]@users.noreply.github.com" - name: Upload Artifact diff --git a/extension_version.txt b/extension_version.txt index 8da4276..fd14e28 100644 --- a/extension_version.txt +++ b/extension_version.txt @@ -1 +1 @@ -extension_version=2.2.8 \ No newline at end of file +published_extension_version=2.2.8 \ No newline at end of file