NikolaGavric94/laravel-square

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
# This is a basic workflow to help you get started with Actions
name: "Build and test PHP 8.x"

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  pull_request:
    branches:
      - 'master'
      - 'nikolag_master'
      - '3.1.**'
      - '3.2.**'
      - '3.3.**'
  push:
    branches:
      - 'master'
      - '3.1.**'
      - '3.2.**'
      - '3.3.**'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    name: PHP${{ matrix.php-version }} with Laravel${{ matrix.illuminate }} on ubuntu-latest
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - php-version: "8.2"
            illuminate: "10.*"
            orchestra: "8.*"
            phpunit: "10.*"
    # Steps represent a sequence of tasks that will be executed as part of the job
    environment: sandbox
    steps:
      - uses: actions/checkout@v3

      # Setup php
      - name: Setup PHP with PECL extension
        uses: shivammathur/setup-php@v2
        with:
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl
          php-version: ${{ matrix.php-version }}

      # Setup laravel deps
      - name: Setup laravel deps
        env:
          ILLUMINATE_VERSION: ${{ matrix.illuminate }}
        run: composer require illuminate/config:${ILLUMINATE_VERSION} illuminate/console:${ILLUMINATE_VERSION} illuminate/contracts:${ILLUMINATE_VERSION} illuminate/container:${ILLUMINATE_VERSION} illuminate/database:${ILLUMINATE_VERSION} --no-update

      # Setup orchestra testbench and phpunit
      - name: Install test deps
        env:
          ORCHESTRA_TESTBENCH_VERSION: ${{ matrix.orchestra }}
          PHPUNIT_VERSION: ${{ matrix.phpunit }}
        run: composer require --dev orchestra/testbench:${ORCHESTRA_TESTBENCH_VERSION} phpunit/phpunit:${PHPUNIT_VERSION} --no-update

      # Copy env config and install remaining composer deps
      - name: Copy config and build
        run: |
          cp .env.testing .env
          composer self-update
          composer install --no-interaction --no-cache
          composer dump-autoload

      # Run phpunit tests
      - name: Run tests
        run: vendor/bin/phpunit --migrate-configuration && vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml
        env:
          SQUARE_ORDER_NAMESPACE: ${{ secrets.SQUARE_ORDER_NAMESPACE }}
          SQUARE_USER_NAMESPACE: ${{ secrets.SQUARE_USER_NAMESPACE }}
          SQUARE_APPLICATION_ID: ${{ secrets.SQUARE_APPLICATION_ID }}
          SQUARE_TOKEN: ${{ secrets.SQUARE_TOKEN }}
          SQUARE_LOCATION: ${{ secrets.SQUARE_LOCATION }}
          SQUARE_SANDBOX: ${{ secrets.SQUARE_SANDBOX }}

      # Upload test coverage to code climate
      - name: Publish code coverage
        uses: paambaati/codeclimate-action@v3.2.0
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_TOKEN }}