From df1b0fbe8588ae5007fb1d7a4f9790b9c458bd53 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 13 Dec 2023 17:03:25 +0700 Subject: [PATCH 01/41] OIDC init --- .github/workflows/publish_agent.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 1bc73dd1..589e9f13 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -190,12 +190,13 @@ jobs: - name: Install packages run: npm install --only dev - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 with: - aws-access-key-id: ${{ secrets.AWS_API_KEY }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} - aws-region: us-east-1 + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID_SHARED }}:role/katalon-github-oidc-federation + role-session-name: github-actions + aws-region: ${{ vars.AWS_REGION }} + mask-aws-account-id: 'no' - name: Download artifacts uses: actions/download-artifact@v2 From fdbc9408722922014adeb762155608709010c97e Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 13 Dec 2023 17:20:33 +0700 Subject: [PATCH 02/41] Trigger build --- .github/workflows/publish_agent.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 589e9f13..9ddafd54 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -2,7 +2,11 @@ name: Publish Agent on: workflow_dispatch: - + push: + branches: + # - main + # - release + - CO-2241 jobs: ### BUILD ### build: From 37ce0283ea6600600bfc14e2712313dec89a84ab Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 14 Dec 2023 21:18:31 +0700 Subject: [PATCH 03/41] Manually define env --- .github/workflows/publish_agent.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 9ddafd54..3d12242e 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -1,8 +1,12 @@ name: Publish Agent on: - workflow_dispatch: - push: + workflow_dispatch: + inputs: + environment: + description: "Manual environment to run (qa | staging | prod)" + required: false + type: string branches: # - main # - release @@ -197,7 +201,7 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID_SHARED }}:role/katalon-github-oidc-federation + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/katalon-github-oidc-federation role-session-name: github-actions aws-region: ${{ vars.AWS_REGION }} mask-aws-account-id: 'no' From 39c61d6a9d5da4e531601171ef901f0f51335606 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 20:33:24 +0700 Subject: [PATCH 04/41] add permission --- .github/workflows/publish_agent.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 3d12242e..e87a1ff5 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -11,6 +11,9 @@ on: # - main # - release - CO-2241 +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout jobs: ### BUILD ### build: From a0a3ef83722e95bf2e750a2f23a85ea18e459bf2 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 20:46:11 +0700 Subject: [PATCH 05/41] Set env --- .github/workflows/publish_agent.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index e87a1ff5..84353ae0 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -15,6 +15,13 @@ permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout jobs: + + ### SET ENV ### + set_env: + runs-on: ubuntu-latest + name: Set Environment + outputs: + ENV: ${{ inputs.environment }} ### BUILD ### build: name: Build @@ -184,6 +191,7 @@ jobs: ### DEPLOY ### deploy: name: Deploy cloud agent + environment: ${{ needs.set_env.outputs.ENV }} needs: build From dd94b7ffd10ee4fd173ee6f5215c71d1d1c15a46 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 20:48:39 +0700 Subject: [PATCH 06/41] Set env --- .github/workflows/publish_agent.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 84353ae0..a694b2c4 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -20,8 +20,12 @@ jobs: set_env: runs-on: ubuntu-latest name: Set Environment + steps: + - name: Set environment base on branch + id: set_env + uses: katalon-studio/katalon-base-actions/actions/get-env@v1.0.0 outputs: - ENV: ${{ inputs.environment }} + ENV: ${{ inputs.environment || steps.set_env.outputs.ENV }} ### BUILD ### build: name: Build From fe1f9e8cf36b4809fd9117592701771c90c89b1d Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 20:58:45 +0700 Subject: [PATCH 07/41] Set env input --- .github/workflows/publish_agent.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index a694b2c4..65e03e66 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -17,15 +17,15 @@ permissions: jobs: ### SET ENV ### - set_env: - runs-on: ubuntu-latest - name: Set Environment - steps: - - name: Set environment base on branch - id: set_env - uses: katalon-studio/katalon-base-actions/actions/get-env@v1.0.0 - outputs: - ENV: ${{ inputs.environment || steps.set_env.outputs.ENV }} + # set_env: + # runs-on: ubuntu-latest + # name: Set Environment + # steps: + # - name: Set environment base on branch + # id: set_env + # uses: katalon-studio/katalon-base-actions/actions/get-env@v1.0.0 + # outputs: + # ENV: ${{ inputs.environment || steps.set_env.outputs.ENV }} ### BUILD ### build: name: Build @@ -195,7 +195,7 @@ jobs: ### DEPLOY ### deploy: name: Deploy cloud agent - environment: ${{ needs.set_env.outputs.ENV }} + environment: ${{ inputs.environment }} needs: build From 315fb813769991dbb7288dc7db45badc7ff08228 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 21:25:53 +0700 Subject: [PATCH 08/41] s3 copy --- .github/workflows/publish_agent.yml | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 65e03e66..0b11f62e 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: environment: - description: "Manual environment to run (qa | staging | prod)" + description: "Manual environment to run (staging | prod)" required: false type: string branches: @@ -17,15 +17,15 @@ permissions: jobs: ### SET ENV ### - # set_env: - # runs-on: ubuntu-latest - # name: Set Environment - # steps: - # - name: Set environment base on branch - # id: set_env - # uses: katalon-studio/katalon-base-actions/actions/get-env@v1.0.0 - # outputs: - # ENV: ${{ inputs.environment || steps.set_env.outputs.ENV }} + set_env: + runs-on: ubuntu-latest + name: Set Environment + steps: + - name: Set environment base on input + id: set_env + run: echo "Exposing environment vars to reusable workflow" + outputs: + ENV: ${{ inputs.environment }} ### BUILD ### build: name: Build @@ -195,7 +195,7 @@ jobs: ### DEPLOY ### deploy: name: Deploy cloud agent - environment: ${{ inputs.environment }} + environment: ${{ needs.set_env.outputs.ENV }} needs: build @@ -232,7 +232,14 @@ jobs: - name: Set BUILD_VERSION environment variable run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - - name: Deploy to s3 + - name: Deploy to s3 staging + if: ${{ needs.set_env.outputs.ENV == 'staging' }} + run: | + ls -laR + aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://katalon-testops-agent-beta/$BUILD_VERSION + + - name: Deploy to s3 prod + if: ${{ needs.set_env.outputs.ENV == 'prod' }} run: | ls -laR aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$BUILD_VERSION/cli-linux-x64 From 3ea61830897a97c7c3bddea0c1cfaffb84fff106 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 21:47:30 +0700 Subject: [PATCH 09/41] add need key --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 0b11f62e..41b4a82d 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -197,7 +197,7 @@ jobs: name: Deploy cloud agent environment: ${{ needs.set_env.outputs.ENV }} - needs: build + needs: [set_env, build] runs-on: ubuntu-latest From 59022f6ba932414a12a9a7fcf222cb7d04bdb2c0 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 22:09:52 +0700 Subject: [PATCH 10/41] add need key --- .github/workflows/publish_agent.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 41b4a82d..e634e9fa 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -13,7 +13,7 @@ on: - CO-2241 permissions: id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout + contents: write # This is required for actions/checkout jobs: ### SET ENV ### @@ -232,12 +232,6 @@ jobs: - name: Set BUILD_VERSION environment variable run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - - name: Deploy to s3 staging - if: ${{ needs.set_env.outputs.ENV == 'staging' }} - run: | - ls -laR - aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://katalon-testops-agent-beta/$BUILD_VERSION - - name: Deploy to s3 prod if: ${{ needs.set_env.outputs.ENV == 'prod' }} run: | From 28de0f92d0a4c96147204d308974e306fee1f1dd Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Mon, 18 Dec 2023 22:19:00 +0700 Subject: [PATCH 11/41] update tag --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 236699a1..294011cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "katalon-agent", - "version": "v2.0.0", + "version": "v2.0.1", "description": "", "main": "cli.js", "scripts": { From 49d537f461f363c7c1f7cd5f767ab0eb5635520c Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:23:40 +0700 Subject: [PATCH 12/41] Test build version --- .github/workflows/publish_agent.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index e634e9fa..7f8c9bc3 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -7,6 +7,10 @@ on: description: "Manual environment to run (staging | prod)" required: false type: string + agent_version: + description: "Build version" + required: true + type: string branches: # - main # - release @@ -29,7 +33,6 @@ jobs: ### BUILD ### build: name: Build - runs-on: ${{ matrix.os }} strategy: @@ -87,8 +90,12 @@ jobs: run: npm run buildWin --if-present - name: Set BUILD_VERSION environment variable - run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + run: | + echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + sed -i '' 's/$GITHUB_ENV/$AGENT_VERSION/g' package.json shell: bash + env: + AGENT_VERSION: ${{ inputs.agent_version }} - name: Upload Windows x64 artifact uses: actions/upload-artifact@v2 From 87d4804269e6f93a5675ffd703e4f6d9fcdf6f6d Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:33:19 +0700 Subject: [PATCH 13/41] Test build version --- .github/workflows/publish_agent.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 7f8c9bc3..205a3c72 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -90,7 +90,10 @@ jobs: run: npm run buildWin --if-present - name: Set BUILD_VERSION environment variable + working-directory: . run: | + pwd + ls echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV sed -i '' 's/$GITHUB_ENV/$AGENT_VERSION/g' package.json shell: bash From 805b6ce012aa0724d56c26191532f12fe431ed5b Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:38:13 +0700 Subject: [PATCH 14/41] Test build version --- .github/workflows/publish_agent.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 205a3c72..d8cdf09b 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -8,7 +8,7 @@ on: required: false type: string agent_version: - description: "Build version" + description: "Build version example: v2.0.2" required: true type: string branches: @@ -95,7 +95,7 @@ jobs: pwd ls echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - sed -i '' 's/$GITHUB_ENV/$AGENT_VERSION/g' package.json + sed -i "s/$GITHUB_ENV/$AGENT_VERSION/g" package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From 77b29261ab7a12d2bcf90fa07417f0566cf18e5b Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:43:26 +0700 Subject: [PATCH 15/41] Test build version --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index d8cdf09b..c4d779d6 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -95,7 +95,7 @@ jobs: pwd ls echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - sed -i "s/$GITHUB_ENV/$AGENT_VERSION/g" package.json + sed -i '' "s/$GITHUB_ENV/$AGENT_VERSION/g" package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From c60cb30bb74c8932f6538780263149e4ef803f6f Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:50:05 +0700 Subject: [PATCH 16/41] Test build version --- .github/workflows/publish_agent.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index c4d779d6..2502cdd5 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -92,10 +92,10 @@ jobs: - name: Set BUILD_VERSION environment variable working-directory: . run: | - pwd - ls echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - sed -i '' "s/$GITHUB_ENV/$AGENT_VERSION/g" package.json + echo $GITHUB_ENV + echo $BUILD_VERSION + sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From 5deab975777313b39695e9eef7e34d1217ae9291 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:53:21 +0700 Subject: [PATCH 17/41] Test build version --- .github/workflows/publish_agent.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 2502cdd5..1157a773 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -88,12 +88,11 @@ jobs: CI: true if: ${{ matrix.os == 'windows-latest' }} run: npm run buildWin --if-present - - name: Set BUILD_VERSION environment variable + run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + - name: Change version in package.json file and by inputting working-directory: . run: | - echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - echo $GITHUB_ENV echo $BUILD_VERSION sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json shell: bash From f1b660915ea7aab376b152e580f2747f7f196108 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 15:55:01 +0700 Subject: [PATCH 18/41] Test build version --- .github/workflows/publish_agent.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 1157a773..fd1b28f2 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -93,8 +93,9 @@ jobs: - name: Change version in package.json file and by inputting working-directory: . run: | + ls echo $BUILD_VERSION - sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json + sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" ./package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From d6ff895fc716235cb92fb7eb048029a40c2caaa4 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 16:57:41 +0700 Subject: [PATCH 19/41] Test build version --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index fd1b28f2..e40b5622 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -95,7 +95,7 @@ jobs: run: | ls echo $BUILD_VERSION - sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" ./package.json + sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From 7b9f1ad1888f800a0aa834121f9fac33a5b50997 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 17:17:46 +0700 Subject: [PATCH 20/41] Test build version --- .github/workflows/publish_agent.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index e40b5622..89f145cf 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -8,7 +8,7 @@ on: required: false type: string agent_version: - description: "Build version example: v2.0.2" + description: "Build version example: 2.0.2" required: true type: string branches: @@ -95,7 +95,7 @@ jobs: run: | ls echo $BUILD_VERSION - sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json + sed -i '' '/version/s/[^.]*$/'"${AGENT_VERSION}\",/" package.json shell: bash env: AGENT_VERSION: ${{ inputs.agent_version }} From 8ba7ef8faa1465c21570ade73ef6bbe186b873f5 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 17:22:35 +0700 Subject: [PATCH 21/41] Test build version --- .github/workflows/publish_agent.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 89f145cf..76eea477 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -8,7 +8,7 @@ on: required: false type: string agent_version: - description: "Build version example: 2.0.2" + description: "Build version example: v2.0.2" required: true type: string branches: @@ -34,7 +34,8 @@ jobs: build: name: Build runs-on: ${{ matrix.os }} - + env: + AGENT_VERSION: ${{ inputs.agent_version }} strategy: fail-fast: true matrix: @@ -64,6 +65,9 @@ jobs: - name: Install packages if: steps.cache-packages.outputs.cache-hit != 'true' run: npm ci + + - name: Set BUILD_VERSION environment variable + run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} env: @@ -73,6 +77,7 @@ jobs: npm run buildLinux --if-present chmod +x bin/cli-linux-x64 *.sh ls -l bin + sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} env: @@ -82,23 +87,14 @@ jobs: npm run buildMacos --if-present chmod +x bin/cli-macos-x64 *.sh ls -l bin + sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} env: CI: true if: ${{ matrix.os == 'windows-latest' }} run: npm run buildWin --if-present - - name: Set BUILD_VERSION environment variable - run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - - name: Change version in package.json file and by inputting - working-directory: . - run: | - ls - echo $BUILD_VERSION - sed -i '' '/version/s/[^.]*$/'"${AGENT_VERSION}\",/" package.json - shell: bash - env: - AGENT_VERSION: ${{ inputs.agent_version }} + - name: Upload Windows x64 artifact uses: actions/upload-artifact@v2 From ebefa08ae2e8415bf5263ea1f1af3efa6c0ed8c1 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 17:45:12 +0700 Subject: [PATCH 22/41] Test build version --- .github/workflows/publish_agent.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 76eea477..03808472 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -137,7 +137,8 @@ jobs: ### RELEASE ### release: name: Release - + env: + AGENT_VERSION: ${{ inputs.agent_version }} needs: build runs-on: ubuntu-latest @@ -175,23 +176,20 @@ jobs: - name: Add execute permission to downloaded artifacts run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/* - - name: Set BUILD_VERSION environment variable - run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - - name: Package artifacts for release env: GZIP: -9 run: | set -x - + cat package.json mkdir -p packages ls -la - zip -9 -j packages/katalon-agent-win-x64-$BUILD_VERSION.zip katalon-agent-win-x64-$BUILD_VERSION/* - zip -9 -j packages/katalon-agent-win-x86-$BUILD_VERSION.zip katalon-agent-win-x86-$BUILD_VERSION/* - zip -9 -j packages/katalon-agent-linux-x64-$BUILD_VERSION.zip katalon-agent-linux-x64-$BUILD_VERSION/* - zip -9 -j packages/katalon-agent-macos-x64-$BUILD_VERSION.zip katalon-agent-macos-x64-$BUILD_VERSION/* - cd katalon-agent-linux-x64-$BUILD_VERSION - tar cvzf ../packages/katalon-agent-linux-x64-$BUILD_VERSION.tar.gz * + zip -9 -j packages/katalon-agent-win-x64-$AGENT_VERSION.zip katalon-agent-win-x64-$AGENT_VERSION/* + zip -9 -j packages/katalon-agent-win-x86-$AGENT_VERSION.zip katalon-agent-win-x86-$AGENT_VERSION/* + zip -9 -j packages/katalon-agent-linux-x64-$AGENT_VERSION.zip katalon-agent-linux-x64-$AGENT_VERSION/* + zip -9 -j packages/katalon-agent-macos-x64-$AGENT_VERSION.zip katalon-agent-macos-x64-$AGENT_VERSION/* + cd katalon-agent-linux-x64-$AGENT_VERSION + tar cvzf ../packages/katalon-agent-linux-x64-$AGENT_VERSION.tar.gz * - name: Release env: From b4402f180a82bfba797d7452f4926befb07bf8a2 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 17:58:22 +0700 Subject: [PATCH 23/41] Test build version --- .github/workflows/publish_agent.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 03808472..51138a1b 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -100,7 +100,7 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ matrix.os == 'windows-latest' }} with: - name: katalon-agent-win-x64-${{ env.BUILD_VERSION }} + name: katalon-agent-win-x64-${{ env.AGENT_VERSION }} path: | bin/cli-win-x64.exe bin/nssm.exe @@ -110,7 +110,7 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ matrix.os == 'windows-latest' }} with: - name: katalon-agent-win-x86-${{ env.BUILD_VERSION }} + name: katalon-agent-win-x86-${{ env.AGENT_VERSION }} path: | bin/cli-win-x86.exe bin/nssm.exe @@ -120,7 +120,7 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ matrix.os == 'ubuntu-latest' }} with: - name: katalon-agent-linux-x64-${{ env.BUILD_VERSION }} + name: katalon-agent-linux-x64-${{ env.AGENT_VERSION }} path: | bin/cli-linux-x64 bin/*.sh @@ -129,7 +129,7 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ matrix.os == 'macos-latest' }} with: - name: katalon-agent-macos-x64-${{ env.BUILD_VERSION }} + name: katalon-agent-macos-x64-${{ env.AGENT_VERSION }} path: | bin/cli-macos-x64 bin/start.sh @@ -181,7 +181,6 @@ jobs: GZIP: -9 run: | set -x - cat package.json mkdir -p packages ls -la zip -9 -j packages/katalon-agent-win-x64-$AGENT_VERSION.zip katalon-agent-win-x64-$AGENT_VERSION/* @@ -200,7 +199,8 @@ jobs: deploy: name: Deploy cloud agent environment: ${{ needs.set_env.outputs.ENV }} - + env: + AGENT_VERSION: ${{ inputs.agent_version }} needs: [set_env, build] runs-on: ubuntu-latest @@ -233,11 +233,9 @@ jobs: - name: Add execute permission to downloaded artifacts run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/* - - name: Set BUILD_VERSION environment variable - run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - name: Deploy to s3 prod if: ${{ needs.set_env.outputs.ENV == 'prod' }} run: | ls -laR - aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$BUILD_VERSION/cli-linux-x64 + aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$AGENT_VERSION/cli-linux-x64 From 22d9d75ee121656d08899da7ff482e7574bae199 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 18:10:31 +0700 Subject: [PATCH 24/41] Test build version --- .github/workflows/publish_agent.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 51138a1b..26f83090 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -175,7 +175,13 @@ jobs: - name: Add execute permission to downloaded artifacts run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/* + + - name: Set BUILD_VERSION environment variable + run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + - name: Change Package.json version for release + run: sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json + - name: Package artifacts for release env: GZIP: -9 From 9167d0362e1c624b195593a272aee3d6ea7c36d2 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 18:13:05 +0700 Subject: [PATCH 25/41] Test release --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 26f83090..abbce37c 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -180,7 +180,7 @@ jobs: run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - name: Change Package.json version for release - run: sed -i '' "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json + run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json - name: Package artifacts for release env: From 9567835bd2418534a3015282358713e746c1d519 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 18:21:31 +0700 Subject: [PATCH 26/41] Test release --- .github/workflows/publish_agent.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index abbce37c..7af8348c 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -137,12 +137,13 @@ jobs: ### RELEASE ### release: name: Release + environment: ${{ needs.set_env.outputs.ENV }} env: AGENT_VERSION: ${{ inputs.agent_version }} - needs: build + needs: [set_env, build] + if: ${{ needs.set_env.outputs.ENV == 'prod' }} runs-on: ubuntu-latest - strategy: matrix: node-version: From 570b0a7267710d213116fd72b9df46762bc67971 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 21:27:40 +0700 Subject: [PATCH 27/41] Commit job --- .github/workflows/publish_agent.yml | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 7af8348c..a30670fd 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -48,7 +48,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2.1.0 + uses: actions/checkout@v3 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.2 @@ -151,7 +151,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2.1.0 + uses: actions/checkout@v3 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.2 @@ -214,7 +214,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2.1.0 + uses: actions/checkout@v3 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.2 @@ -246,3 +246,28 @@ jobs: run: | ls -laR aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$AGENT_VERSION/cli-linux-x64 + + commit: + runs-on: ubuntu-latest + needs: [set_env, build, release, deploy] + name: Commit Code + env: + AGENT_VERSION: ${{ inputs.agent_version }} + environment: ${{ needs.set_env.outputs.ENV }} + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_TOKEN }} + - name: Set BUILD_VERSION environment variable + run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + - name: Change Package.json version for release + run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json + ### Commit code + - name: Deploy to GitOps + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Update version to ${{ needs.build.outputs.VERSION }} + # Optional commit user and author settings + commit_user_name: github-cloudops-bot # defaults to "github-actions[bot]" + commit_user_email: github-cloudops-bot@katalon.com # defaults to "41898282+github-actions[bot]@users.noreply.github.com" + commit_author: Author # defaults to author of the commit that triggered the run \ No newline at end of file From 06752a7f0a3a47daa9a15cf05e01590c2d9e393d Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 21:30:27 +0700 Subject: [PATCH 28/41] Commit job --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index a30670fd..82361e74 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -266,7 +266,7 @@ jobs: - name: Deploy to GitOps uses: stefanzweifel/git-auto-commit-action@v4 with: - commit_message: Update version to ${{ needs.build.outputs.VERSION }} + commit_message: Update version to ${{ env.AGENT_VERSION }} # Optional commit user and author settings commit_user_name: github-cloudops-bot # defaults to "github-actions[bot]" commit_user_email: github-cloudops-bot@katalon.com # defaults to "41898282+github-actions[bot]@users.noreply.github.com" From 1838445e0c9f19e2c9b746bdcc6e2477bd46cb7a Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 21:38:10 +0700 Subject: [PATCH 29/41] Commit job --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 82361e74..f32bd352 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -249,7 +249,7 @@ jobs: commit: runs-on: ubuntu-latest - needs: [set_env, build, release, deploy] + needs: [set_env, build, deploy] name: Commit Code env: AGENT_VERSION: ${{ inputs.agent_version }} From 0f20264e058c09c1ac3f43178263cd200ad1158a Mon Sep 17 00:00:00 2001 From: Author Date: Thu, 11 Jan 2024 14:47:05 +0000 Subject: [PATCH 30/41] Update version to v2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 294011cd..cce6f609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "katalon-agent", - "version": "v2.0.1", + "version": "v2.0.2", "description": "", "main": "cli.js", "scripts": { From 1cb7804c6607fc7098ce3b82d8857eac63066918 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Thu, 11 Jan 2024 21:50:14 +0700 Subject: [PATCH 31/41] Commit job --- .github/workflows/publish_agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index f32bd352..63864f6a 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -249,7 +249,7 @@ jobs: commit: runs-on: ubuntu-latest - needs: [set_env, build, deploy] + needs: [set_env, build, deploy, release] name: Commit Code env: AGENT_VERSION: ${{ inputs.agent_version }} From 1053a16bb7f2f816c3f17ca0fd7ba09c8c57ec2f Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 17 Jan 2024 13:39:07 +0700 Subject: [PATCH 32/41] Package agent added --- .github/workflows/package_agent.yml | 192 ++++++++++++---------------- 1 file changed, 81 insertions(+), 111 deletions(-) diff --git a/.github/workflows/package_agent.yml b/.github/workflows/package_agent.yml index ad4baef1..e996f070 100644 --- a/.github/workflows/package_agent.yml +++ b/.github/workflows/package_agent.yml @@ -1,18 +1,13 @@ name: Package Agent - -on: +'on': push: branches: - master - release - jobs: - ### BUILD ### build: name: Build - runs-on: ${{ matrix.os }} - strategy: fail-fast: true matrix: @@ -22,137 +17,113 @@ jobs: - windows-latest node-version: - 14.x - steps: - - name: Checkout code - uses: actions/checkout@v2.1.0 - - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.1.2 - with: - node-version: ${{ matrix.node-version }} - - - name: Cache - id: cache-packages - uses: actions/cache@v2.1.4 - with: - path: node_modules - key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install packages - if: steps.cache-packages.outputs.cache-hit != 'true' - run: npm ci - - - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} - env: - CI: true - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - npm run buildLinux --if-present - chmod +x bin/cli-linux-x64 *.sh - ls -l bin - - - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} - env: - CI: true - if: ${{ matrix.os == 'macos-latest' }} - run: | - npm run buildMacos --if-present - chmod +x bin/cli-macos-x64 *.sh - ls -l bin - - - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} - env: - CI: true - if: ${{ matrix.os == 'windows-latest' }} - run: npm run buildWin --if-present - - - name: Set BUILD_VERSION environment variable - run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - shell: bash - - - name: Upload Windows x64 artifact - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'windows-latest' }} - with: - name: katalon-agent-win-x64-${{ env.BUILD_VERSION }} - path: | - bin/cli-win-x64.exe - bin/nssm.exe - bin/*.bat - - - name: Upload Windows x86 artifact - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'windows-latest' }} - with: - name: katalon-agent-win-x86-${{ env.BUILD_VERSION }} - path: | - bin/cli-win-x86.exe - bin/nssm.exe - bin/*.bat - - - name: Upload Linux x64 artifact - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - name: katalon-agent-linux-x64-${{ env.BUILD_VERSION }} - path: | - bin/cli-linux-x64 - bin/*.sh - - - name: Upload MacOS x64 artifact - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'macos-latest' }} - with: - name: katalon-agent-macos-x64-${{ env.BUILD_VERSION }} - path: | - bin/cli-macos-x64 - bin/start.sh - - ### DEPLOY ### + - name: Checkout code + uses: actions/checkout@v2.1.0 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.1.2 + with: + node-version: ${{ matrix.node-version }} + - name: Cache + id: cache-packages + uses: actions/cache@v2.1.4 + with: + path: node_modules + key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + - name: Install packages + if: steps.cache-packages.outputs.cache-hit != 'true' + run: npm ci + - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} + env: + CI: true + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + npm run buildLinux --if-present + chmod +x bin/cli-linux-x64 *.sh + ls -l bin + - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} + env: + CI: true + if: ${{ matrix.os == 'macos-latest' }} + run: | + npm run buildMacos --if-present + chmod +x bin/cli-macos-x64 *.sh + ls -l bin + - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} + env: + CI: true + if: ${{ matrix.os == 'windows-latest' }} + run: npm run buildWin --if-present + - name: Set BUILD_VERSION environment variable + run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV + shell: bash + - name: Upload Windows x64 artifact + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'windows-latest' }} + with: + name: katalon-agent-win-x64-${{ env.BUILD_VERSION }} + path: | + bin/cli-win-x64.exe + bin/nssm.exe + bin/*.bat + - name: Upload Windows x86 artifact + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'windows-latest' }} + with: + name: katalon-agent-win-x86-${{ env.BUILD_VERSION }} + path: | + bin/cli-win-x86.exe + bin/nssm.exe + bin/*.bat + - name: Upload Linux x64 artifact + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'ubuntu-latest' }} + with: + name: katalon-agent-linux-x64-${{ env.BUILD_VERSION }} + path: | + bin/cli-linux-x64 + bin/*.sh + - name: Upload MacOS x64 artifact + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'macos-latest' }} + with: + name: katalon-agent-macos-x64-${{ env.BUILD_VERSION }} + path: | + bin/cli-macos-x64 + bin/start.sh deploy: name: Deploy staging cloud agent - + environment: staging needs: build - strategy: matrix: node-version: - 10.x - runs-on: ubuntu-latest - steps: - - name: Checkout code uses: actions/checkout@v2.1.0 - - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.2 with: node-version: ${{ matrix.node-version }} - - name: Install packages run: npm install --only dev - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 with: - aws-access-key-id: ${{ secrets.STAGING_AWS_API_KEY }} - aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_KEY }} - aws-region: us-east-1 - + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/katalon-github-oidc-federation + role-session-name: github-actions + aws-region: ${{ vars.AWS_REGION }} + mask-aws-account-id: 'no' - name: Download artifacts uses: actions/download-artifact@v2 with: path: . - - name: Add execute permission to downloaded artifacts run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/* - - name: Set BUILD_VERSION environment variable run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV - - name: Package artifacts env: GZIP: -9 @@ -167,7 +138,6 @@ jobs: zip -9 -j packages/katalon-agent-macos-x64-$BUILD_VERSION.zip katalon-agent-macos-x64-$BUILD_VERSION/* cd katalon-agent-linux-x64-$BUILD_VERSION tar cvzf ../packages/katalon-agent-linux-x64-$BUILD_VERSION.tar.gz * - cd .. ls -laR aws s3 sync packages/ s3://katalon-testops-agent-beta/$BUILD_VERSION --acl public-read \ No newline at end of file From f04677b21267108286a1a8b3852cdd2318368de7 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 17 Jan 2024 13:41:26 +0700 Subject: [PATCH 33/41] Package agent added --- .github/workflows/package_agent.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/package_agent.yml b/.github/workflows/package_agent.yml index e996f070..9a931254 100644 --- a/.github/workflows/package_agent.yml +++ b/.github/workflows/package_agent.yml @@ -4,6 +4,7 @@ name: Package Agent branches: - master - release + - CO-2241 jobs: build: name: Build From ca0f46fc5217058672ebb423d25a062b6843a751 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 17 Jan 2024 13:48:56 +0700 Subject: [PATCH 34/41] Package agent added --- .github/workflows/package_agent.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/package_agent.yml b/.github/workflows/package_agent.yml index 9a931254..d550c70a 100644 --- a/.github/workflows/package_agent.yml +++ b/.github/workflows/package_agent.yml @@ -5,6 +5,9 @@ name: Package Agent - master - release - CO-2241 +permissions: + id-token: write # This is required for requesting the JWT + contents: write # This is required for actions/checkout jobs: build: name: Build From fb69fee2985bd0bad18cc98d45c17eda02744204 Mon Sep 17 00:00:00 2001 From: "phuc.pham" Date: Wed, 17 Jan 2024 13:56:55 +0700 Subject: [PATCH 35/41] Trigger branch --- .github/workflows/package_agent.yml | 1 - .github/workflows/publish_agent.yml | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/package_agent.yml b/.github/workflows/package_agent.yml index d550c70a..358c344d 100644 --- a/.github/workflows/package_agent.yml +++ b/.github/workflows/package_agent.yml @@ -4,7 +4,6 @@ name: Package Agent branches: - master - release - - CO-2241 permissions: id-token: write # This is required for requesting the JWT contents: write # This is required for actions/checkout diff --git a/.github/workflows/publish_agent.yml b/.github/workflows/publish_agent.yml index 63864f6a..5b73df0c 100644 --- a/.github/workflows/publish_agent.yml +++ b/.github/workflows/publish_agent.yml @@ -11,10 +11,7 @@ on: description: "Build version example: v2.0.2" required: true type: string - branches: - # - main - # - release - - CO-2241 + permissions: id-token: write # This is required for requesting the JWT contents: write # This is required for actions/checkout From 42d8dc947dc460fcfa907a52787b7ca55abd4eaa Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 10:55:39 +0700 Subject: [PATCH 36/41] Execute pre command --- package.json | 2 +- src/helper/agent.js | 4 ++++ src/service/command-executor.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 294011cd..cce6f609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "katalon-agent", - "version": "v2.0.1", + "version": "v2.0.2", "description": "", "main": "cli.js", "scripts": { diff --git a/src/helper/agent.js b/src/helper/agent.js index d7f89efc..06825a67 100644 --- a/src/helper/agent.js +++ b/src/helper/agent.js @@ -36,6 +36,9 @@ function createCommandExecutor( projectId, sessionId: parameter.sessionId, env, + x11Display, + xvfbConfiguration, + preExecuteCommand: parameter.preExecuteCommand, }; return new GenericCommandExecutor(info); } @@ -52,6 +55,7 @@ function createCommandExecutor( extraFiles: parameter.extraFiles, gitRepository: parameter.gitRepositoryResource, organizationId: parameter.organizationId, + preExecuteCommand: parameter.preExecuteCommand, }; return new KatalonCommandExecutor(info); } diff --git a/src/service/command-executor.js b/src/service/command-executor.js index ef797ed4..afe18af6 100644 --- a/src/service/command-executor.js +++ b/src/service/command-executor.js @@ -10,6 +10,7 @@ const properties = require('../core/properties'); const reportUploader = require('./report-uploader'); const file = require('../core/file'); const utils = require('../core/utils'); +const os = require('../core/os'); const PROJECT_FILE_PATTERN = '**/*.prj'; const TESTOPS_PROPERTIES_FILE = 'com.kms.katalon.integration.analytics.properties'; @@ -98,6 +99,9 @@ class KatalonCommandExecutor extends BaseKatalonCommandExecutor { this.organizationId = info.organizationId; this.extraFiles = info.extraFiles; this.gitRepository = info.gitRepository; + this.preExecuteCommand = info.preExecuteCommand; + this.x11Display = info.x11Display; + this.env = info.env; } async downloadExtraFiles(extraFiles, ksProjectPath, jLogger, apiKey) { @@ -137,6 +141,19 @@ class KatalonCommandExecutor extends BaseKatalonCommandExecutor { await this.downloadExtraFiles(this.extraFiles, ksProjectDir, logger, apiKey); } logger.debug('Finish downloading extra files.'); + + if (this.preExecuteCommand) { + logger.debug('Start pre-execute command.'); + await os.runCommand(this.preExecuteCommand, { + x11Display: this.x11Display, + xvfbConfiguration: this.xvfbConfiguration, + logger, + tmpDirPath: ksProjectDir, + undefined, + env: this.env, + }); + logger.debug('End pre-execute command.'); + } } } @@ -146,11 +163,26 @@ class GenericCommandExecutor { this.projectId = info.projectId; this.sessionId = info.sessionId; this.env = info.env; + this.xvfbConfiguration = info.xvfbConfiguration; + this.x11Display = info.x11Display; + this.preExecuteCommand = info.preExecuteCommand; } async execute(logger, execDirPath, callback, apiKey) { const outputDir = path.join(execDirPath, GENERIC_COMMAND_OUTPUT_DIR); fs.ensureDirSync(outputDir); + if (this.preExecuteCommand) { + logger.debug('Start pre-execute command.'); + await os.runCommand(this.preExecuteCommand, { + x11Display: this.x11Display, + xvfbConfiguration: this.xvfbConfiguration, + logger, + tmpDirPath: execDirPath, + undefined, + env: this.env, + }); + logger.debug('End pre-execute command.'); + } const status = await genericCommand.executeCommands( this.commands, From f9519810dd3c01f097ee6dd18a40a4ea60e997a6 Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 10:57:16 +0700 Subject: [PATCH 37/41] remove unused param --- src/service/command-executor.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/service/command-executor.js b/src/service/command-executor.js index afe18af6..97d0f5a4 100644 --- a/src/service/command-executor.js +++ b/src/service/command-executor.js @@ -149,7 +149,6 @@ class KatalonCommandExecutor extends BaseKatalonCommandExecutor { xvfbConfiguration: this.xvfbConfiguration, logger, tmpDirPath: ksProjectDir, - undefined, env: this.env, }); logger.debug('End pre-execute command.'); @@ -178,7 +177,6 @@ class GenericCommandExecutor { xvfbConfiguration: this.xvfbConfiguration, logger, tmpDirPath: execDirPath, - undefined, env: this.env, }); logger.debug('End pre-execute command.'); From 3929908c5d9559e881dae6dd844155e8528a5348 Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 13:54:55 +0700 Subject: [PATCH 38/41] fix sona --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23e5d38f..c0025357 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: branches: - master - release + - TES-5726 concurrency: group: test-${{ github.head_ref || github.sha }} @@ -28,6 +29,13 @@ jobs: cache: 'npm' cache-dependency-path: package-lock.json + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + cache: 'maven' + - name: Run test run: | npm ci @@ -37,7 +45,7 @@ jobs: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage/lcov.info - name: Sonar Cloud Scan - uses: SonarSource/sonarcloud-github-action@v1.8 + uses: SonarSource/sonarcloud-github-action@v2.1.1 with: args: > -Dsonar.verbose=true From 5624de5bd66766795e778d125f164100ea930a09 Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 13:58:12 +0700 Subject: [PATCH 39/41] fix sona --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0025357..a48b9afa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,8 +33,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'corretto' - cache: 'maven' + distribution: 'adopt' - name: Run test run: | From 032d379fd0d033aadbeef5c18451b7afae40258b Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 14:23:55 +0700 Subject: [PATCH 40/41] fix sona --- .github/workflows/test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a48b9afa..7575b9d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,12 +29,6 @@ jobs: cache: 'npm' cache-dependency-path: package-lock.json - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - - name: Run test run: | npm ci From 75ce35b2dbd4e10fa20acdf8d82a64f9fa1a428f Mon Sep 17 00:00:00 2001 From: lydoan1199 Date: Fri, 19 Jan 2024 14:27:29 +0700 Subject: [PATCH 41/41] remove unused --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7575b9d3..73d90074 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,6 @@ on: branches: - master - release - - TES-5726 concurrency: group: test-${{ github.head_ref || github.sha }}