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

feature: introduce CI #62

Merged
merged 22 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a78f651
feature: introduce CI
boesing Sep 24, 2021
57edf15
qa: introduce additional checks
boesing Sep 24, 2021
2abcb4e
feature: modify continuous integration to iterate over test projects
boesing Mar 24, 2022
69f7cd9
bugfix: checkout code before generating the matrix
boesing Mar 24, 2022
1b31ab9
bugfix: return JSON array as matrix output
boesing Mar 24, 2022
7e95c31
bugfix: remove `fromJSON` from matrix
boesing Mar 24, 2022
b3d7262
bugfix: use proper `set-output` notation to provide JSON array
boesing Mar 24, 2022
e9a23c4
bugfix: use alternative notation to output variable
boesing Mar 24, 2022
263af90
qa: add some project structures for integration testing
boesing Apr 6, 2022
cd86164
refactor: build docker container and use it within build steps
boesing Apr 6, 2022
dd7ef62
bugfix: fixup container filename
boesing Apr 6, 2022
4be073d
bugfix: checkout source code
boesing Apr 6, 2022
3b82981
feature: use github action cache for container build
boesing Apr 6, 2022
454ac89
bugfix: use `-it` rather than `--it`
boesing Apr 6, 2022
92f93aa
bugfix: remove interactive tty from `docker run`
boesing Apr 6, 2022
2f92a40
bugfix: use `TEST_TAG` as container identifier
boesing Apr 6, 2022
2efe76c
feature: output generated matrix from `matrix_generation` step
boesing Apr 6, 2022
a963e94
bugfix: properly escape JSON output
boesing Apr 6, 2022
503b791
bugfix: change to `<=8.1.0` since `,` constraint is not supported (yet)
boesing Apr 6, 2022
e514d80
bugfix: add missing `s` to `docs`
boesing Apr 6, 2022
a945d27
bugfix: escape JSON for verification
boesing Apr 6, 2022
eef730a
docs: add some clarification on why we generate a matrix here
boesing Jun 28, 2022
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
98 changes: 98 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
- 'refs/pull/*'

env:
TEST_TAG: laminas/ci-matrix-action:test

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout sourcecode
uses: actions/checkout@v3
- name: Gather integration test directory names
id: matrix
run: cd tests; echo "::set-output name=matrix::[\"$(ls -d * | tr '\n' ' ' | sed 's/ $//' | sed 's/ /\",\"/g')\"]"
boesing marked this conversation as resolved.
Show resolved Hide resolved

container:
name: Prepare docker container
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
steps:
- name: Checkout sourcecode
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build container for CI pipeline
uses: docker/build-push-action@v2
with:
context: .
load: true
push: false
tags: ${{ env.TEST_TAG }}
outputs: type=docker,dest=/tmp/container.tar
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload container artifact
uses: actions/upload-artifact@v2
with:
name: container
path: /tmp/container.tar

qa:
name: QA Checks
needs: [matrix, container]
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
projectName: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout sourcecode
uses: actions/checkout@v3

- name: Download container artifact
uses: actions/download-artifact@v2
with:
name: container
path: /tmp

- name: Load image
run: docker load --input /tmp/container.tar

- name: "Generating matrix for project: ${{ matrix.projectName }}"
id: matrix_generation
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
run: cd tests/${PROJECT_NAME_TO_TEST} && docker run -v $(realpath .):/github/workspace -w=/github/workspace ${TEST_TAG} node ../../index.js $(test -r diff && cat diff || echo -n "")

- name: "Output generated matrix"
uses: sergeysova/jq-action@v2
with:
cmd: "jq . < <(echo '${{ steps.matrix_generation.outputs.matrix }}')"

- name: Minify matrix from test directory
uses: sergeysova/jq-action@v2
id: expected_matrix
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
with:
cmd: 'jq -c . < tests/${PROJECT_NAME_TO_TEST}/matrix.json'

