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

CI: Add concurrency to CI configs, and Composer tweaks #559

Merged
merged 4 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ on:
schedule:
- cron: '27 20 * * 2'

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/cs-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ on:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checkcs:
name: 'Basic CS and QA checks'
Expand Down Expand Up @@ -42,16 +48,16 @@ jobs:
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all --strict
run: composer validate --no-check-all --strict --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

# Lint PHP.
- name: Lint PHP against parse errors
run: composer lint-ci | cs2pr
run: composer lint-ci --no-interaction | cs2pr

# Needed as runs-on: system doesn't have xml-lint by default.
# @link https://github.com/marketplace/actions/xml-lint
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
- '**.md'
pull_request:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: PHP ${{ matrix.php }}
Expand Down Expand Up @@ -64,11 +70,11 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install Composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

# - name: Install Composer dependencies for PHP >= 8.2
# if: ${{ matrix.php >= 8.2 }}
# uses: ramsey/composer-install@v1
# uses: ramsey/composer-install@v2
# with:
# composer-options: --ignore-platform-reqs

Expand All @@ -80,12 +86,12 @@ jobs:
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"

- name: Prepare environment for integration tests
run: composer prepare-ci
run: composer prepare-ci --no-interaction

- name: Run integration tests (single site)
if: ${{ matrix.php != 8.0 }}
run: composer testwp
run: composer testwp --no-interaction

- name: Run integration tests (multisite site with code coverage)
if: ${{ matrix.php == 8.0 }}
run: composer coveragewp-ci
run: composer coveragewp-ci --no-interaction
6 changes: 6 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
- '**/*[tj]sx?'
- package*.json

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-20.04
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ on:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: PHP ${{ matrix.php }}
Expand Down Expand Up @@ -67,13 +73,13 @@ jobs:

- name: Install Composer dependencies for PHP < 8.2
if: ${{ matrix.php < 8.2 }}
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

- name: Install Composer dependencies for PHP >= 8.2
if: ${{ matrix.php >= 8.2 }}
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
composer-options: --ignore-platform-reqs

- name: Run unit tests
run: composer test
run: composer test --no-interaction
26 changes: 18 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"wp-coding-standards/wpcs": "^2.3.0",
"yoast/wp-test-utils": "^1"
},
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload": {
"classmap": [
"src/"
Expand All @@ -42,14 +48,14 @@
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html/unit -v"
],
"coveragewp": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html/integration -c phpunit-integration.xml.dist -v"
],
"coverage-ci": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit -v"
],
"coveragewp": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html/integration -c phpunit-integration.xml.dist -v"
],
"coveragewp-ci": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit -c phpunit-integration.xml.dist -v"
Expand Down Expand Up @@ -82,13 +88,17 @@
]
},
"scripts-descriptions": {
"coverage": "Run tests with code coverage for the Parse.ly plugin and generate local HTML output.",
"coverage-ci": "Run tests with code coverage for the Parse.ly plugin and generate a Clover XML file for CI.",
"coverage": "Run unit tests with code coverage for the Parse.ly plugin, send results to stdout, and generate plus local HTML output.",
"coverage-ci": "Run unit tests with code coverage for the Parse.ly plugin and send results to stdout.",
"coveragewp": "Run integration tests with code coverage for the Parse.ly plugin, send results to stdout, and generate local HTML output.",
"coveragewp-ci": "Run integration tests with code coverage for the Parse.ly plugin and send results to stdout.",
"cs": "Run PHPCS to checking coding standards for the Parse.ly plugin.",
"lint": "Run PHP linting on the Parse.ly plugin.",
"lint-ci": "Run PHP linting on the Parse.ly plugin with checkstyle output for CI.",
"prepare-ci": "Install the files and setup a database needed to run tests for the Parse.ly plugin for CI.",
"test": "Run the tests for the Parse.ly plugin.",
"test-ms": "Run the tests for the Parse.ly plugin on a multisite install."
"test": "Run the unit tests for the Parse.ly plugin.",
"test-ms": "Run the unit tests for the Parse.ly plugin on a multisite install.",
"testwp": "Run the integration tests for the Parse.ly plugin.",
"testwp-ms": "Run the integration tests for the Parse.ly plugin on a multisite install."
}
}