From 27ac657fad09464936698b8a3047e3de92d0c5f1 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Fri, 20 Sep 2024 16:29:20 +0300 Subject: [PATCH 01/34] ci: replace test branch flow with new flow --- .github/workflows/e2e_test_for_prs.yml | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/e2e_test_for_prs.yml diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml new file mode 100644 index 00000000..1856b172 --- /dev/null +++ b/.github/workflows/e2e_test_for_prs.yml @@ -0,0 +1,49 @@ +name: Run e2e for topic branch +on: + pull_request: + paths-ignore: + - '**.md' + - 'cloudformation/*.yml' + +jobs: + run-e2e-for-topic-branch: + permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + name: Run e2e for topic branch + runs-on: ubuntu-latest + steps: + - name: Git clone + uses: actions/checkout@v4 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 #v4.0.2 + with: + role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} + aws-region: ${{secrets.AWS_E2E_REGION}} + - name: Trigger AWS CodePipeline + run: | + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) + echo "Pipeline execution ID: $codepipeline_execution_id" + echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV + env: + BRANCH_NAME: ${{github.head_ref}} + - name: Poll Pipeline Status + id: poll-status + run: | + while true; do + sleep 30 + status=$(aws codepipeline get-pipeline-execution \ + --pipeline-name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} \ + --pipeline-execution-id ${{ env.codepipeline_execution_id }} \ + --query 'pipelineExecution.status' --output text) + + echo "Current pipeline status: $status" + + if [[ "$status" == "Succeeded" ]]; then + echo "Pipeline execution succeeded!" + exit 0 + elif [[ "$status" == "Failed" ]]; then + echo "Pipeline execution failed!" + exit 1 + fi + done From 1af4a24ac136e071b03b44e31fb20787bda2ea2d Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Fri, 20 Sep 2024 23:14:49 +0300 Subject: [PATCH 02/34] ci: refactor e2e buildspec --- buildspec-e2e.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/buildspec-e2e.yml b/buildspec-e2e.yml index 285805bc..c21470c8 100644 --- a/buildspec-e2e.yml +++ b/buildspec-e2e.yml @@ -6,7 +6,8 @@ phases: nodejs: 20 commands: - npm i -g pnpm - - export COMMIT_SHA=$(cat meta.json | jq -r '.sha') + - # export COMMIT_SHA=$(cat meta.json | jq -r '.sha') + - export COMMIT_SHA=$(git rev-parse HEAD) - echo $COMMIT_SHA - echo $CODEBUILD_BUILD_ID - echo $CODEBUILD_PUBLIC_BUILD_URL @@ -20,16 +21,17 @@ phases: - ls -lah - pulumi version - pnpm install - - pnpm -C website install && pnpm -C website build - - cd tests && pnpm install && npx playwright install --with-deps && cd .. - - cd infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../ - - cd infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../ - - cd infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../ + - pnpm build + - cp -r dist e2e + - pnpm -C e2e/website install && pnpm -C website build + - cd e2e/tests && pnpm install && npx playwright install --with-deps && cd - + - cd e2e/infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - + - cd e2e/infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - + - cd e2e/infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd - build: commands: - ls -a - - cd tests && pnpm test + - cd e2e/tests && pnpm test && cd - finally: - - cd ../ - echo $COMMIT_SHA - - cd infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../ + - cd e2e/infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd - From 90f4aca3451c13365d8810f5f86c89130ef0f18b Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Fri, 20 Sep 2024 23:54:21 +0300 Subject: [PATCH 03/34] ci: refactor e2e buildspec --- .github/workflows/e2e_test_for_prs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 1856b172..45aa85d2 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,6 +25,7 @@ jobs: codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV + echo ${{github.head_ref}} env: BRANCH_NAME: ${{github.head_ref}} - name: Poll Pipeline Status From 706198b09f59125fceb6863c81d7bea22b674a89 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 00:37:18 +0300 Subject: [PATCH 04/34] ci: attempt to pass branch name as var to codepipeline --- .github/workflows/e2e_test_for_prs.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 45aa85d2..c2be4a66 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -19,15 +19,12 @@ jobs: uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 #v4.0.2 with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} - aws-region: ${{secrets.AWS_E2E_REGION}} + aws-region: ${{vars.AWS_E2E_REGION}} - name: Trigger AWS CodePipeline run: | - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --variables name=BRANCH_NAME,value=${{github.head_ref}} --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - echo ${{github.head_ref}} - env: - BRANCH_NAME: ${{github.head_ref}} - name: Poll Pipeline Status id: poll-status run: | From 11991fb7dd9af128cbce4177f7008a324cc937c3 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 01:04:38 +0300 Subject: [PATCH 05/34] ci: attempt to pass branch name as var to codepipeline & remove deploy test branch workflow --- .github/workflows/deploy_test_branch.yml | 107 ----------------------- .github/workflows/e2e_test_for_prs.yml | 5 +- 2 files changed, 4 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/deploy_test_branch.yml diff --git a/.github/workflows/deploy_test_branch.yml b/.github/workflows/deploy_test_branch.yml deleted file mode 100644 index db592630..00000000 --- a/.github/workflows/deploy_test_branch.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Deploy test branch -on: - pull_request: - paths-ignore: - - '**.md' - - 'cloudformation/*.yml' - -jobs: - deploy-test-branch: - name: Deploy test branch - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: 'Install pnpm' - uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371 - with: - version: 9 - - - name: 'Install latest node version' - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.nodeVersion }} - cache: ${{ env.PACKAGE_MANAGER }} - - - name: Get current date - id: date - run: echo "today=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT - - - name: Install dependencies - run: pnpm install - - name: Build - run: pnpm build - env: - FPCDN: ${{ secrets.FPCDN }} - INGRESS_API: ${{ secrets.INGRESS_API }} - - - name: Collect meta - run: node .github/workflows/serialize_job_info.js - env: - GITHUB_REAL_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - - - name: Prepare e2e directory - run: cp -r dist e2e && cp package.json e2e && cp pnpm-lock.yaml e2e - - - name: Build for mock tests - run: rm -rf dist && pnpm build - env: - FPCDN: ${{ secrets.MOCK_FPCDN }} - INGRESS_API: ${{ secrets.MOCK_INGRESS_API }} - - - name: Add mock dist - run: cp -r dist e2e/mock-dist - - - name: Deploy - uses: s0/git-publish-subdir-action@92faf786f11dfa44fc366ac3eb274d193ca1af7e - env: - REPO: self - BRANCH: e2e-tests - FOLDER: e2e - TARGET_DIR: ${{ steps.date.outputs.today }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - MESSAGE: Deploy prepared in [${{ steps.date.outputs.today }}] - - run-e2e-for-test-branch: - needs: [deploy-test-branch] - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - name: Run e2e for test branch - runs-on: ubuntu-latest - steps: - - name: Git clone - uses: actions/checkout@v4 - - name: configure AWS credentials - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 #v4.0.2 - with: - role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} - aws-region: ${{vars.AWS_E2E_REGION}} - - name: Trigger AWS CodePipeline - run: | - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TEST_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) - echo "Pipeline execution ID: $codepipeline_execution_id" - echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - - name: Poll Pipeline Status - id: poll-status - run: | - while true; do - sleep 30 - status=$(aws codepipeline get-pipeline-execution \ - --pipeline-name ${{vars.AWS_E2E_TEST_BRANCH_CODEPIPELINE_NAME}} \ - --pipeline-execution-id ${{ env.codepipeline_execution_id }} \ - --query 'pipelineExecution.status' --output text) - - echo "Current pipeline status: $status" - - if [[ "$status" == "Succeeded" ]]; then - echo "Pipeline execution succeeded!" - exit 0 - elif [[ "$status" == "Failed" ]]; then - echo "Pipeline execution failed!" - exit 1 - fi - done diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index c2be4a66..142ce060 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -20,9 +20,12 @@ jobs: with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} aws-region: ${{vars.AWS_E2E_REGION}} + - name: Store BRANCH_NAME in Parameter Store + run: | + aws ssm put-parameter --name "BRANCH_NAME" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --variables name=BRANCH_NAME,value=${{github.head_ref}} --query 'pipelineExecutionId' --output text) + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - name: Poll Pipeline Status From 4a664c1cc46fec3a14ececc92495f70a750c8d1c Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 01:11:35 +0300 Subject: [PATCH 06/34] ci: rename parameter name --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 142ce060..6fa63be6 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -22,7 +22,7 @@ jobs: aws-region: ${{vars.AWS_E2E_REGION}} - name: Store BRANCH_NAME in Parameter Store run: | - aws ssm put-parameter --name "BRANCH_NAME" --value "${{github.head_ref}}" --type "String" --overwrite + aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) From a7e42faba5e4b3028955b5e9cc9852b86b8fb813 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 01:28:13 +0300 Subject: [PATCH 07/34] ci: fix buildspec dir --- buildspec-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec-e2e.yml b/buildspec-e2e.yml index c21470c8..36b41582 100644 --- a/buildspec-e2e.yml +++ b/buildspec-e2e.yml @@ -23,7 +23,7 @@ phases: - pnpm install - pnpm build - cp -r dist e2e - - pnpm -C e2e/website install && pnpm -C website build + - pnpm -C e2e/website install && pnpm -C e2e/website build - cd e2e/tests && pnpm install && npx playwright install --with-deps && cd - - cd e2e/infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - - cd e2e/infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - From f4308672e74338d0a6110962d674c4429d9e1b15 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 15:45:14 +0300 Subject: [PATCH 08/34] ci: fix mocked e2e tests --- buildspec-e2e-pr-join-artifacts.yml | 72 +++++++++++++++++++++++++++++ buildspec-mock-e2e.yml | 18 ++++---- 2 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 buildspec-e2e-pr-join-artifacts.yml diff --git a/buildspec-e2e-pr-join-artifacts.yml b/buildspec-e2e-pr-join-artifacts.yml new file mode 100644 index 00000000..8b77f68a --- /dev/null +++ b/buildspec-e2e-pr-join-artifacts.yml @@ -0,0 +1,72 @@ +# todo use this in the CodeBuild project + +version: 0.2 + + #env: + #variables: + # key: "value" + # key: "value" + #parameter-store: + # key: "value" + # key: "value" + #secrets-manager: + # key: secret-id:json-key:version-stage:version-id + # key: secret-id:json-key:version-stage:version-id + #exported-variables: + # - variable + # - variable + #git-credential-helper: yes + #batch: + #fast-fail: true + #build-list: + #build-matrix: +#build-graph: +phases: + #install: + #If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions. + #If you specify runtime-versions and use an image other than Ubuntu standard image 2.0, the build fails. + #runtime-versions: + # name: version + # name: version + #commands: + # - command + # - command + #pre_build: + #commands: + # - command + # - command + build: + commands: + - ls -la $CODEBUILD_SRC_DIR # rc branch, also called as primary source + - ls -la $CODEBUILD_SRC_DIR_SourceArtifact # source that will be used for topic branch + - cd $CODEBUILD_SRC_DIR_SourceArtifact + - echo $BRANCH_NAME + - git switch $BRANCH_NAME # check out topic branch + - git status + - cp $CODEBUILD_SRC_DIR/buildspec-e2e.yml buildspec-e2e.yml + - cp $CODEBUILD_SRC_DIR/buildspec-mock-e2e.yml buildspec-mock-e2e.yml + # - command + # - command + #post_build: + #commands: + # - command + # - command + #reports: + #report-name-or-arn: + #files: + # - location + # - location + #base-directory: location + #discard-paths: yes + #file-format: JunitXml | CucumberJson +artifacts: + files: + - '**/*' + # - location + # - location + #name: $(date +%Y-%m-%d) + #discard-paths: yes + base-directory: $CODEBUILD_SRC_DIR_SourceArtifact + #cache: + #paths: + # - paths diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index 04641e73..babb695d 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -6,8 +6,8 @@ phases: nodejs: 20 commands: - npm i -g pnpm - - export COMMIT_SHA=$(cat meta.json | jq -r '.sha') - - export VERSION=$(cat meta.json | jq -r '.version') + - export COMMIT_SHA=$(git rev-parse HEAD) + - export VERSION=$(cat package.json | jq -r '.version') - echo $COMMIT_SHA - echo $VERSION - echo $CODEBUILD_BUILD_ID @@ -23,15 +23,15 @@ phases: - pulumi version - pnpm install - npm i -g ts-node - - pnpm -C website install && pnpm -C website build - - cd tests && pnpm install && cd .. - - cd infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../ - - cd infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../ - - cd infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../ + - pnpm -C e2e/website install && pnpm -C e2e/website build + - cd e2e/tests && pnpm install && cd - + - cd e2e/infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - + - cd e2e/infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd - + - cd e2e/infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd - build: commands: - - ts-node ./scripts/mockTests.ts --project=tsconfig.json + - ts-node e2e/scripts/mockTests.ts --project=tsconfig.json finally: - echo $COMMIT_SHA - - cd infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../ + - cd e2e/infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd - From 9a5357604441df3eb32cb88b8ff9efeeaecf6bbd Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 16:03:55 +0300 Subject: [PATCH 09/34] ci: add todo --- buildspec-e2e.yml | 1 + buildspec-mock-e2e.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/buildspec-e2e.yml b/buildspec-e2e.yml index 36b41582..9f8d6f32 100644 --- a/buildspec-e2e.yml +++ b/buildspec-e2e.yml @@ -1,3 +1,4 @@ +# todo use this file and delete hard coded code editor version: 0.2 phases: diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index babb695d..aa71a979 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -1,3 +1,4 @@ +# todo use this file and delete hard coded code editor version: 0.2 phases: From 38bd4224894011fa98175ea3ad4e59565acf58a3 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 16:24:25 +0300 Subject: [PATCH 10/34] ci: fix mock e2e --- buildspec-mock-e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index aa71a979..13e27605 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -23,6 +23,7 @@ phases: - ls -lah - pulumi version - pnpm install + - FPCDN=$MOCK_FPCDN INGRESS_API=$MOCK_INGRESS_API pnpm build - npm i -g ts-node - pnpm -C e2e/website install && pnpm -C e2e/website build - cd e2e/tests && pnpm install && cd - From 4afb5fa0d5e5c345bb997015c2b1f87ab230ef1a Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Sat, 21 Sep 2024 17:06:57 +0300 Subject: [PATCH 11/34] ci: fix mock e2e --- buildspec-mock-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index 13e27605..2fa5d549 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -23,7 +23,7 @@ phases: - ls -lah - pulumi version - pnpm install - - FPCDN=$MOCK_FPCDN INGRESS_API=$MOCK_INGRESS_API pnpm build + - pnpm build - npm i -g ts-node - pnpm -C e2e/website install && pnpm -C e2e/website build - cd e2e/tests && pnpm install && cd - From 6f5b3dd76153a917d8e411451204c1e851649211 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 12:05:59 +0300 Subject: [PATCH 12/34] chore: remove outdated comments --- buildspec-e2e-pr-join-artifacts.yml | 56 ------------------- buildspec-e2e.yml | 2 - buildspec-mock-e2e.yml | 1 - .../secrets-manager/validate-secret.ts | 1 - 4 files changed, 60 deletions(-) diff --git a/buildspec-e2e-pr-join-artifacts.yml b/buildspec-e2e-pr-join-artifacts.yml index 8b77f68a..35aa4200 100644 --- a/buildspec-e2e-pr-join-artifacts.yml +++ b/buildspec-e2e-pr-join-artifacts.yml @@ -1,40 +1,6 @@ -# todo use this in the CodeBuild project - version: 0.2 - #env: - #variables: - # key: "value" - # key: "value" - #parameter-store: - # key: "value" - # key: "value" - #secrets-manager: - # key: secret-id:json-key:version-stage:version-id - # key: secret-id:json-key:version-stage:version-id - #exported-variables: - # - variable - # - variable - #git-credential-helper: yes - #batch: - #fast-fail: true - #build-list: - #build-matrix: -#build-graph: phases: - #install: - #If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions. - #If you specify runtime-versions and use an image other than Ubuntu standard image 2.0, the build fails. - #runtime-versions: - # name: version - # name: version - #commands: - # - command - # - command - #pre_build: - #commands: - # - command - # - command build: commands: - ls -la $CODEBUILD_SRC_DIR # rc branch, also called as primary source @@ -45,28 +11,6 @@ phases: - git status - cp $CODEBUILD_SRC_DIR/buildspec-e2e.yml buildspec-e2e.yml - cp $CODEBUILD_SRC_DIR/buildspec-mock-e2e.yml buildspec-mock-e2e.yml - # - command - # - command - #post_build: - #commands: - # - command - # - command - #reports: - #report-name-or-arn: - #files: - # - location - # - location - #base-directory: location - #discard-paths: yes - #file-format: JunitXml | CucumberJson artifacts: files: - - '**/*' - # - location - # - location - #name: $(date +%Y-%m-%d) - #discard-paths: yes base-directory: $CODEBUILD_SRC_DIR_SourceArtifact - #cache: - #paths: - # - paths diff --git a/buildspec-e2e.yml b/buildspec-e2e.yml index 9f8d6f32..96165b93 100644 --- a/buildspec-e2e.yml +++ b/buildspec-e2e.yml @@ -1,4 +1,3 @@ -# todo use this file and delete hard coded code editor version: 0.2 phases: @@ -7,7 +6,6 @@ phases: nodejs: 20 commands: - npm i -g pnpm - - # export COMMIT_SHA=$(cat meta.json | jq -r '.sha') - export COMMIT_SHA=$(git rev-parse HEAD) - echo $COMMIT_SHA - echo $CODEBUILD_BUILD_ID diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index 2fa5d549..a2b3839d 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -1,4 +1,3 @@ -# todo use this file and delete hard coded code editor version: 0.2 phases: diff --git a/proxy/utils/customer-variables/secrets-manager/validate-secret.ts b/proxy/utils/customer-variables/secrets-manager/validate-secret.ts index 492123ce..f1844d53 100644 --- a/proxy/utils/customer-variables/secrets-manager/validate-secret.ts +++ b/proxy/utils/customer-variables/secrets-manager/validate-secret.ts @@ -8,7 +8,6 @@ function assertIsCustomerVariableValue(value: unknown, key: string): asserts val } } -// TODO Update notion documentation to contain correct keys export function validateSecret(obj: unknown): asserts obj is CustomerVariablesRecord { if (!obj || typeof obj !== 'object') { throw new TypeError('Secrets Manager secret is not an object') From 083a731adf1b8c4836f304c6c3ac9ee098f568f9 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:09:10 +0300 Subject: [PATCH 13/34] ci: try --source-revisions --- .github/workflows/e2e_test_for_prs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 6fa63be6..475f3be1 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,7 +25,9 @@ jobs: aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) + git_hash=$(git rev-parse HEAD) + echo git_hash + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=string,revisionType=COMMIT_ID,revisionValue=git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - name: Poll Pipeline Status From e7e010ed711a5e878357c536b5b644a928552970 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:14:25 +0300 Subject: [PATCH 14/34] ci: fix --source-revisions --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 475f3be1..703ae18a 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -27,7 +27,7 @@ jobs: run: | git_hash=$(git rev-parse HEAD) echo git_hash - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=string,revisionType=COMMIT_ID,revisionValue=git_hash --query 'pipelineExecutionId' --output text) + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - name: Poll Pipeline Status From 8cef93efd5479f4301dc767e7c5dd211870c2d42 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:15:20 +0300 Subject: [PATCH 15/34] ci: fix --source-revisions --- .github/workflows/e2e_test_for_prs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 703ae18a..2b4dc86c 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -26,8 +26,8 @@ jobs: - name: Trigger AWS CodePipeline run: | git_hash=$(git rev-parse HEAD) - echo git_hash - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=git_hash --query 'pipelineExecutionId' --output text) + echo $git_hash + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - name: Poll Pipeline Status From 7f4d37cd67759a89cc6b96f112ea523b26774f63 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:20:47 +0300 Subject: [PATCH 16/34] ci: add debug log --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 2b4dc86c..e5440add 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,8 +25,8 @@ jobs: aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | + git status git_hash=$(git rev-parse HEAD) - echo $git_hash codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV From c32bc20eb1081be3d9ea4e758e6cee560044e89f Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:24:21 +0300 Subject: [PATCH 17/34] ci: fix commit id --- .github/workflows/e2e_test_for_prs.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index e5440add..3bfe5938 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -20,13 +20,14 @@ jobs: with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} aws-region: ${{vars.AWS_E2E_REGION}} - - name: Store BRANCH_NAME in Parameter Store - run: | - aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite +# - name: Store BRANCH_NAME in Parameter Store +# run: | +# aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | git status - git_hash=$(git rev-parse HEAD) + git_hash=$(git rev-parse --short "$GITHUB_SHA") + echo $git_hash codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV From 36165ef4c972d5ebea4a578860d92a5ca6cb3271 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:27:44 +0300 Subject: [PATCH 18/34] ci: fix commit id --- .github/workflows/e2e_test_for_prs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 3bfe5938..a37ad02a 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,8 +25,7 @@ jobs: # aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | - git status - git_hash=$(git rev-parse --short "$GITHUB_SHA") + git_hash=${{ github.event.pull_request.head.ref }} echo $git_hash codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" From 3d845a69b0cb42ff0a06baf9011884bd9dec25e8 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:32:01 +0300 Subject: [PATCH 19/34] ci: fix commit id --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index a37ad02a..92eb747f 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,7 +25,7 @@ jobs: # aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | - git_hash=${{ github.event.pull_request.head.ref }} + git_hash=${{ github.event.pull_request.head.sha }} echo $git_hash codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$git_hash --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" From 0260a3da74a76a348dcb3b88dc872e21f907195e Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:35:58 +0300 Subject: [PATCH 20/34] ci: remove branch name related logic from e2e tests --- .github/workflows/e2e_test_for_prs.yml | 3 --- buildspec-e2e-pr-join-artifacts.yml | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 92eb747f..b9fd7baa 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -20,9 +20,6 @@ jobs: with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} aws-region: ${{vars.AWS_E2E_REGION}} -# - name: Store BRANCH_NAME in Parameter Store -# run: | -# aws ssm put-parameter --name "/cloudfront-integration-e2e/branch_name" --value "${{github.head_ref}}" --type "String" --overwrite - name: Trigger AWS CodePipeline run: | git_hash=${{ github.event.pull_request.head.sha }} diff --git a/buildspec-e2e-pr-join-artifacts.yml b/buildspec-e2e-pr-join-artifacts.yml index 35aa4200..c1052499 100644 --- a/buildspec-e2e-pr-join-artifacts.yml +++ b/buildspec-e2e-pr-join-artifacts.yml @@ -4,10 +4,8 @@ phases: build: commands: - ls -la $CODEBUILD_SRC_DIR # rc branch, also called as primary source - - ls -la $CODEBUILD_SRC_DIR_SourceArtifact # source that will be used for topic branch + - ls -la $CODEBUILD_SRC_DIR_SourceArtifact # topic branch - cd $CODEBUILD_SRC_DIR_SourceArtifact - - echo $BRANCH_NAME - - git switch $BRANCH_NAME # check out topic branch - git status - cp $CODEBUILD_SRC_DIR/buildspec-e2e.yml buildspec-e2e.yml - cp $CODEBUILD_SRC_DIR/buildspec-mock-e2e.yml buildspec-mock-e2e.yml From ab6ed16d1b5cb631d645bdbfca0562de8c5efc13 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 23 Sep 2024 15:49:34 +0300 Subject: [PATCH 21/34] ci: fix file paths --- buildspec-e2e-pr-join-artifacts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/buildspec-e2e-pr-join-artifacts.yml b/buildspec-e2e-pr-join-artifacts.yml index c1052499..1e017f7d 100644 --- a/buildspec-e2e-pr-join-artifacts.yml +++ b/buildspec-e2e-pr-join-artifacts.yml @@ -11,4 +11,5 @@ phases: - cp $CODEBUILD_SRC_DIR/buildspec-mock-e2e.yml buildspec-mock-e2e.yml artifacts: files: + - '**/*' base-directory: $CODEBUILD_SRC_DIR_SourceArtifact From 49be83d7def97d3bbcad34b07a35a9231f83d7e1 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Tue, 24 Sep 2024 11:35:14 +0300 Subject: [PATCH 22/34] ci: e2e tests clean up and put aws execution link to the action summary --- .github/workflows/cleanup_old_e2e_tasks.yml | 46 --------------------- .github/workflows/e2e_test_for_prs.yml | 10 +++++ .github/workflows/serialize_job_info.js | 18 -------- buildspec-e2e.yml | 2 - buildspec-mock-e2e.yml | 4 -- 5 files changed, 10 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/cleanup_old_e2e_tasks.yml delete mode 100644 .github/workflows/serialize_job_info.js diff --git a/.github/workflows/cleanup_old_e2e_tasks.yml b/.github/workflows/cleanup_old_e2e_tasks.yml deleted file mode 100644 index c4dbc780..00000000 --- a/.github/workflows/cleanup_old_e2e_tasks.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Cleanup old e2e tasks - -on: - workflow_dispatch: - schedule: - - cron: '0 4 * * *' - -jobs: - run-cleanup-old-e2e-tasks: - runs-on: ubuntu-20.04 - name: Clean old tasks - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: e2e-tests - - - name: Set git settings - uses: fregante/setup-git-user@2e28d51939d2a84005a917d2f844090637f435f8 - - - name: Cleanup old artifacts - id: cleanup - shell: bash - run: | - now=`date +%s` - re='([0-9]{4}-[0-9]{2}-[0-9]{2})-([0-9]{2})-([0-9]{2})-([0-9]{2})' - for name in *; do - if [ -d "$name" ] && [ ! -L "$name" ] && [[ $name =~ $re ]]; then - normalized_date="${BASH_REMATCH[1]} ${BASH_REMATCH[2]}:${BASH_REMATCH[3]}:${BASH_REMATCH[4]}" - folder_date=`date -d "$normalized_date" +%s` - diff=$(($now - $folder_date)) - if [ $diff -gt 84600 ]; then - rm -rf ./${name} - echo "deleted: $name" - echo "HAS_DELETED_DIRECTORY=true" >> $GITHUB_OUTPUT - fi - fi - done - - - name: commit changes - if: ${{ steps.cleanup.outputs.HAS_DELETED_DIRECTORY == 'true' }} - run: | - git add . - git status - git commit -m "chore: cleanup old e2e tasks" - git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index b9fd7baa..8b933c29 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -47,3 +47,13 @@ jobs: exit 1 fi done + - name: Output Pipeline Link + if: always() + run: | + region=${{ vars.AWS_E2E_REGION }} + pipeline_name=${{ vars.AWS_E2E_TOPIC_BRANCH_CODEPIPELINE_NAME }} + execution_id=${{ env.codepipeline_execution_id }} + pipeline_url="https://${region}.console.aws.amazon.com/codesuite/codepipeline/pipelines/${pipeline_name}/executions/${execution_id}?region=${region}" + echo "AWS CodePipeline Execution URL: $pipeline_url" + echo "## AWS CodePipeline Execution Link" >> $GITHUB_STEP_SUMMARY + echo "[$pipeline_url]($pipeline_url)" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/serialize_job_info.js b/.github/workflows/serialize_job_info.js deleted file mode 100644 index ab18d9eb..00000000 --- a/.github/workflows/serialize_job_info.js +++ /dev/null @@ -1,18 +0,0 @@ -const fs = require('fs') -const pkg = require('../../package.json') - -const meta = { - sha: process.env.GITHUB_REAL_COMMIT_SHA, - version: pkg.version, -} - -console.info('job info', meta) - -const serializedData = JSON.stringify(meta, null, ' ') - -fs.writeFile('./e2e/meta.json', serializedData, (err) => { - if (err) { - console.error(err) - } - // file written successfully -}) diff --git a/buildspec-e2e.yml b/buildspec-e2e.yml index 96165b93..8cbc4345 100644 --- a/buildspec-e2e.yml +++ b/buildspec-e2e.yml @@ -6,8 +6,6 @@ phases: nodejs: 20 commands: - npm i -g pnpm - - export COMMIT_SHA=$(git rev-parse HEAD) - - echo $COMMIT_SHA - echo $CODEBUILD_BUILD_ID - echo $CODEBUILD_PUBLIC_BUILD_URL - ls -a diff --git a/buildspec-mock-e2e.yml b/buildspec-mock-e2e.yml index a2b3839d..175d4cd1 100644 --- a/buildspec-mock-e2e.yml +++ b/buildspec-mock-e2e.yml @@ -6,10 +6,6 @@ phases: nodejs: 20 commands: - npm i -g pnpm - - export COMMIT_SHA=$(git rev-parse HEAD) - - export VERSION=$(cat package.json | jq -r '.version') - - echo $COMMIT_SHA - - echo $VERSION - echo $CODEBUILD_BUILD_ID - echo $CODEBUILD_PUBLIC_BUILD_URL - ls -a From 0e1f9cb60218ab51c6982ec4d3f1b340fdc030a1 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 11:54:19 +0300 Subject: [PATCH 23/34] ci: fix workflow trigger conditions --- .github/workflows/e2e_test_for_prs.yml | 26 +++++++++++++++++++++++--- buildspec-e2e-pr-join-artifacts.yml | 4 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 8b933c29..b07c1c3a 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -1,12 +1,32 @@ name: Run e2e for topic branch on: pull_request: - paths-ignore: - - '**.md' - - 'cloudformation/*.yml' jobs: + check-changed-files: + runs-on: ubuntu-20.04 + name: Check changed files + outputs: + NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} + steps: + - id: files + uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 + - name: Make decision based on changed files + id: decision + run: | + needToRunTests=false + for changed_file in ${{ steps.files.outputs.all }}; do + if [[ ${changed_file} =~ ^(proxy|scripts|mgmt-lambda)\/.+$ ]]; then + needToRunTests=true + fi + if [[ ${changed_file} =~ ^\.github\/workflows\/.+$ ]]; then + needToRunTests=true + fi + done + echo $needToRunTests + echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT run-e2e-for-topic-branch: + if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout diff --git a/buildspec-e2e-pr-join-artifacts.yml b/buildspec-e2e-pr-join-artifacts.yml index 1e017f7d..f75acdd8 100644 --- a/buildspec-e2e-pr-join-artifacts.yml +++ b/buildspec-e2e-pr-join-artifacts.yml @@ -3,8 +3,8 @@ version: 0.2 phases: build: commands: - - ls -la $CODEBUILD_SRC_DIR # rc branch, also called as primary source - - ls -la $CODEBUILD_SRC_DIR_SourceArtifact # topic branch + # $CODEBUILD_SRC_DIR => rc branch + # $CODEBUILD_SRC_DIR_SourceArtifact => topic branch - cd $CODEBUILD_SRC_DIR_SourceArtifact - git status - cp $CODEBUILD_SRC_DIR/buildspec-e2e.yml buildspec-e2e.yml From 4f1ed3e9830023f21094ee8531e7d7b61133d329 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:09:33 +0300 Subject: [PATCH 24/34] ci: replace github output with github env var --- .github/workflows/e2e_test_for_prs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index b07c1c3a..fe4cedde 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -6,8 +6,6 @@ jobs: check-changed-files: runs-on: ubuntu-20.04 name: Check changed files - outputs: - NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} steps: - id: files uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 @@ -24,9 +22,10 @@ jobs: fi done echo $needToRunTests - echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT + echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_ENV run-e2e-for-topic-branch: - if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' + needs: check-changed-files + if: ${{ env.NEED_TO_RUN_TESTS }} == 'true' permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout From 8a10f10180893be006a816853b791ad326ef10a4 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:14:28 +0300 Subject: [PATCH 25/34] ci: replace github output with github env var --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index fe4cedde..151be883 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -25,7 +25,7 @@ jobs: echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_ENV run-e2e-for-topic-branch: needs: check-changed-files - if: ${{ env.NEED_TO_RUN_TESTS }} == 'true' + if: ${{ env.NEED_TO_RUN_TESTS == 'true' }} permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout From 31c5c143cd8d919973f59574ce05501755541dac Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:18:27 +0300 Subject: [PATCH 26/34] ci: revert back to using github outputs --- .github/workflows/e2e_test_for_prs.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 151be883..b07c1c3a 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -6,6 +6,8 @@ jobs: check-changed-files: runs-on: ubuntu-20.04 name: Check changed files + outputs: + NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} steps: - id: files uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 @@ -22,10 +24,9 @@ jobs: fi done echo $needToRunTests - echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_ENV + echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT run-e2e-for-topic-branch: - needs: check-changed-files - if: ${{ env.NEED_TO_RUN_TESTS == 'true' }} + if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout From 3663e4f953a3fc0575b2f7b78f41d3728009439b Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:26:58 +0300 Subject: [PATCH 27/34] ci: manual implementation of the diff action --- .github/workflows/e2e_test_for_prs.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index b07c1c3a..c287404c 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -9,6 +9,16 @@ jobs: outputs: NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} steps: + - name: Get changed files + id: testing-behavior + run: | + git fetch origin {{ GITHUB_BASE_REF }} + diff=$(git diff --name-only --diff-filter=AM origin/{{ GITHUB_BASE_REF }}..HEAD | tr '\n' ' ') + echo $diff + echo "ADDED_MODIFIED=$diff" >> "$GITHUB_OUTPUT" + for changed_file in $diff; do + echo $changed_file + done - id: files uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 - name: Make decision based on changed files From b1fcf2c76c2c8a09945d477f53748d0cdae7ebbf Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:29:46 +0300 Subject: [PATCH 28/34] ci: manual implementation of the diff action --- .github/workflows/e2e_test_for_prs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index c287404c..a6928b9b 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -9,11 +9,13 @@ jobs: outputs: NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} steps: + - name: Git clone + uses: actions/checkout@v4 - name: Get changed files id: testing-behavior run: | git fetch origin {{ GITHUB_BASE_REF }} - diff=$(git diff --name-only --diff-filter=AM origin/{{ GITHUB_BASE_REF }}..HEAD | tr '\n' ' ') + diff=$(git diff --name-only --diff-filter=AM origin/{{ GITHUB_BASE_REF }}..HEAD) echo $diff echo "ADDED_MODIFIED=$diff" >> "$GITHUB_OUTPUT" for changed_file in $diff; do From b137b122ac346f5def6369f02b8607b6bd92d0a4 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:30:30 +0300 Subject: [PATCH 29/34] ci: manual implementation of the diff action --- .github/workflows/e2e_test_for_prs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index a6928b9b..d71826e0 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -14,8 +14,8 @@ jobs: - name: Get changed files id: testing-behavior run: | - git fetch origin {{ GITHUB_BASE_REF }} - diff=$(git diff --name-only --diff-filter=AM origin/{{ GITHUB_BASE_REF }}..HEAD) + git fetch origin $GITHUB_BASE_REF + diff=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF$..HEAD) echo $diff echo "ADDED_MODIFIED=$diff" >> "$GITHUB_OUTPUT" for changed_file in $diff; do From df761b680affe109efd396a4641feaef566d1b87 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:31:02 +0300 Subject: [PATCH 30/34] ci: manual implementation of the diff action --- .github/workflows/e2e_test_for_prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index d71826e0..de5b5f8f 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -15,7 +15,7 @@ jobs: id: testing-behavior run: | git fetch origin $GITHUB_BASE_REF - diff=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF$..HEAD) + diff=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF..HEAD) echo $diff echo "ADDED_MODIFIED=$diff" >> "$GITHUB_OUTPUT" for changed_file in $diff; do From c31ccb5bcae8d77c08600504390f56bd195d390a Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:33:57 +0300 Subject: [PATCH 31/34] ci: manual implementation of the diff action --- .github/workflows/e2e_test_for_prs.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index de5b5f8f..8bd6b175 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -12,22 +12,13 @@ jobs: - name: Git clone uses: actions/checkout@v4 - name: Get changed files - id: testing-behavior + id: decision run: | git fetch origin $GITHUB_BASE_REF diff=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF..HEAD) echo $diff - echo "ADDED_MODIFIED=$diff" >> "$GITHUB_OUTPUT" - for changed_file in $diff; do - echo $changed_file - done - - id: files - uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 - - name: Make decision based on changed files - id: decision - run: | needToRunTests=false - for changed_file in ${{ steps.files.outputs.all }}; do + for changed_file in $diff; do if [[ ${changed_file} =~ ^(proxy|scripts|mgmt-lambda)\/.+$ ]]; then needToRunTests=true fi From c4d0b0e84b673fc2a6eef6f9c212de6aae43663a Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:37:38 +0300 Subject: [PATCH 32/34] ci: debug job output --- .github/workflows/e2e_test_for_prs.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 8bd6b175..687ccde0 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -28,6 +28,13 @@ jobs: done echo $needToRunTests echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT + debug-job: + name: debug job + runs-on: ubuntu-latest + steps: + - name: Debug output + run: echo "NEED_TO_RUN_TESTS=${{ needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS }}" + run-e2e-for-topic-branch: if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' permissions: From 36d6e793f89159a6a97badc11517154cb6f63aab Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 13:39:43 +0300 Subject: [PATCH 33/34] ci: debug job output --- .github/workflows/e2e_test_for_prs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 687ccde0..825fed7a 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -29,6 +29,7 @@ jobs: echo $needToRunTests echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT debug-job: + needs: check-changed-files name: debug job runs-on: ubuntu-latest steps: @@ -36,6 +37,7 @@ jobs: run: echo "NEED_TO_RUN_TESTS=${{ needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS }}" run-e2e-for-topic-branch: + needs: check-changed-files if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' permissions: id-token: write # This is required for requesting the JWT From 6841fc5dfa89672ad9dc939461c68ad3ec5471d6 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Wed, 25 Sep 2024 14:06:58 +0300 Subject: [PATCH 34/34] ci: fix diff filter and remove unused steps --- .github/workflows/e2e_test_for_prs.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/e2e_test_for_prs.yml b/.github/workflows/e2e_test_for_prs.yml index 825fed7a..182f0f86 100644 --- a/.github/workflows/e2e_test_for_prs.yml +++ b/.github/workflows/e2e_test_for_prs.yml @@ -15,7 +15,7 @@ jobs: id: decision run: | git fetch origin $GITHUB_BASE_REF - diff=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF..HEAD) + diff=$(git diff --name-only origin/$GITHUB_BASE_REF..HEAD) echo $diff needToRunTests=false for changed_file in $diff; do @@ -28,13 +28,6 @@ jobs: done echo $needToRunTests echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT - debug-job: - needs: check-changed-files - name: debug job - runs-on: ubuntu-latest - steps: - - name: Debug output - run: echo "NEED_TO_RUN_TESTS=${{ needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS }}" run-e2e-for-topic-branch: needs: check-changed-files