|
| 1 | +name: build |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: [ "master" ] |
| 5 | + push: |
| 6 | + branches: [ "master" ] |
| 7 | + schedule: |
| 8 | + - cron: '0 16 * * 0' # sunday 16:00 |
| 9 | + |
| 10 | +# Actions |
| 11 | +# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action |
| 12 | +# sudo-bot/action-scrutinizer@latest https://github.com/marketplace/actions/action-scrutinizer |
| 13 | + |
| 14 | +jobs: |
| 15 | + |
| 16 | + composer-normalize: |
| 17 | + name: Composer normalization |
| 18 | + runs-on: "ubuntu-latest" |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v3 |
| 22 | + - name: Setup PHP |
| 23 | + uses: shivammathur/setup-php@v2 |
| 24 | + with: |
| 25 | + php-version: '8.1' |
| 26 | + coverage: none |
| 27 | + tools: composer-normalize |
| 28 | + env: |
| 29 | + fail-fast: true |
| 30 | + - name: Composer normalize |
| 31 | + run: composer-normalize |
| 32 | + |
| 33 | + phpcs: |
| 34 | + name: Code style (phpcs) |
| 35 | + runs-on: "ubuntu-latest" |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v3 |
| 39 | + - name: Setup PHP |
| 40 | + uses: shivammathur/setup-php@v2 |
| 41 | + with: |
| 42 | + php-version: '8.1' |
| 43 | + coverage: none |
| 44 | + tools: cs2pr, phpcs |
| 45 | + env: |
| 46 | + fail-fast: true |
| 47 | + - name: Code style (phpcs) |
| 48 | + run: phpcs -q --report=checkstyle | cs2pr |
| 49 | + |
| 50 | + php-cs-fixer: |
| 51 | + name: Code style (php-cs-fixer) |
| 52 | + runs-on: "ubuntu-latest" |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v3 |
| 56 | + - name: Setup PHP |
| 57 | + uses: shivammathur/setup-php@v2 |
| 58 | + with: |
| 59 | + php-version: '8.1' |
| 60 | + coverage: none |
| 61 | + tools: cs2pr, php-cs-fixer |
| 62 | + env: |
| 63 | + fail-fast: true |
| 64 | + - name: Code style (php-cs-fixer) |
| 65 | + run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr |
| 66 | + |
| 67 | + phpstan: |
| 68 | + name: Code analysis (phpstan) |
| 69 | + runs-on: "ubuntu-latest" |
| 70 | + steps: |
| 71 | + - name: Checkout |
| 72 | + uses: actions/checkout@v3 |
| 73 | + - name: Setup PHP |
| 74 | + uses: shivammathur/setup-php@v2 |
| 75 | + with: |
| 76 | + php-version: '8.1' |
| 77 | + coverage: none |
| 78 | + tools: composer:v2, phpstan |
| 79 | + extensions: soap |
| 80 | + env: |
| 81 | + fail-fast: true |
| 82 | + - name: Get composer cache directory |
| 83 | + id: composer-cache |
| 84 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 85 | + - name: Cache dependencies |
| 86 | + uses: actions/cache@v3 |
| 87 | + with: |
| 88 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 89 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 90 | + restore-keys: ${{ runner.os }}-composer- |
| 91 | + - name: Install project dependencies |
| 92 | + run: composer upgrade --no-interaction --no-progress --prefer-dist |
| 93 | + - name: PHPStan |
| 94 | + run: phpstan analyse --no-progress --verbose |
| 95 | + |
| 96 | + tests: |
| 97 | + name: Tests on PHP ${{ matrix.php-versions }} |
| 98 | + runs-on: "ubuntu-latest" |
| 99 | + strategy: |
| 100 | + matrix: |
| 101 | + php-versions: ['7.3', '7.4', '8.0', '8.1'] |
| 102 | + steps: |
| 103 | + - name: Checkout |
| 104 | + uses: actions/checkout@v3 |
| 105 | + with: |
| 106 | + fetch-depth: 0 # required for sudo-bot/action-scrutinizer |
| 107 | + - name: Install poppler-utils |
| 108 | + run: | |
| 109 | + sudo apt-get update -y -qq |
| 110 | + sudo apt-get install -y -qq poppler-utils |
| 111 | + - name: Setup PHP |
| 112 | + uses: shivammathur/setup-php@v2 |
| 113 | + with: |
| 114 | + php-version: ${{ matrix.php-versions }} |
| 115 | + coverage: xdebug |
| 116 | + tools: composer:v2 |
| 117 | + extensions: soap |
| 118 | + env: |
| 119 | + fail-fast: true |
| 120 | + - name: Install SAT XML resources |
| 121 | + shell: bash |
| 122 | + run: | |
| 123 | + if [ ! -d tests/_files/external-resources ]; then |
| 124 | + rm -r -f tests/_files/external-resources |
| 125 | + git clone --depth 1 https://github.com/phpcfdi/resources-sat-xml resources-sat-xml-cloned |
| 126 | + mv resources-sat-xml-cloned/resources tests/_files/external-resources |
| 127 | + rm -r -f resources-sat-xml-cloned |
| 128 | + else |
| 129 | + echo tests/_files/external-resources already exists |
| 130 | + fi |
| 131 | + - name: Get composer cache directory |
| 132 | + id: composer-cache |
| 133 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 134 | + - name: Cache dependencies |
| 135 | + uses: actions/cache@v3 |
| 136 | + with: |
| 137 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 138 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 139 | + restore-keys: ${{ runner.os }}-composer- |
| 140 | + - name: Install project dependencies |
| 141 | + run: composer upgrade --no-interaction --no-progress --prefer-dist |
| 142 | + - name: Tests (phpunit) |
| 143 | + run: vendor/bin/phpunit --testdox --verbose --coverage-clover=build/coverage-clover.xml |
| 144 | + - name: Upload code coverage to scrutinizer |
| 145 | + uses: sudo-bot/action-scrutinizer@latest |
| 146 | + with: |
| 147 | + cli-args: "--format=php-clover build/coverage-clover.xml" |
| 148 | + continue-on-error: true |
0 commit comments