From ef143b63529372ccaeed9dd1bb12978f0da05469 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 7 Sep 2023 10:07:26 +0900 Subject: [PATCH] chore: reuse github workflows --- .github/workflows/deptrac.yml | 68 +------------------------ .github/workflows/phpcpd.yml | 33 ++----------- .github/workflows/phpcsfixer.yml | 51 +------------------ .github/workflows/phpstan.yml | 70 +------------------------- .github/workflows/phpunit.yml | 85 +------------------------------- .github/workflows/psalm.yml | 66 +------------------------ .github/workflows/rector.yml | 59 +--------------------- .github/workflows/unused.yml | 54 +------------------- 8 files changed, 18 insertions(+), 468 deletions(-) diff --git a/.github/workflows/deptrac.yml b/.github/workflows/deptrac.yml index 9042772..0de9b55 100644 --- a/.github/workflows/deptrac.yml +++ b/.github/workflows/deptrac.yml @@ -2,72 +2,8 @@ name: Deptrac on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'depfile.yaml' - - '.github/workflows/deptrac.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'depfile.yaml' - - '.github/workflows/deptrac.yml' jobs: - build: - name: Dependency Tracing - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phive - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Create Deptrac cache directory - run: mkdir -p build/ - - - name: Cache Deptrac results - uses: actions/cache@v3 - with: - path: build - key: ${{ runner.os }}-deptrac-${{ github.sha }} - restore-keys: ${{ runner.os }}-deptrac- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Trace dependencies - run: | - sudo phive --no-progress install --global --trust-gpg-keys B8F640134AB1782E,A98E898BB53EB748 qossmic/deptrac - deptrac analyze --cache-file=build/deptrac.cache + deptrac: + uses: codeigniter4/.github/.github/workflows/deptrac.yml@main diff --git a/.github/workflows/phpcpd.yml b/.github/workflows/phpcpd.yml index 41abe9a..a63f978 100644 --- a/.github/workflows/phpcpd.yml +++ b/.github/workflows/phpcpd.yml @@ -2,35 +2,10 @@ name: PHPCPD on: pull_request: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcpd.yml' push: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcpd.yml' jobs: - build: - name: Code Copy-Paste Detection - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phpcpd - extensions: dom, mbstring - coverage: none - - - name: Detect duplicate code - run: phpcpd src/ tests/ + phpcpd: + uses: codeigniter4/.github/.github/workflows/phpcpd.yml@main + with: + dirs: "src/ tests/" diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml index 302e3ae..84cbc39 100644 --- a/.github/workflows/phpcsfixer.yml +++ b/.github/workflows/phpcsfixer.yml @@ -2,55 +2,8 @@ name: PHPCSFixer on: pull_request: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcsfixer.yml' push: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcsfixer.yml' jobs: - build: - name: Coding Standards - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: json, tokenizer - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Check code for standards compliance - run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff + phpcsfixer: + uses: codeigniter4/.github/.github/workflows/phpcsfixer.yml@main diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 55c2bd9..fabe558 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -2,74 +2,8 @@ name: PHPStan on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpstan*' - - '.github/workflows/phpstan.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpstan*' - - '.github/workflows/phpstan.yml' jobs: - build: - name: PHP ${{ matrix.php-versions }} Static Analysis - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - strategy: - fail-fast: false - matrix: - php-versions: ['7.4', '8.0', '8.1'] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpstan, phpunit - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Create PHPStan cache directory - run: mkdir -p build/phpstan - - - name: Cache PHPStan results - uses: actions/cache@v3 - with: - path: build/phpstan - key: ${{ runner.os }}-phpstan-${{ github.sha }} - restore-keys: ${{ runner.os }}-phpstan- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Run static analysis - run: vendor/bin/phpstan analyze + phpstan: + uses: codeigniter4/.github/.github/workflows/phpstan.yml@main diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index cd165a5..3d476af 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -2,89 +2,8 @@ name: PHPUnit on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit.yml' jobs: - main: - name: PHP ${{ matrix.php-versions }} Unit Tests - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - strategy: - matrix: - php-versions: ['7.4', '8.0', '8.1'] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: composer, phive, phpunit - extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3 - coverage: xdebug - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Test with PHPUnit - run: vendor/bin/phpunit --verbose --coverage-text - env: - TERM: xterm-256color - TACHYCARDIA_MONITOR_GA: enabled - - - if: matrix.php-versions == '8.0' - name: Run Coveralls - continue-on-error: true - run: | - sudo phive --no-progress install --global --trust-gpg-keys E82B2FB314E9906E php-coveralls - php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - - coveralls: - needs: [main] - name: Coveralls Finished - runs-on: ubuntu-latest - steps: - - name: Upload Coveralls results - uses: coverallsapp/github-action@master - continue-on-error: true - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + phpunit: + uses: codeigniter4/.github/.github/workflows/phpunit.yml@main diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index aabe1f2..4722444 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -2,70 +2,8 @@ name: Psalm on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'psalm*' - - '.github/workflows/psalm.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'psalm*' - - '.github/workflows/psalm.yml' jobs: - build: - name: Psalm Analysis - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phpstan, phpunit - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Create Psalm cache directory - run: mkdir -p build/psalm - - - name: Cache Psalm results - uses: actions/cache@v3 - with: - path: build/psalm - key: ${{ runner.os }}-psalm-${{ github.sha }} - restore-keys: ${{ runner.os }}-psalm- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Run Psalm analysis - run: vendor/bin/psalm + psalm: + uses: codeigniter4/.github/.github/workflows/psalm.yml@main diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index a0feec3..88eec78 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -2,63 +2,8 @@ name: Rector on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'rector.php' - - '.github/workflows/rector.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'rector.php' - - '.github/workflows/rector.yml' jobs: - build: - name: PHP ${{ matrix.php-versions }} Rector Analysis - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - strategy: - fail-fast: false - matrix: - php-versions: ['7.4', '8.0', '8.1', '8.2'] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpstan - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_FILES_DIR }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Analyze for refactoring - run: vendor/bin/rector process --dry-run --no-progress-bar + rector: + uses: codeigniter4/.github/.github/workflows/rector.yml@main diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index 0506531..13b155c 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -2,58 +2,8 @@ name: Unused on: pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - '.github/workflows/unused.yml' push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - '.github/workflows/unused.yml' jobs: - build: - name: Unused Package Detection - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer, composer-unused - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Detect unused packages - run: composer-unused -vvv --output-format=github --ansi --no-interaction --no-progress + unused: + uses: codeigniter4/.github/.github/workflows/unused.yml@main