Skip to content

Commit 26e33c0

Browse files
committed
- Added GitHub Actions Workflow
- Set push and pull_request events on master, main, and develop branches - Created a job for running Laravel tests on Ubuntu using different PHP versions and Laravel dependencies - Configured caching for node_modules, Composer, and vendor directories to speed up builds - Added steps for installing Node.js and PHP versions, building frontend, and running PestPHP tests and Laravel Pint code sniffer - Ignored test and documentation files in Git using .gitattributes - Added .scrutinizer.yml file for building and testing code with PHP scrutinizer, while ignoring tests/ directory and running PestPHP for coverage
1 parent 85146a0 commit 26e33c0

File tree

3 files changed

+143
-1
lines changed

3 files changed

+143
-1
lines changed

.gitattributes

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
* text=auto
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/.scrutinizer.yml export-ignore
10+
/tests export-ignore
11+
/.editorconfig export-ignore

.github/workflows/main.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# GithHub Actions Workflow generated with Ghygen
2+
# Original configuration: https://ghygen.hi-folks.dev?code=5eeae8ee67de18c6bb0ec00188b0c617
3+
name: Laravel Git Hooks
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
- develop
10+
pull_request:
11+
branches:
12+
- main
13+
- develop
14+
15+
jobs:
16+
laravel-tests:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
operating-system: [ ubuntu-latest ]
22+
php-versions: [ '8.1','8.0','7.4' ]
23+
dependency-stability: [ 'prefer-none' ]
24+
25+
laravel: [ '10.*' ]
26+
include:
27+
- laravel: 10.*
28+
testbench: 8.*
29+
30+
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: '19.x'
38+
- name: Cache node_modules directory
39+
uses: actions/cache@v3
40+
id: node_modules-cache
41+
with:
42+
path: node_modules
43+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
44+
- name: Install NPM packages
45+
if: steps.node_modules-cache.outputs.cache-hit != 'true'
46+
run: npm ci
47+
- name: Build frontend
48+
run: npm run development
49+
- name: Install PHP versions
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: ${{ matrix.php-versions }}
53+
- name: Get Composer Cache Directory 2
54+
id: composer-cache
55+
run: |
56+
echo "::set-output name=dir::$(composer config cache-files-dir)"
57+
- uses: actions/cache@v3
58+
id: actions-cache
59+
with:
60+
path: ${{ steps.composer-cache.outputs.dir }}
61+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-composer-
64+
- name: Cache PHP dependencies
65+
uses: actions/cache@v3
66+
id: vendor-cache
67+
with:
68+
path: vendor
69+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
70+
- name: Install Laravel Dependencies
71+
run: |
72+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
73+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
74+
75+
- name: Update Dependencies with latest stable
76+
if: matrix.dependency-stability == 'prefer-stable'
77+
run: composer update --prefer-stable
78+
- name: Update Dependencies with lowest stable
79+
if: matrix.dependency-stability == 'prefer-lowest'
80+
run: composer update --prefer-stable --prefer-lowest
81+
82+
83+
- name: Show dir
84+
run: pwd
85+
- name: PHP Version
86+
run: php --version
87+
88+
# Code quality
89+
90+
- name: Execute tests (Unit and Feature tests) via PestPHP
91+
# Set environment
92+
env:
93+
SESSION_DRIVER: array
94+
95+
run: vendor/bin/pest
96+
97+
98+
- name: Execute Code Sniffer via Laravel Pint
99+
run: vendor/bin/pint --test src config

.scrutinizer.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
build:
2+
nodes:
3+
analysis:
4+
project_setup:
5+
override: true
6+
tests:
7+
override: [php-scrutinizer-run]
8+
coverage:
9+
tests:
10+
override:
11+
- command: XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --coverage-clover=coverage.clover
12+
coverage:
13+
file: coverage.clover
14+
format: clover
15+
16+
filter:
17+
excluded_paths: [tests/*]
18+
19+
checks:
20+
php:
21+
remove_extra_empty_lines: true
22+
remove_php_closing_tag: true
23+
remove_trailing_whitespace: true
24+
fix_use_statements:
25+
remove_unused: true
26+
preserve_multiple: false
27+
preserve_blanklines: true
28+
order_alphabetically: true
29+
fix_php_opening_tag: true
30+
fix_linefeed: true
31+
fix_line_ending: true
32+
fix_identation_4spaces: true
33+
fix_doc_comments: true

0 commit comments

Comments
 (0)