From cf67b95e5b2d3d9ec8e961e17534ab2c6459953b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 24 Dec 2021 16:43:38 +0100 Subject: [PATCH 1/4] Attempting to set up custom EC2 instances for E2E tests --- .github/workflows/end_to_end_tests.yml | 56 +++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index d6370f10..a5050496 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -11,10 +11,42 @@ on: jobs: + start-runner: + name: Start self-hosted EC2 runner + runs-on: ubuntu-latest + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + ec2-image-id: ami-0070a0f2d7073ed91 + ec2-instance-type: t3.xlarge + subnet-id: subnet-0ac40025f559df1bc + security-group-id: sg-0e36e96e3b8ed2d64 + #iam-role-name: my-role-name # optional, requires additional permissions + #aws-resource-tags: > # optional, requires additional permissions + # [ + # {"Key": "Name", "Value": "ec2-github-runner"}, + # {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} + # ] + + end-to-end-tests: name: "End-to-end testcafe tests" - runs-on: "ubuntu-latest" + needs: start-runner # required to start the main job when the runner is ready + runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner steps: - name: "Checkout" @@ -67,3 +99,25 @@ jobs: - name: Display logs if: ${{ failure() }} run: docker-compose logs + + stop-runner: + name: Stop self-hosted EC2 runner + needs: + - start-runner # required to get output from the start-runner job + - end-to-end-tests # required to wait when the main job is done + runs-on: ubuntu-latest + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} From 03d8562a65deebc78cc3e8881baca017f8818dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 24 Dec 2021 16:45:32 +0100 Subject: [PATCH 2/4] Trying to comment personal access token --- .github/workflows/end_to_end_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index a5050496..b473e0f2 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -29,7 +29,7 @@ jobs: uses: machulav/ec2-github-runner@v2 with: mode: start - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + #github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} ec2-image-id: ami-0070a0f2d7073ed91 ec2-instance-type: t3.xlarge subnet-id: subnet-0ac40025f559df1bc @@ -118,6 +118,6 @@ jobs: uses: machulav/ec2-github-runner@v2 with: mode: stop - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + #github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} label: ${{ needs.start-runner.outputs.label }} ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} From b58f9ed6f712cf8123939092e74ab59553b86005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 24 Dec 2021 16:50:12 +0100 Subject: [PATCH 3/4] Putting back token --- .github/workflows/end_to_end_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index b473e0f2..a5050496 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -29,7 +29,7 @@ jobs: uses: machulav/ec2-github-runner@v2 with: mode: start - #github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} ec2-image-id: ami-0070a0f2d7073ed91 ec2-instance-type: t3.xlarge subnet-id: subnet-0ac40025f559df1bc @@ -118,6 +118,6 @@ jobs: uses: machulav/ec2-github-runner@v2 with: mode: stop - #github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} label: ${{ needs.start-runner.outputs.label }} ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} From d4f8cf421044eebe561344afd6353e8268aa9b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 24 Dec 2021 17:00:45 +0100 Subject: [PATCH 4/4] Updating AMI --- .github/workflows/end_to_end_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index a5050496..a1cb5e5d 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -30,7 +30,7 @@ jobs: with: mode: start github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - ec2-image-id: ami-0070a0f2d7073ed91 + ec2-image-id: ami-094dbcc53250a2480 ec2-instance-type: t3.xlarge subnet-id: subnet-0ac40025f559df1bc security-group-id: sg-0e36e96e3b8ed2d64