Skip to content

Commit

Permalink
ci(all): fixup failing CI pipeline
Browse files Browse the repository at this point in the history
We've

1. Pinned PHP/Composer/Magento versions more correctly for future-compatability.
2. Now run integrations tests against tagged releases as opposed to directly against branches in Github.
3. Cached composer across the pipeline, improving test runs by ~2minutes (down from 5).
4. Matrixed across composer versions as well, because Magento versions didn't use to support composer 2.
5. Moved down from `ubuntu-latest` to `ubuntu-18.04` because of Magento 2.3's PHP constraint. We'll revert once it's EoL.

BREAKING CHANGE: we no longer test against php7.2. Please use it at your own risk.
  • Loading branch information
damienwebdev committed Aug 2, 2021
1 parent f3c9e67 commit 4edc8e5
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 91 deletions.
107 changes: 62 additions & 45 deletions .azure/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
variables:
phpVersion: 7.2

# specific path build
trigger:
branches:
include:
- master
- main
paths:
exclude:
- docs/*
Expand All @@ -14,14 +11,17 @@ trigger:
pr:
branches:
include:
- master
- main
paths:
exclude:
- docs/*
- docs/README.md

pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-18.04'

variables:
COMPOSER_CACHE_DIR: $(Pipeline.Workspace)/.composer

resources:
containers:
Expand All @@ -33,77 +33,94 @@ resources:
- 9200:9200
stages:
- stage: build
variables:
phpVersion: 7.4
jobs:
- job: Lint
displayName: Lint
steps:
- template: templates/setup-php.yml
- template: templates/magento-auth.yml
- template: templates/composer-cache.yml
parameters:
key: '"$(phpVersion)"'
- template: templates/composer-install.yml
- script: composer run-script lint
displayName: Lint
- job: Unit_Test
displayName: Unit Test
strategy:
matrix:
php73:
phpVersion: 7.3
php74:
phpVersion: 7.4
steps:
- template: templates/setup-php.yml
- template: templates/magento-auth.yml
- template: templates/composer-cache.yml
parameters:
key: '"$(phpVersion)"'
- template: templates/composer-install.yml
- script: composer run-script unit-test
displayName: Unit Test
- job: Integration_Test
displayName: Integration Test
variables:
magedir: "../magento2"
services:
elasticsearch: elasticsearch
strategy:
matrix:
php72_magento2.3:
phpVersion: 7.2
magentoTag: 2.3
php73_magento2.3:
phpVersion: 7.3
magentoTag: 2.3
php73_magento2.4:
phpVersion: 7.3
magentoTag: 2.4
magentoTag: ^2.3
composerVersion: 1
php74_magento2.4:
phpVersion: 7.4
magentoTag: 2.4
services:
elasticsearch: elasticsearch
magentoTag: ^2.4
composerVersion: 2
steps:
- template: templates/setup-php.yml

- script: bash ./ci/scripts/wait-for-elasticsearch.sh http://localhost:9200/_cat/health?h=status
displayName: Waiting for Elasticsearch
- template: templates/magento-auth.yml
- template: templates/integration-setup.yml
- script: |
cd $(pwd)/../magento2/dev/tests/integration
../../../vendor/bin/phpunit --testsuite "Graycore_StdLogging"
displayName: Run Integration Tests
- stage: prerelease
displayName: Pre-release Verification
dependsOn: []
variables:
magedir: "../magento2"
repository: https://github.com/graycoreio/magento2-stdlogging
jobs:
- job: package_install_test
displayName: Package Install Test
strategy:
matrix:
php72_magento2.3:
phpVersion: 7.2
magentoTag: 2.3.5
php74_magento2.4:
phpVersion: 7.4
magentoTag: 2.4.0
steps:
- template: templates/setup-php.yml
- template: templates/magento-auth.yml
displayName: Wait for Elasticsearch to start...

- template: templates/composer-version.yml
parameters:
composerVersion: $(composerVersion)

- template: templates/composer-cache.yml
parameters:
key: '"$(phpVersion)" | "$(magentoTag)" | "$(composerVersion)" | "v2"'

- template: templates/magento-auth.yml

- script: composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=$(magentoTag) $(magedir) --no-install
displayName: Create Magento $(magentoTag) Project

- script: composer config repositories.local path $(Build.SourcesDirectory)
workingDirectory: $(magedir)
displayName: Add Github Repo for Testing

- script: composer require graycore/magento2-stdlogging "@dev" --no-update && composer install --dry-run
- script: composer require graycore/magento2-stdlogging "@dev" --no-update && composer install
workingDirectory: $(magedir)
displayName: Require and attempt install
displayName: Require and attempt install

- script: sudo systemctl start mysql.service && mysql -u root -proot < $(Build.SourcesDirectory)/ci/scripts/create-database.sql
displayName: Setup MySQL

- script: cp $(Build.SourcesDirectory)/ci/phpunit.xml $(magedir)/dev/tests/integration/phpunit.xml
displayName: Copy PHPUnit.xml

- script: cp ci/install-config-mysql-2.3.php ../magento2/dev/tests/integration/etc/install-config-mysql.php
condition: and(succeeded(), contains(variables['magentoTag'], '2.3'))
displayName: Setup Magento Test config.php (2.3)

- script: cp ci/install-config-mysql-2.4.php ../magento2/dev/tests/integration/etc/install-config-mysql.php
condition: and(succeeded(), contains(variables['magentoTag'], '2.4'))
displayName: Setup Magento Test config.php (2.4)

- script: ../../../vendor/bin/phpunit --testsuite "Graycore_StdLogging"
workingDirectory: $(magedir)/dev/tests/integration
displayName: Run Tests
14 changes: 14 additions & 0 deletions .azure/templates/composer-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
parameters:
- name: key # name of the parameter; required
type: string # data type of the parameter; required
default: ""

steps:
- task: Cache@2
inputs:
${{ if eq(parameters['key'], '') }}:
key: 'composer | "$(Agent.OS)" | composer.lock'
${{ if ne(parameters['key'], '') }}:
key: 'composer | "$(Agent.OS)" | ${{ parameters.key }} | composer.lock'
path: $(COMPOSER_CACHE_DIR)
displayName: Cache composer
6 changes: 3 additions & 3 deletions .azure/templates/composer-install.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
steps:
- script: composer install --no-interaction --prefer-dist
displayName: 'composer install'
steps:
- script: composer install --no-interaction --prefer-dist
displayName: 'composer install'
7 changes: 7 additions & 0 deletions .azure/templates/composer-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
- name: composerVersion # name of the parameter; required
type: string # data type of the parameter; required
default: 2
steps:
- script: sudo composer self-update --${{ parameters.composerVersion }}
displayName: Pin to Composer Version ${{ parameters.composerVersion }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![Packagist Downloads](https://img.shields.io/packagist/dm/graycore/magento2-stdlogging?color=blue)](https://packagist.org/packages/graycore/magento2-stdlogging/stats)
[![Packagist Version](https://img.shields.io/packagist/v/graycore/magento2-stdlogging?color=blue)](https://packagist.org/packages/graycore/magento2-stdlogging)
[![Packagist License](https://img.shields.io/packagist/l/graycore/magento2-stdlogging)](https://github.com/graycoreio/magento2-stdlogging/blob/master/LICENSE)
[![Build Status](https://graycore.visualstudio.com/open-source/_apis/build/status/graycoreio.magento2-stdlogging?branchName=master)](https://graycore.visualstudio.com/open-source/_build/latest?definitionId=14&branchName=master)
[![Packagist License](https://img.shields.io/packagist/l/graycore/magento2-stdlogging)](https://github.com/graycoreio/magento2-stdlogging/blob/main/LICENSE)
[![Build Status](https://graycore.visualstudio.com/open-source/_apis/build/status/graycoreio.magento2-stdlogging?branchName=main)](https://graycore.visualstudio.com/open-source/_build/latest?definitionId=14&branchName=main)

## Magento Version Support
![Magento v2.3 Supported](https://img.shields.io/badge/Magento-2.3-brightgreen.svg?labelColor=2f2b2f&logo=magento&logoColor=f26724&color=464246&longCache=true&style=flat)
Expand Down
41 changes: 0 additions & 41 deletions ci/scripts/integration-setup.sh

This file was deleted.

0 comments on commit 4edc8e5

Please sign in to comment.