From 35a03c61bbc8ebb42f919caeb70d3f67ecfb1e5d Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Fri, 29 Dec 2023 19:09:10 +0100 Subject: [PATCH] build: reuse workflows (#147) --- .github/workflows/static.yml | 72 +--------------- .github/workflows/tests.yml | 156 +++++------------------------------ 2 files changed, 23 insertions(+), 205 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 25ab9f6..c8c22a4 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -5,71 +5,7 @@ on: 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 - - - 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 + statics: + uses: monicahq/workflows/.github/workflows/static.yml@main + with: + php-version: 8.2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d03e48a..9dccef7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,152 +14,34 @@ on: types: - created -env: - default-php-version: '8.2' - default-laravel-version: '10.*' - semantic-node-version: 18 - - jobs: tests: - runs-on: ubuntu-latest + uses: monicahq/workflows/.github/workflows/library.yml@main + with: + php-version: ${{ matrix.php-version }} + laravel-version: ${{ matrix.laravel-version }} + coverage: ${{ matrix.php-version == '8.2' && matrix.laravel-version == '10.*' }} + strategy: fail-fast: false matrix: - php-version: ['8.0', '8.1', '8.2'] + php-version: [8.0, 8.1, 8.2] laravel-version: [8.*, 9.*, 10.*] exclude: - - laravel-version: 10.* - php-version: '8.0' - name: PHP ${{ matrix.php-version }} | Laravel ${{ matrix.laravel-version }} - - 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 }} - coverage: none - extension-csv: sqlite, gmp - - name: Check PHP Version - run: php -v - - name: Check Composer Version - run: composer -V - - name: Check PHP Extensions - run: php -m - - - name: Validate composer.json - run: composer validate - - - 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 }}-${{ matrix.laravel-version }} - restore-keys: | - ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}-${{ matrix.laravel-version }} - ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }} - ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }} - ${{ runner.os }}-composer-v4- - - - name: Install dependencies with Laravel ${{ matrix.laravel-version }} - run: | - export COMPOSER_ROOT_VERSION=dev-main - composer require "illuminate/support:${{ matrix.laravel-version }}" --no-update - composer update --no-interaction --no-progress --prefer-dist - - - name: Run test suite - run: phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/results.xml --coverage-clover ./results/coverage.xml - - - name: Fix results files - run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" *.xml - working-directory: results - - - name: Fix laravel version - id: laravel - run: echo "version=${{ matrix.laravel-version }}" | sed "s/*/0/g" >> $GITHUB_OUTPUT - - - name: Store results - if: matrix.php-version == env.default-php-version && matrix.laravel-version == env.default-laravel-version - uses: actions/upload-artifact@v4 - with: - name: results-${{ matrix.php-version }}-${{ steps.laravel.outputs.version }} - path: results + - php-version: 8.0 + laravel-version: 10.* - - #################### - # Sonarcloud - #################### reporting: + uses: monicahq/workflows/.github/workflows/reporting.yml@main + with: + project: monicahq_laravel-sabre + sources: src + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} needs: tests - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Download results - uses: actions/download-artifact@v4 - with: - pattern: results-* - path: results - merge-multiple: true - - name: SonarCloud Scan - if: env.SONAR_TOKEN != '' - uses: SonarSource/sonarcloud-github-action@v2.1.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - #################### - # Semantic release - #################### - semantic-release: + release: + uses: monicahq/workflows/.github/workflows/release.yml@main + secrets: + GH_TOKEN_RELEASE: ${{ secrets.GH_TOKEN_RELEASE }} needs: tests - runs-on: ubuntu-latest - name: Semantic release - if: github.event_name != 'pull_request' - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Get all tags - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.semantic-node-version }} - - - name: Semantic Release - uses: cycjimmy/semantic-release-action@v4 - id: semantic - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_TOKEN_RELEASE: ${{ secrets.GH_TOKEN_RELEASE }} - with: - semantic_version: 19 - extra_plugins: | - conventional-changelog-conventionalcommits@5.0.0 - @semantic-release/changelog@6 - semantic-release-github-pullrequest - - - name: New release published - if: steps.semantic.outputs.new_release_published == 'true' - run: echo ${{ steps.semantic.outputs.new_release_version }} - - - name: Store changelog file - if: steps.semantic.outputs.new_release_published == 'true' - uses: actions/upload-artifact@v4 - with: - name: changelog - path: CHANGELOG.md