Forked from alistaircol/github-workflow-lint-test-laravel-private-package.yaml
Created
August 20, 2023 21:31
-
-
Save chistel/606e567dca0ef160d4ba8dad8b335eb1 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 hidden or 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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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