-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 6.32 KB
/
integration_tests.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
name: Integration tests (InstaWP)
on:
workflow_run:
workflows: [Generate plugins]
types:
- completed
env:
CHECKOUT_SUBMODULES: "recursive"
jobs:
provide_data:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Retrieve the GitHub Action artifact URLs to install in InstaWP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: ${{ env.CHECKOUT_SUBMODULES }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ramsey/composer-install@v3
- id: input_data
run: |
echo "additional_integration_test_plugins=$(vendor/bin/monorepo-builder additional-integration-test-plugins --config=config/monorepo-builder/additional-integration-test-plugins.php)" >> $GITHUB_OUTPUT
- name: Retrieve artifact URLs from GitHub workflow
uses: actions/github-script@v7
id: artifact-url
with:
script: |
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
// Use Nightly Link as it allows InstaWP to access the artifacts, i.e. without having to be logged-in to GitHub
// @see https://nightly.link
// Allow installing additional plugins, set via the monorepo configuration
const artifactURLs = allArtifacts.data.artifacts.map((artifact) => {
return artifact.url.replace('https://api.github.com/repos', 'https://nightly.link') + '.zip'
}).concat(${{ steps.input_data.outputs.additional_integration_test_plugins }});
return artifactURLs.join(',');
result-encoding: string
- name: Artifact URL for InstaWP
run: echo "Artifact URL for InstaWP - ${{ steps.artifact-url.outputs.result }}"
shell: bash
- id: output_data
run: |
echo "instawp_config_entries=$(vendor/bin/monorepo-builder instawp-config-entries-json --config=config/monorepo-builder/instawp-config-entries-json.php)" >> $GITHUB_OUTPUT
echo "instawp_instance_sleeping_time=$(vendor/bin/monorepo-builder env-var INSTAWP_INSTANCE_SLEEPING_TIME --config=config/monorepo-builder/env-var.php)" >> $GITHUB_OUTPUT
outputs:
artifact_url: ${{ steps.artifact-url.outputs.result }}
instawp_config_entries: ${{ steps.output_data.outputs.instawp_config_entries }}
instawp_instance_sleeping_time: ${{ steps.output_data.outputs.instawp_instance_sleeping_time }}
process:
needs: provide_data
if: needs.provide_data.outputs.instawp_config_entries != '[]'
name: Launch InstaWP site from template "${{ matrix.instaWPConfig.templateSlug }}" and execute integration tests against it
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
instaWPConfig: ${{ fromJson(needs.provide_data.outputs.instawp_config_entries) }}
steps:
- uses: actions/checkout@v4
with:
submodules: ${{ env.CHECKOUT_SUBMODULES }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ramsey/composer-install@v3
- name: Create InstaWP instance
uses: instawp/wordpress-testing-automation@main
id: create-instawp
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INSTAWP_TOKEN: ${{ secrets.INSTAWP_TOKEN }}
INSTAWP_TEMPLATE_SLUG: ${{ matrix.instaWPConfig.templateSlug }}
REPO_ID: ${{ matrix.instaWPConfig.repoID }}
INSTAWP_ACTION: create-site-template
ARTIFACT_URL: ${{ needs.provide_data.outputs.artifact_url }}
- name: InstaWP instance URL
run: echo "InstaWP instance URL - ${{ steps.create-instawp.outputs.instawp_url }}"
shell: bash
- name: Extract InstaWP domain
id: extract-instawp-domain
run: |
instawp_domain="$(echo "${{ steps.create-instawp.outputs.instawp_url }}" | sed -e s#https://##)"
echo "instawp-domain=$(echo $instawp_domain)" >> $GITHUB_OUTPUT
- name: Sleep ${{ needs.provide_data.outputs.instawp_instance_sleeping_time }} seconds to make sure InstaWP is ready
if: ${{ needs.provide_data.outputs.instawp_instance_sleeping_time }}
run: "sleep ${{ needs.provide_data.outputs.instawp_instance_sleeping_time }}s"
shell: bash
- name: Run tests
run: |
INTEGRATION_TESTS_WEBSERVER_DOMAIN=${{ steps.extract-instawp-domain.outputs.instawp-domain }} \
INTEGRATION_TESTS_AUTHENTICATED_ADMIN_USER_USERNAME=${{ steps.create-instawp.outputs.iwp_wp_username }} \
INTEGRATION_TESTS_AUTHENTICATED_ADMIN_USER_PASSWORD=${{ steps.create-instawp.outputs.iwp_wp_password }} \
vendor/bin/phpunit --filter=Integration
- name: Destroy InstaWP instance
uses: instawp/wordpress-testing-automation@main
id: destroy-instawp
if: ${{ always() }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INSTAWP_TOKEN: ${{ secrets.INSTAWP_TOKEN }}
INSTAWP_TEMPLATE_SLUG: ${{ matrix.instaWPConfig.templateSlug }}
REPO_ID: ${{ matrix.instaWPConfig.repoID }}
INSTAWP_ACTION: destroy-site