From 9d0ebc00cfe3883fb6bb4ac4c65e3f767c95d488 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Fri, 20 Sep 2024 16:29:20 +0300 Subject: [PATCH] ci: replace test branch flow with new flow --- .github/workflows/deploy_test_branch.yml | 107 ----------------------- .github/workflows/e2e_test_for_prs.yml | 49 +++++++++++ 2 files changed, 49 insertions(+), 107 deletions(-) delete mode 100644 .github/workflows/deploy_test_branch.yml create mode 100644 .github/workflows/e2e_test_for_prs.yml diff --git a/.github/workflows/deploy_test_branch.yml b/.github/workflows/deploy_test_branch.yml deleted file mode 100644 index 11cfd07b..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: ${{secrets.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 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