Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer 2.0 compatibility #45

Merged
merged 4 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 13 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,10 @@ commands:
EXPECTED_SIGNATURE=$(curl -s https://composer.github.io/installer.sig)
ACTUAL_SIGNATURE=$(php -r "echo hash_file('sha384', 'composer-setup.php');")
[[ "$EXPECTED_SIGNATURE" == "$ACTUAL_SIGNATURE" ]] && sudo php composer-setup.php --install-dir=/bin --filename=composer || exit 1

conditionally-skip:
description: "Skip if the current commit has no change in relevant directories"
parameters:
directories:
type: string
nodegit-workaround:
description: "Ensure nodegit runs without error"
steps:
- run:
name: Checking whether relevant files were changed
command: |
CHANGED_FILES="$( git diff HEAD^ HEAD --name-only --diff-filter=ACMRT << parameters.directories >> )"
if [ -z "$CHANGED_FILES" ] && [ -z "$CIRCLE_TAG" ]; then echo "No change to relevant file, exiting job" && circleci-agent step halt; fi
- run: sudo apt-get update && sudo apt-get install libkrb5-dev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported from #43 and #44, various fixes to prevent npm ci errors


jobs:
lint:
Expand All @@ -48,6 +40,7 @@ jobs:
- checkout
- node/install:
node-version: lts
- nodegit-workaround
- set-up-packages
- run: npm run lint

Expand All @@ -68,14 +61,14 @@ jobs:
MYSQL_ROOT_PASSWORD: wordpress
steps:
- checkout
- conditionally-skip:
directories: php tests/php
- run:
name: Installing the mysqli extension
command: sudo docker-php-ext-install mysqli
- install-composer
name: Installing PHP extensions
command: |
sudo apt-get update && sudo apt-get install libpng-dev
sudo docker-php-ext-install mysqli gd
- node/install:
node-version: lts
- nodegit-workaround
- run:
name: Installing WordPress and setting up tests
command: |
Expand All @@ -90,33 +83,19 @@ jobs:
name: Running PHPUnit
working_directory: *PLUGIN_PATH
command: |
composer remove --dev phpunit/phpunit && composer install && npm ci && npm run build
composer remove --dev phpunit/phpunit && composer install
npm ci && npm run build
composer require --dev phpunit/phpunit 5.7.9
WP_TESTS_DIR=~/project/wordpress-develop/tests/phpunit ./vendor/bin/phpunit

js-tests:
executor: php
steps:
- checkout
- conditionally-skip:
directories: js tests/js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported from https://github.com/studiopress/genesis-custom-blocks/pull/41/files#r517919253. That was merged into the editor feature branch.

- node/install:
node-version: lts
- run: npm ci && npm run test:js

e2e-tests:
machine:
image: ubuntu-1604:202004-01
steps:
- checkout
- conditionally-skip:
directories: php js css tests/e2e
- run: sudo apt-get update && sudo apt-get install php php-xml
- install-composer
- node/install:
node-version: lts
- set-up-packages
- run: npm run env start && npm run test:e2e
- nodegit-workaround
- run: HUSKY_SKIP_INSTALL=1 npm ci && npm run test:js

svn-deploy:
executor:
Expand Down Expand Up @@ -155,10 +134,6 @@ workflows:
filters:
tags:
only: /.*/
- e2e-tests:
filters:
tags:
only: /.*/
- lint:
filters:
tags:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"require-dev": {
"brain/monkey": "2.4.0",
"dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "0.7.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change that allows Composer 2.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does your comment mean that version 0.5.0 of this package was failing with composer 2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think 0.5.0 caused this message:

$ git checkout develop
$ composer self-update --2 # If needed, changes Composer to 2.*
$ composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - dealerdirect/phpcodesniffer-composer-installer is locked to version v0.5.0 and an update of this package was not requested.
    - dealerdirect/phpcodesniffer-composer-installer v0.5.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

"mikey179/vfsstream": "1.6.8",
"mockery/mockery": "1.3.1",
"phpcompatibility/phpcompatibility-wp": "2.1.0",
Expand Down
Loading