Skip to content

Commit

Permalink
ci: update workflows (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Feb 26, 2024
1 parent 9ea8465 commit d598f0f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 127 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint files

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: Lint files ${{ github.ref }}
cancel-in-progress: true

jobs:
php:
name: Lint PHP files
uses: monicahq/workflows/.github/workflows/lint_php.yml@v2
42 changes: 0 additions & 42 deletions .github/workflows/lint_php.yml

This file was deleted.

77 changes: 9 additions & 68 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,13 @@ on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-v4-
- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader

- name: Run psalm
run: vendor/bin/psalm --output-format=github

concurrency:
group: Static ${{ github.ref }}
cancel-in-progress: true

phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-v4-
- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader

- name : Run phpstan
run: vendor/bin/phpstan analyse
jobs:
statics:
name: Static analysis
uses: monicahq/workflows/.github/workflows/static.yml@v2
with:
php-version: 8.2
44 changes: 27 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ on:
env:
default-php-version: '8.2'
default-laravel-version: '10.*'
semantic-node-version: 18
semantic-node-version: 20

concurrency:
group: Tests ${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
Expand All @@ -29,8 +33,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1','8.2']
laravel-version: [9.*,10.*]
php-version: ['8.1', '8.2', '8.3']
laravel-version: ['9.*', '10.*']
psr7: ['guzzle']
include:
- php-version: '8.1'
Expand Down Expand Up @@ -63,6 +67,8 @@ jobs:
run: composer -V
- name: Check PHP Extensions
run: php -m
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Validate composer.json
run: composer validate
Expand All @@ -71,7 +77,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}-${{ matrix.laravel-version }}
Expand Down Expand Up @@ -104,24 +110,25 @@ jobs:
run: |
composer update --no-interaction --no-progress --prefer-dist
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Set results artifact name
id: artifact
run: echo "name=${{ matrix.php-version }}_${{ matrix.laravel-version }}${{ matrix.psr7 }}" | sed -e "s/*//g" >> $GITHUB_OUTPUT

- name: Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run test suite
run: vendor/bin/phpunit -c phpunit.xml --log-junit ./results/results_${{ matrix.psr7 }}.xml --coverage-clover ./results/coverage_${{ matrix.psr7 }}.xml

- name: Fix results files
if: success() || failure()
run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" *.xml
working-directory: results
if: success() || failure()

- name: Store results
if: matrix.php-version == env.default-php-version && matrix.laravel-version == env.default-laravel-version && (success() || failure())
uses: actions/upload-artifact@v3
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: results
name: results_${{ steps.artifact.outputs.name }}
path: results


Expand All @@ -140,16 +147,19 @@ jobs:
fetch-depth: 0

- name: Download results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: results
pattern: ${{ format('results_{0}_{1}', env.default-php-version, env.default-laravel-version) }}
path: results
merge-multiple: true

- name: Merge junit files
run: |
mkdir -p $RUNNER_TEMP/junit-merge
cd $RUNNER_TEMP/junit-merge
npm init -y
yarn set version berry
yarn dlx junit-report-merger ./results/results.xml "./results/results*.xml"
yarn dlx junit-merge --recursive --dir $GITHUB_WORKSPACE/results --out $GITHUB_WORKSPACE/results/results.xml
- name: Set coverage list
id: coverage
Expand All @@ -159,7 +169,7 @@ jobs:
- name: SonarCloud Scan
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarcloud-github-action@v2.1.1
uses: SonarSource/sonarcloud-github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down Expand Up @@ -207,7 +217,7 @@ jobs:

- name: Store changelog file
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md

0 comments on commit d598f0f

Please sign in to comment.