Created
September 5, 2022 14:58
-
-
Save alistaircol/e636582d66b416c3ac5f76dcb21c82d6 to your computer and use it in GitHub Desktop.
GitHub Workflow - Laravel Unit Feature Test Private Repository Package Code Coverage Generation Artifact
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: GitHub Workflow - Laravel Unit Feature Test Private Repository Package Code Coverage Generation Artifact | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
env: | |
COMPOSER_AUTH: >- | |
{"github-oauth": { "github.com": ${{ secrets.PAT }} }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup PHP Action | |
uses: shivammathur/setup-php@2.9.0 | |
with: | |
php-version: 8.0 | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v2 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install --prefer-dist --no-progress --no-suggest | |
- name: Determine if linting is required | |
id: linting-required | |
uses: tj-actions/changed-files@v29.0.3 | |
with: | |
files: | | |
app/**/*.php | |
config/**/*.php | |
- name: PHP Lint Check | |
if: >- | |
steps.linting-required.outputs.only_changed == 'true' | |
|| steps.linting-required.outputs.only_modified == 'true' | |
run: composer run lint | |
- name: PSR2 Code Sniffer | |
if: >- | |
steps.linting-required.outputs.only_changed == 'true' | |
|| steps.linting-required.outputs.only_modified == 'true' | |
run: composer run style | |
test: | |
runs-on: ubuntu-latest | |
needs: lint | |
env: | |
COMPOSER_AUTH: >- | |
{"github-oauth": { "github.com": ${{ secrets.PAT }} }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup PHP Action | |
uses: shivammathur/setup-php@2.9.0 | |
with: | |
php-version: 8.0 | |
extensions: pdo_sqlite, sqlite3, xdebug | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v2 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install --prefer-dist --no-progress --no-suggest | |
- name: Run Preamble | |
run: | | |
mkdir -p database | |
touch database/database.sqlite | |
cp .env.testing .env | |
rm .env.example | |
php artisan migrate --database=sqlite | |
mkdir -p build/coverage | |
- name: Run tests | |
run: composer run tests | |
- name: Generate coverage report | |
run: composer run coverage | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage-report | |
path: build/coverage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment