Repository navigation
164 lines (147 loc) · 6.14 KB
/
Copy pathphpunit.yml
File metadata and controls
164 lines (147 loc) · 6.14 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: PHPUnit
on:
workflow_dispatch:
inputs:
civicrm-version:
description: CiviCRM Composer constraint (for example 6.14.0, 6.18.0-alpha1, or dev-master)
required: false
default: ^6.14
type: string
php-version:
description: PHP version to test, or the full compatibility matrix
required: false
default: matrix
type: choice
options:
- matrix
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
pull_request:
paths:
- '**.php'
- composer.json
- phpunit.xml.dist
- phpunit-integration.xml
- .github/workflows/phpunit.yml
push:
branches:
- main
paths:
- '**.php'
- composer.json
- phpunit.xml.dist
- phpunit-integration.xml
- .github/workflows/phpunit.yml
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
phpunit:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
php-version: ${{ fromJSON((inputs.php-version || 'matrix') == 'matrix' && '["8.1","8.2","8.3","8.4","8.5"]' || format('["{0}"]', inputs.php-version)) }}
name: PHP ${{ matrix.php-version }}
env:
CIVICRM_VERSION: ${{ inputs.civicrm-version || '^6.14' }}
DATABASE_URL: mysql://user:password@127.0.0.1:3306/civicrm?new_link=true
steps:
- name: Checkout extension
uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: bcmath, curl, fileinfo, gd, intl, mbstring, mysqli, xml, zip
coverage: none
env:
fail-fast: true
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-composer-
- name: Install test runner
run: composer install --no-interaction --no-progress --prefer-dist
- name: Set up MySQL
run: |
sudo systemctl start mysql.service
until sudo mysqladmin ping --silent; do sleep 1; done
sudo mysql -e 'CREATE DATABASE civicrm;' --user=root --password=root
sudo mysql -e 'CREATE USER "user"@"localhost" IDENTIFIED BY "password";' --user=root --password=root
sudo mysql -e 'GRANT ALL ON *.* TO "user"@"localhost";' --user=root --password=root
sudo mysql -e 'GRANT SUPER ON *.* TO "user"@"localhost";' --user=root --password=root
sudo mysql -e 'FLUSH PRIVILEGES;' --user=root --password=root
- name: Install CiviCRM standalone
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
EXT_DIR="$GITHUB_WORKSPACE"
EXT_PACKAGE=$(composer show --self --name-only)
cd ..
git clone --depth=1 https://github.com/civicrm/civicrm-standalone.git
cd civicrm-standalone
composer config --no-plugins allow-plugins.composer/installers true
composer config --no-plugins allow-plugins.cweagans/composer-patches true
composer config --json 'extra.installer-paths.ext/{$name}' '["type:civicrm-ext"]'
# Historical CiviCRM releases may depend on packages with known advisories.
# This applies only to this disposable compatibility-test checkout.
composer config --no-plugins policy.advisories.block false
composer config repositories.helloasso path "$EXT_DIR"
composer remove --no-update civicrm/civicrm-core civicrm/civicrm-packages
composer require --no-update \
"civicrm/civicrm-core:$CIVICRM_VERSION" \
"civicrm/civicrm-packages:$CIVICRM_VERSION"
composer require --with-all-dependencies --no-interaction --no-progress \
composer/installers \
civicrm/cli-tools \
"$EXT_PACKAGE"
MJWSHARED_TAG="$(git ls-remote --tags --refs https://lab.civicrm.org/extensions/mjwshared.git | awk -F/ '{print $3}' | grep -E '^[0-9]+(\.[0-9]+){2}$' | sort -V | tail -n1)"
test -n "$MJWSHARED_TAG"
git clone --depth=1 --branch "$MJWSHARED_TAG" \
https://lab.civicrm.org/extensions/mjwshared.git \
ext/mjwshared
- name: Configure CiviCRM
run: |
cd ../civicrm-standalone
export PATH="$(realpath vendor/bin):$PATH"
cv core:install \
--db="$DATABASE_URL" \
--comp="CiviContribute,CiviEvent,CiviMember"
export CV_CONFIG="$HOME/.cv.json"
cv vars:fill --quiet
sed -i "s#\"TEST_DB_DSN\": \".*\"#\"TEST_DB_DSN\": \"$DATABASE_URL\"#g" "$CV_CONFIG"
cv en mjwshared
cv en helloasso-payment-processor
cv updb
- name: Run unit tests
env:
HELLOASSO_UNIT_ONLY: '0'
HELLOASSO_BOOT_LEVEL: full
run: |
export PATH="$(realpath ../civicrm-standalone/vendor/bin):$PATH"
export CV_CONFIG="$HOME/.cv.json"
export CIVICRM_SETTINGS="$(realpath ../civicrm-standalone/private/civicrm.settings.php)"
composer phpunit
- name: Run CiviCRM integration tests
env:
HELLOASSO_TEST_API_CLIENT_ID: ${{ secrets.HELLOASSO_TEST_API_CLIENT_ID }}
HELLOASSO_TEST_API_CLIENT_SECRET: ${{ secrets.HELLOASSO_TEST_API_CLIENT_SECRET }}
HELLOASSO_TEST_ORGANIZATION_SLUG: ${{ vars.HELLOASSO_TEST_ORGANIZATION_SLUG }}
HELLOASSO_RUN_SANDBOX_SMOKE: ${{ matrix.php-version == '8.4' && '1' || '0' }}
run: |
export PATH="$(realpath ../civicrm-standalone/vendor/bin):$PATH"
export CV_CONFIG="$HOME/.cv.json"
export CIVICRM_SETTINGS="$(realpath ../civicrm-standalone/private/civicrm.settings.php)"
composer phpunit:integration