the-kbA-team/micro-auth-lib

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
name: "CI workflow"
on:
  # Triggers the workflow on push or pull request events
  push:
  pull_request:

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
permissions:
  contents: "read"
jobs:

  composer:
    name: "Composer config validation"
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@v3"
      - name: "Validate composer.json"
        run: "composer validate --strict"

  codesniffer:
    name: "PSR12 validation (PHP_CodeSniffer)"
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@v3"
      - uses: "php-actions/phpcs@v1"

  php:
    name: "PHP tests"
    runs-on: "ubuntu-latest"
    strategy:
      matrix:
        php_version:
          - "7.4"
          - "8.1"
          - "8.2"
          - "8.3"
    env:
      CC_TEST_REPORTER_ID: "c8bc13b8787c6de68ae094688dec7fd7bb3a14445d560194b5785fae2623d489"

    steps:
      - name: "GIT checkout"
        uses: "actions/checkout@v3"

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

      - name: "PHP syntax validation"
        run: |
          php -l src/
          php -l tests/

      - name: "Get composer cache directory"
        id: "composer-cache"
        run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

      - name: "Cache composer dependencies"
        uses: "actions/cache@v3"
        with:
          path: "${{ steps.composer-cache.outputs.dir }}"
          key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
          restore-keys: "${{ runner.os }}-composer-"

      - name: "Composer install dependencies"
        run: "composer install --prefer-dist --no-progress"

      - name: "PHPStan Static Analysis"
        uses: "php-actions/phpstan@v3"
        with:
          php_version: "${{ matrix.php_version }}"
          configuration: "phpstan.neon"

      - name: "CodeClimate Reporter Setup"
        run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build

      - name: "PHPUnit tests"
        run: |
          php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text 
          export PHPUNIT_EXIT_CODE=$?

      - name: "CodeClimate report"
        run: "./cc-test-reporter after-build -t clover"