- name: "verify output of generated matrix for project: empty-project"
run: diff --color <(echo '${{ steps.expected_matrix.outputs.value }}') <(echo '${{ steps.matrix_generation.outputs.matrix }}')
10 changes: 10 additions & 0 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"additional_checks": [
{
"name": "Run matrix on every test project",
"job": {
"command": "for directory tests/*; do cd $directory; node ../../index.js || exit 1; cd ../.."
}
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-codeception-dist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
Empty file.
10 changes: 10 additions & 0 deletions tests/code-check-codeception-dist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/codecept run on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-codeception-nodist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
Empty file.
10 changes: 10 additions & 0 deletions tests/code-check-codeception-nodist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/codecept run on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-composer-require-checker/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
10 changes: 10 additions & 0 deletions tests/code-check-composer-require-checker/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-infection-dist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
1 change: 1 addition & 0 deletions tests/code-check-infection-dist/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file.
10 changes: 10 additions & 0 deletions tests/code-check-infection-dist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "phpdbg -qrr ./vendor/bin/infection on PHP 7.4",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-infection-nodist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
1 change: 1 addition & 0 deletions tests/code-check-infection-nodist/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file.
10 changes: 10 additions & 0 deletions tests/code-check-infection-nodist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "phpdbg -qrr ./vendor/bin/infection on PHP 7.4",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"php": "~8.1.0"
},
"require-dev": {
"roave/infection-static-analysis-plugin": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin on PHP 8.1",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"php": "~8.1.0"
},
"require-dev": {
"roave/infection-static-analysis-plugin": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin on PHP 8.1",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
3 changes: 3 additions & 0 deletions tests/code-check-phpbench/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
10 changes: 10 additions & 0 deletions tests/code-check-phpbench/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
1 change: 1 addition & 0 deletions tests/code-check-phpbench/phpbench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions tests/code-check-phpcs-dist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
10 changes: 10 additions & 0 deletions tests/code-check-phpcs-dist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/phpcs -q --report=checkstyle | cs2pr on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/phpcs -q --report=checkstyle | cs2pr\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-phpcs-dist/phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
3 changes: 3 additions & 0 deletions tests/code-check-phpcs-nodist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
10 changes: 10 additions & 0 deletions tests/code-check-phpcs-nodist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/phpcs -q --report=checkstyle | cs2pr on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/phpcs -q --report=checkstyle | cs2pr\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-phpcs-nodist/phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
3 changes: 3 additions & 0 deletions tests/code-check-phpunit-dist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
5 changes: 5 additions & 0 deletions tests/code-check-phpunit-dist/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "~8.1.0"
}
}
2 changes: 2 additions & 0 deletions tests/code-check-phpunit-dist/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions tests/code-check-phpunit-dist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"include": [
{
"name": "PHPUnit on PHP 8.1 with locked dependencies",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit on PHP 8.1 with lowest dependencies",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit on PHP 8.1 with latest dependencies",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-phpunit-dist/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
3 changes: 3 additions & 0 deletions tests/code-check-phpunit-nodist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
5 changes: 5 additions & 0 deletions tests/code-check-phpunit-nodist/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "~8.1.0"
}
}
16 changes: 16 additions & 0 deletions tests/code-check-phpunit-nodist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"include": [
{
"name": "PHPUnit on PHP 8.1 with lowest dependencies",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit on PHP 8.1 with latest dependencies",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-phpunit-nodist/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
3 changes: 3 additions & 0 deletions tests/code-check-psalm-dist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
10 changes: 10 additions & 0 deletions tests/code-check-psalm-dist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/psalm --shepherd --stats --output-format=github --no-cache on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/psalm --shepherd --stats --output-format=github --no-cache\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-psalm-dist/psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
3 changes: 3 additions & 0 deletions tests/code-check-psalm-nodist/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stablePHP": "7.4"
}
10 changes: 10 additions & 0 deletions tests/code-check-psalm-nodist/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "./vendor/bin/psalm --shepherd --stats --output-format=github --no-cache on PHP 7.4",
"job": "{\"command\":\"./vendor/bin/psalm --shepherd --stats --output-format=github --no-cache\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[\"memory_limit = -1\"],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
2 changes: 2 additions & 0 deletions tests/code-check-psalm-nodist/psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
Loading