-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Nimut/github-actions
- Loading branch information
Showing
6 changed files
with
227 additions
and
105 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: ✏️ matrix | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
os: | ||
value: ${{ jobs.compute.outputs.os }} | ||
coverage: | ||
value: ${{ jobs.compute.outputs.coverage }} | ||
major: | ||
value: ${{ jobs.compute.outputs.major }} | ||
php: | ||
value: ${{ jobs.compute.outputs.php }} | ||
exclude: | ||
value: ${{ jobs.compute.outputs.exclude }} | ||
|
||
env: | ||
OS: '[ "ubuntu-latest" ]' | ||
COVERAGE: '[ "~9.0.0", "~9.1.0", "~9.2.0", "~10.0.0", "~10.1.0" ]' | ||
PHP: '[ "8.0", "8.1", "8.2", "8.3" ]' | ||
EXCLUDE: '[ { "coverage": "10", "php": "8.0" }, { "coverage": "~10.0.0", "php": "8.0" }, { "coverage": "~10.1.0", "php": "8.0" } ]' | ||
|
||
jobs: | ||
compute: | ||
name: Compute outputs | ||
|
||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
os: ${{ env.OS }} | ||
coverage: ${{ env.COVERAGE }} | ||
major: ${{ steps.major-version.outputs.major }} | ||
php: ${{ env.PHP }} | ||
exclude: ${{ env.EXCLUDE }} | ||
|
||
steps: | ||
- name: Compute major versions | ||
id: major-version | ||
run: | | ||
echo -e "COVERAGE\n" | ||
echo $COVERAGE | ||
echo -e "\n\nSplit by comma\n" | ||
echo $COVERAGE | tr "," "\n" | ||
echo -e "\n\nParse numbers\n" | ||
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | ||
echo -e "\n\nCut last 2 characters\n" | ||
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | ||
echo -e "\n\nSort by version\n" | ||
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | ||
echo -e "\n\nUnique values only\n" | ||
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | ||
echo -e "\n\nCovert to JSON\n" | ||
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))' | ||
echo "major=$(echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))')" >> $GITHUB_OUTPUT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
name: 🏃 tests | ||
|
||
on: [ push, pull_request, workflow_call ] | ||
|
||
jobs: | ||
compute: | ||
uses: ./.github/workflows/compute.yml | ||
|
||
build: | ||
name: 'Build COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}' | ||
|
||
needs: [ compute ] | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ${{ fromJson(needs.compute.outputs.os) }} | ||
coverage: ${{ fromJson(needs.compute.outputs.coverage) }} | ||
php: ${{ fromJson(needs.compute.outputs.php) }} | ||
exclude: ${{ fromJson(needs.compute.outputs.exclude) }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Store Composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Store PHP code coverage version | ||
id: version-cache | ||
env: | ||
COVERAGE: ${{ matrix.coverage }} | ||
run: | | ||
echo "version=$(echo $COVERAGE | tr -d -c 0-9)" >> $GITHUB_OUTPUT | ||
echo "major=$(echo $COVERAGE | tr -d -c 0-9 | sed 's/.\{2\}$//')" >> $GITHUB_OUTPUT | ||
- uses: actions/cache/restore@v4 | ||
id: restore-composer-cache | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}- | ||
${{ runner.os }}-${{ matrix.php }}- | ||
${{ runner.os }}- | ||
- name: Set up PHP Version ${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Environment Check | ||
run: | | ||
php --version | ||
composer --version | ||
mkdir -p .Log/coverage/ .Log/log/ | ||
- name: Validate composer.json | ||
run: composer validate | ||
|
||
- name: Composer install | ||
run: composer update --with "phpunit/php-code-coverage:${{ matrix.coverage }}" --no-interaction | ||
|
||
- name: Save composer cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }} | ||
|
||
- name: Lint PHP | ||
run: php .Build/bin/parallel-lint --exclude .Build . | ||
|
||
- name: Run PHPUnit | ||
if: ${{ success() || failure() }} | ||
run: find 'tests' -wholename '*Test.php' | parallel --gnu 'echo -e "\n\nRunning test {}"; HASH=${{ steps.version-cache.outputs.version }}_$( echo {} | md5sum | cut -d " " -f 1); .Build/bin/phpunit --log-junit .Log/log/junit_$HASH.xml --coverage-php .Log/coverage/coverage_$HASH.cov --coverage-filter src/ {}' | ||
|
||
- name: Archive PHPUnit logs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }} | ||
path: .Log/* | ||
retention-days: 1 | ||
|
||
merge: | ||
name: 'Merge COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}' | ||
|
||
needs: [ compute, build ] | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ${{ fromJson(needs.compute.outputs.os) }} | ||
coverage: ${{ fromJson(needs.compute.outputs.major) }} | ||
php: ${{ fromJson(needs.compute.outputs.php) }} | ||
exclude: ${{ fromJson(needs.compute.outputs.exclude) }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download PHPUnit logs | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: .Log | ||
pattern: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}-* | ||
merge-multiple: true | ||
|
||
- name: Store Composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- uses: actions/cache/restore@v4 | ||
id: restore-composer-cache | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.php }}- | ||
${{ runner.os }}- | ||
- name: Set up PHP Version ${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Environment Check | ||
run: | | ||
php --version | ||
composer --version | ||
- name: Validate composer.json | ||
run: composer validate | ||
|
||
- name: Composer install | ||
run: composer update --with "phpunit/php-code-coverage:^${{ matrix.coverage }}.0" --no-interaction | ||
|
||
- name: Save composer cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }} | ||
|
||
- name: Merge log files | ||
run: bin/phpunit-merger log .Log/log/ .Log/junit.xml | ||
|
||
- name: Merge coverage files | ||
run: bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml | ||
|
||
- name: Archive PHPUnit logs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: phpunit-logs-merged-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }} | ||
path: .Log/* | ||
retention-days: 1 |
This file was deleted.
Oops, something went wrong.
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
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
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