-
Notifications
You must be signed in to change notification settings - Fork 54
136 lines (124 loc) · 6.2 KB
/
end-2-end-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: End-2-end
on:
push:
tags:
- '*'
pull_request:
types:
- opened
- labeled
concurrency: e2e-tests
jobs:
secrets-gate:
# Only run tests if the pull request is opened or labeled with run_e2e_tests
if: ${{ github.event.label.name == 'run_e2e_tests' || github.event.action != 'labeled' }}
runs-on: ubuntu-latest
outputs:
is-secret-set: ${{ steps.is-secret-set.outputs.is_mollie_api_key_test_set }}
steps:
- id: is-secret-set
env:
MOLLIE_API_KEY_TEST: ${{ secrets.MOLLIE_API_KEY_TEST }}
if: "${{ env.MOLLIE_API_KEY_TEST != '' }}"
run: echo "is_mollie_api_key_test_set=true" >> $GITHUB_OUTPUT
# Remove flag used to trigger the e2e tests
remove_flag:
if: ${{ contains(github.event.*.labels.*.name, 'run_e2e_tests') }}
runs-on: ubuntu-latest
steps:
- name: Remove run E2E tests label
uses: actions/github-script@v5
with:
script: |
github.rest.issues.removeLabel({
issue_number: ${{ github.event.issue.number || github.event.number }},
owner: context.repo.owner,
repo: context.repo.repo,
name: "run_e2e_tests"
})
e2e-tests:
needs:
- secrets-gate
# Only run this job if the secret is set
if: needs.secrets-gate.outputs.is-secret-set == 'true'
strategy:
fail-fast: false
matrix:
include:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p5
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
MAGENTO_VERSION: ${{ matrix.MAGENTO_VERSION }}
MOLLIE_API_KEY_TEST: ${{ secrets.MOLLIE_API_KEY_TEST }}
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_TESTRAIL_DOMAIN: ${{ secrets.TESTRAIL_DOMAIN }}
CYPRESS_TESTRAIL_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
CYPRESS_TESTRAIL_PASSWORD: ${{ secrets.TESTRAIL_PASSWORD }}
CYPRESS_TESTRAIL_PROJECT_ID: 5
CYPRESS_TESTRAIL_MILESTONE_ID: 37
CYPRESS_TESTRAIL_RUN_NAME: "Github Workflow, ${{ github.head_ref || github.ref_name }}, PHP version: ${{ matrix.PHP_VERSION }}, Magento version: ${{ matrix.MAGENTO_VERSION }}"
CYPRESS_TESTRAIL_RUN_CLOSE: true
steps:
- uses: actions/checkout@v2
- name: Start the Magento container
run: |
openssl req -x509 -newkey rsa:4096 -keyout .github/workflows/templates/nginx-proxy/magento.test.key -out .github/workflows/templates/nginx-proxy/magento.test.crt -days 365 -nodes -subj "/CN=magento.test" && \
docker compose -f .github/workflows/templates/docker-compose.yml up -d
# Get the URL from ngrok
docker compose -f .github/workflows/templates/docker-compose.yml logs ngrok
MAGENTO_URL=$(docker exec magento-project-community-edition /bin/bash -c "curl -s ngrok:4040/api/tunnels |jq -r \".tunnels[0].public_url\"")
echo "magento_url=$MAGENTO_URL" >> $GITHUB_ENV
# Note the `mollie-pwa-*.html` files, as it is copied to the pub folder. This is so that it can be accessed by Cypress.
- name: Upload the code into the docker container
run: |
sed -i '/version/d' ./composer.json && \
docker cp $(pwd) magento-project-community-edition:/data/extensions/ && \
docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html magento-project-community-edition:/data/pub/opt/ && \
docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html magento-project-community-edition:/data/pub/opt/ && \
docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev
- name: Activate the extension
run: |
docker exec magento-project-community-edition php /data/merge-config.php
docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --no-interaction"
docker exec magento-project-community-edition /bin/bash /data/configure-mollie.sh
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/use_webhooks custom_url"
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/custom_webhook_url ${{ env.magento_url }}/mollie/checkout/webhook"
- name: Prepare Magento
run: |
docker exec magento-project-community-edition /bin/bash ./change-base-url https://magento.test/
docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
docker exec magento-project-community-edition ./retry "php bin/magento setup:static-content:deploy -f"
docker exec magento-project-community-edition ./retry "php bin/magento indexer:reindex"
- name: Start all containers and check if we can reach Magento (and warmup cache)
run: |
docker exec e2e curl -k -s -o /dev/null -w "%{http_code}" https://magento.test/
docker exec e2e curl -k -s -o /dev/null -w "%{http_code}" ${{ env.magento_url }}
- name: Run Cypress
run: |
# Copy the .git folder for Cypress
docker cp .git e2e:/e2e/.git
docker exec e2e cypress run --browser chrome --config defaultCommandTimeout=20000
- name: Dump docker-compose logs
if: always()
run: |
docker compose -f .github/workflows/templates/docker-compose.yml logs magento > magento.log && \
docker compose -f .github/workflows/templates/docker-compose.yml logs ngrok > ngrok.log && \
docker compose -f .github/workflows/templates/docker-compose.yml logs e2e > e2e.log
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: E2E logs - ${{ matrix.PHP_VERSION }} - ${{ matrix.MAGENTO_VERSION }}
path: |
Test/End-2-end/cypress/videos
Test/End-2-end/cypress/screenshots
magento-logs
magento.log
nginx-proxy.log
e2e.log