test_and_lint #399
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test_and_lint | |
env: | |
SIMPLETEST_DB: "sqlite://localhost//tmp/test.sqlite" | |
SIMPLETEST_BASE_URL: "http://127.0.0.1:8000" | |
APIGEE_EDGE_AUTH_TYPE: ${{ secrets.APIGEE_EDGE_AUTH_TYPE }} | |
APIGEE_EDGE_ORGANIZATION: ${{ secrets.APIGEE_EDGE_ORGANIZATION }} | |
APIGEE_EDGE_USERNAME: ${{ secrets.APIGEE_EDGE_USERNAME }} | |
APIGEE_EDGE_PASSWORD: ${{ secrets.APIGEE_EDGE_PASSWORD }} | |
APIGEE_EDGE_INSTANCE_TYPE: ${{ secrets.APIGEE_EDGE_INSTANCE_TYPE }} | |
APIGEE_INTEGRATION_ENABLE: ${{ secrets.APIGEE_INTEGRATION_ENABLE }} | |
APIGEE_EDGE_ENDPOINT: ${{ secrets.APIGEE_EDGE_ENDPOINT }} | |
APIGEE_EDGE_ACCOUNT_JSON_KEY: ${{ secrets.APIGEE_EDGE_ACCOUNT_JSON_KEY }} | |
APIGEE_EDGE_HYBRID_ENDPOINT: ${{ secrets.APIGEE_EDGE_HYBRID_ENDPOINT }} | |
APIGEE_EDGE_HYBRID_ORGANIZATION: ${{ secrets.APIGEE_EDGE_HYBRID_ORGANIZATION }} | |
BROWSERTEST_OUTPUT_DIRECTORY: "sites/simpletest/browser_output" | |
BROWSERTEST_OUTPUT_BASE_URL: "" | |
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", { "chromeOptions": { "w3c": false } }, "http://127.0.0.1:9515/wd/hub"]' | |
on: | |
push: | |
pull_request_target: | |
schedule: | |
- cron: '00 01 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: "PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal-core }} | ${{ matrix.instance-type }}" | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- "8.1" | |
- "8.2" | |
drupal-core: | |
# Should update the following as the minimum supported version from Drupal.org | |
- "10.1.x" | |
- "10.2.x" | |
instance-type: | |
- "Edge" | |
- "X" | |
steps: | |
- name: Disable deprecations check for PR | |
if: github.event_name != 'schedule' | |
run: | | |
echo "Disable deprecations check" | |
echo "SYMFONY_DEPRECATIONS_HELPER=disabled" >> $GITHUB_ENV | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "xdebug" | |
php-version: "${{ matrix.php-version }}" | |
tools: composer:v2 | |
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv, opcache, imagick | |
- name: Checkout Drupal core | |
run: | | |
git clone --depth 1 --branch ${{ matrix.drupal-core }} https://github.com/drupal/drupal.git drupal | |
mkdir -p drupal/modules/contrib/apigee_m10n | |
mkdir -p drupal/sites/simpletest/browser_output | |
- name: Get composer cache directory | |
id: composercache | |
run: | | |
cd drupal | |
echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composercache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Checkout apigee_m10n module | |
uses: actions/checkout@v4 | |
with: | |
path: drupal/modules/contrib/apigee_m10n | |
- name: "Allow plugins and dev dependencies" | |
run: | | |
cd drupal | |
composer config --no-plugins allow-plugins.composer/installers true | |
composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true | |
composer config --no-plugins allow-plugins.drupal/core-project-message true | |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true | |
composer config --no-plugins allow-plugins.wikimedia/composer-merge-plugin true | |
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true | |
composer config --no-plugins allow-plugins.cweagans/composer-patches true | |
composer config --no-plugins allow-plugins.php-http/discovery true | |
composer config preferred-install."drupal/apigee_edge" source | |
composer config preferred-install."apigee/apigee-client-php" source | |
composer config minimum-stability dev | |
composer require drupal/commerce:^2.16 | |
composer require drupal/token:~1.0 | |
composer require wikimedia/composer-merge-plugin | |
composer config --json extra.merge-plugin.require '["modules/contrib/apigee_m10n/composer.json"]' | |
composer config platform.php ${{ matrix.php-version }} | |
composer update --with-all-dependencies | |
composer require --dev phpspec/prophecy-phpunit:^2 | |
- name: "PHPCS and setting up Apigee X environment" | |
if: ${{ matrix.instance-type == 'X' }} | |
run: | | |
cd drupal | |
cp modules/contrib/apigee_m10n/phpcs.xml.dist . | |
vendor/bin/phpcs --standard=./phpcs.xml.dist modules/contrib/apigee_m10n -p -s -n --colors | |
# Setting environment variables to run Apigee X tests | |
echo "APIGEE_EDGE_INSTANCE_TYPE=hybrid" >> $GITHUB_ENV | |
echo "APIGEE_EDGE_ORGANIZATION=$APIGEE_EDGE_HYBRID_ORGANIZATION" >> $GITHUB_ENV | |
echo "APIGEE_EDGE_ENDPOINT=$APIGEE_EDGE_HYBRID_ENDPOINT" >> $GITHUB_ENV | |
composer show > composer-show.txt | |
- name: Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: composer-${{ matrix.php-version }}-${{ matrix.drupal-core }}-${{ matrix.instance-type }}-artifact | |
path: drupal/composer.* | |
# Install drupal using minimal installation profile and enable the module. | |
- name: Install Drupal | |
run: | | |
cd drupal | |
php -d sendmail_path=$(which true); vendor/bin/drush --yes -v site-install minimal --db-url="$SIMPLETEST_DB" | |
vendor/bin/drush rs 8000 & | |
- uses: nanasess/setup-chromedriver@v2 | |
- run: | | |
export DISPLAY=:99 | |
chromedriver --url-base=/wd/hub & | |
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional | |
- name: "Run PHPUnit tests" | |
if: ${{ matrix.drupal-core != '10.1.x' || matrix.php-version != '8.1' }} | |
run: | | |
cd drupal | |
vendor/bin/phpunit -c core --verbose --color --group apigee_m10n --testsuite unit,kernel,functional,functional-javascript modules/contrib/apigee_m10n | |
- name: "Run PHPUnit tests with Code Coverage" | |
if: ${{ matrix.drupal-core == '10.1.x' && matrix.php-version == '8.1' }} | |
run: | | |
cd drupal | |
cp modules/contrib/apigee_m10n/phpunit.core.xml.dist core/phpunit.xml | |
vendor/bin/phpunit -c core --verbose --color --group apigee_m10n --testsuite unit,kernel,functional,functional-javascript --coverage-clover /tmp/coverage_${{ matrix.instance-type }}.xml modules/contrib/apigee_m10n | |
- name: Artifacts | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: browser-output-${{ matrix.php-version }}-${{ matrix.drupal-core }}-${{ matrix.instance-type }}-artifact | |
path: drupal/sites/simpletest/browser_output/* | |
- name: Upload coverage to Codecov | |
if: ${{ matrix.drupal-core == '10.1.x' && matrix.php-version == '8.1' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: /tmp/coverage_${{ matrix.instance-type }}.xml | |
name: codecov-umbrella | |
fail_ci_if_error: true | |
verbose: true |