From c02c86c04d88792b30c1eb6d3f371cba462f3f39 Mon Sep 17 00:00:00 2001 From: SerafimArts Date: Sun, 18 Feb 2024 00:18:17 +0000 Subject: [PATCH] Add cross-package test workflows --- .github/workflows/main.yml | 57 ++++++++++++++++++ .github/workflows/static-analysis.yml | 87 +++++++++++++++++++++++++++ psalm.xml | 2 +- 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/static-analysis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..27982ac --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,57 @@ +name: build + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + test: + name: PHP ${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }} + runs-on: ${{ matrix.os }} + if: "!contains(github.event.head_commit.message, '[ci skip]')" + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] + os: [ ubuntu-latest, macos-latest, windows-latest ] + stability: [ prefer-lowest, prefer-stable ] + steps: + - name: Set Git To Use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - name: Checkout + uses: actions/checkout@v3 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + extensions: mbstring + coverage: pcov + ini-values: "memory_limit=-1" + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Restore Composer Cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- + - name: Install Dependencies (PHP Stable) + uses: nick-invision/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + - name: Execute Tests + run: vendor/bin/phpunit --colors=always --coverage-clover=coverage.xml + - name: Upload Coverage + if: matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..89f8e43 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,87 @@ +name: static-analysis + +on: + push: + pull_request: + +jobs: + + # ---------------------------------------------------------------------------- + # Static Analysis + # ---------------------------------------------------------------------------- + + psalm: + name: Psalm + runs-on: ${{ matrix.os }} + if: "!contains(github.event.head_commit.message, '[ci skip]')" + strategy: + fail-fast: false + matrix: + php: [ '8.3' ] + os: [ ubuntu-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Restore Composer Cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- + - name: Install Dependencies + uses: nick-invision/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer install --prefer-dist --no-interaction --no-progress + - name: Execute Static Analysis + run: vendor/bin/psalm --shepherd --stats --output-format=github --php-version=${{ matrix.php }} + + # ---------------------------------------------------------------------------- + # Rector + # ---------------------------------------------------------------------------- + + rector: + name: Rector + runs-on: ${{ matrix.os }} + continue-on-error: true # ALLOW FAIL + if: "!contains(github.event.head_commit.message, '[ci skip]')" + strategy: + fail-fast: false + matrix: + php: [ '8.2' ] + os: [ ubuntu-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Restore Composer Cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- + - name: Install Dependencies + uses: nick-invision/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer install --prefer-dist --no-interaction --no-progress + - name: Check Rector + run: vendor/bin/rector --config=rector.php --dry-run diff --git a/psalm.xml b/psalm.xml index fb6fd30..7d47ed8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@