From 4f428af515c2942ae12aadcfc43e1e9948cc6f87 Mon Sep 17 00:00:00 2001 From: Tiago Date: Wed, 21 Jul 2021 17:56:36 -0300 Subject: [PATCH 1/3] add e2e tests to ci.yml --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7377b4af88..7ff1eefbb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,3 +171,41 @@ jobs: run: | docker run -u $(id -u) --rm -v ${{ github.workspace}}:/awx_devel/:Z \ --workdir=/awx_devel ghcr.io/${{ github.repository_owner }}/awx_devel:${{ github.base_ref }} make ui-test + + e2e-test: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v2 + + - name: Checkout tower-qa + uses: actions/checkout@v2 + with: + path: tower-qa + + - name: Log in to gcr.io + run: | + echo "${{ secrets.GCR_PULL_SECRET }}" | docker login gcr.io -u _json_key --password-stdin + + - name: Pull awx_cypress_base image + run: | + docker pull gcr.io/ansible-tower-engineering/awx_cypress_base:stable + + - name: Build cypress + run: | + cd tower-qa/ui-tests/awx-pf-tests + docker build -t awx-pf-tests . + + - name: Log in to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Pre-pull image to warm build cache + run: | + docker pull ghcr.io/${{ github.repository_owner }}/awx_devel:${{ github.base_ref }} + + - name: Build image + run: | + DEV_DOCKER_TAG_BASE=ghcr.io/${{ github.repository_owner }} COMPOSE_TAG=${{ github.base_ref }} make docker-compose-build \ No newline at end of file From 0c8f4fc9e7de9cf37cb4df62424121c7b5c9b60f Mon Sep 17 00:00:00 2001 From: Tiago Date: Wed, 21 Jul 2021 18:52:14 -0300 Subject: [PATCH 2/3] Revert "add e2e tests to ci.yml" This reverts commit 4f428af515c2942ae12aadcfc43e1e9948cc6f87. --- .github/workflows/ci.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ff1eefbb6..7377b4af88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,41 +171,3 @@ jobs: run: | docker run -u $(id -u) --rm -v ${{ github.workspace}}:/awx_devel/:Z \ --workdir=/awx_devel ghcr.io/${{ github.repository_owner }}/awx_devel:${{ github.base_ref }} make ui-test - - e2e-test: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - uses: actions/checkout@v2 - - - name: Checkout tower-qa - uses: actions/checkout@v2 - with: - path: tower-qa - - - name: Log in to gcr.io - run: | - echo "${{ secrets.GCR_PULL_SECRET }}" | docker login gcr.io -u _json_key --password-stdin - - - name: Pull awx_cypress_base image - run: | - docker pull gcr.io/ansible-tower-engineering/awx_cypress_base:stable - - - name: Build cypress - run: | - cd tower-qa/ui-tests/awx-pf-tests - docker build -t awx-pf-tests . - - - name: Log in to registry - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Pre-pull image to warm build cache - run: | - docker pull ghcr.io/${{ github.repository_owner }}/awx_devel:${{ github.base_ref }} - - - name: Build image - run: | - DEV_DOCKER_TAG_BASE=ghcr.io/${{ github.repository_owner }} COMPOSE_TAG=${{ github.base_ref }} make docker-compose-build \ No newline at end of file From 777d37c4b8d4505cbdaf366546814c0d4aa06dc1 Mon Sep 17 00:00:00 2001 From: Tiago Date: Wed, 21 Jul 2021 18:53:16 -0300 Subject: [PATCH 3/3] Add workflow to run e2e tests when the label needs_test is applied to the PR --- .github/workflows/e2e_test.yml | 106 +++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .github/workflows/e2e_test.yml diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml new file mode 100644 index 0000000000..2abdbc49fc --- /dev/null +++ b/.github/workflows/e2e_test.yml @@ -0,0 +1,106 @@ +--- +name: E2E Tests +on: + pull_request: + types: [labeled] +jobs: + e2e-test: + if: contains(github.event.pull_request.labels.*.name, 'qe:e2e') + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + strategy: + matrix: + job: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] + + steps: + - uses: actions/checkout@v2 + + - name: Install system deps + run: sudo apt-get install -y gettext + + - name: Log in to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Pre-pull image to warm build cache + run: | + docker pull ghcr.io/${{ github.repository_owner }}/awx_devel:${{ github.base_ref }} + + - name: Build UI + run: | + DEV_DOCKER_TAG_BASE=ghcr.io/${{ github.repository_owner }} COMPOSE_TAG=${{ github.base_ref }} make ui-devel + + - name: Start AWX + run: | + DEV_DOCKER_TAG_BASE=ghcr.io/${{ github.repository_owner }} COMPOSE_TAG=${{ github.base_ref }} make docker-compose &> make-docker-compose-output.log & + + - name: Log in to gcr.io + shell: bash + env: + GCR_PULL_SECRET: ${{ secrets.GCR_PULL_SECRET }} + run: | + echo "$GCR_PULL_SECRET" | docker login -u _json_key --password-stdin gcr.io + + - name: Pull awx_cypress_base image + run: | + docker pull gcr.io/ansible-tower-engineering/awx_cypress_base:stable + + - name: Checkout tower-qa + uses: actions/checkout@v2 + with: + repository: ${{ github.repository_owner }}/tower-qa + ssh-key: ${{ secrets.QA_REPO_KEY }} + path: tower-qa + ref: devel + + - name: Build cypress + run: | + cd tower-qa/ui-tests/awx-pf-tests + docker build -t awx-pf-tests . + + - name: Update default AWX password + run: | + while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -k https://localhost:8043/api/v2/ping/)" != "200" ]] + do + echo "Waiting for AWX..." + sleep 5; + done + echo "AWX is up, updating the password..." + docker exec -i tools_awx_1 sh <<-EOSH + awx-manage update_password --username=admin --password=password + EOSH + + - name: Run E2E tests + env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + run: | + export COMMIT_INFO_BRANCH=$GITHUB_HEAD_REF + export COMMIT_INFO_AUTHOR=$GITHUB_ACTOR + export COMMIT_INFO_SHA=$GITHUB_SHA + export COMMIT_INFO_REMOTE=$GITHUB_REPOSITORY_OWNER + cd tower-qa/ui-tests/awx-pf-tests + AWX_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tools_awx_1) + printenv > .env + echo "Executing tests:" + docker run \ + --network '_sources_default' \ + --ipc=host \ + --env-file=.env \ + -e CYPRESS_baseUrl="https://$AWX_IP:8043" \ + -e CYPRESS_AWX_E2E_USERNAME=admin \ + -e CYPRESS_AWX_E2E_PASSWORD='password' \ + -e COMMAND="npm run cypress-gha" \ + -v /dev/shm:/dev/shm \ + -v $PWD:/e2e \ + -w /e2e \ + awx-pf-tests run --project . + + - name: Save AWX logs + uses: actions/upload-artifact@v2 + with: + name: AWX-logs-${{ matrix.job }} + path: make-docker-compose-output.log + +