-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (86 loc) · 2.68 KB
/
Copy pathapi-ci.yml
File metadata and controls
100 lines (86 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: API CI Pipeline
on:
push:
branches:
- main
- '*.x'
pull_request:
branches:
- main
schedule:
- cron: '0 0 * * *'
jobs:
lint:
name: "Code Quality & Static Analysis"
runs-on: ubuntu-latest
defaults:
run:
working-directory: 'api'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite
coverage: none
- name: Install Dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Copy .env
run: cp ../.env.example ../.env
- name: Generate Application Key
run: php artisan key:generate
laravel-tests:
name: "Tests (PHP ${{ matrix.php-version }})"
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: [ '8.4','8.5']
defaults:
run:
working-directory: 'api'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite
coverage: xdebug
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: api/vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('api/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
- name: Create .env
run: |
if [ -z "${{ vars.ENV_FILE }}" ]; then
echo "ENV_FILE secret is not set. Copying .env.example from root..."
# Copies from root to root
cp ../.env.example ../.env
else
echo "Creating .env from secret in root..."
echo "${{ vars.ENV_FILE }}" > ../.env
fi
# Verify file exists in root (for debugging logs)
ls -la ../.env
- name: Install Dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via Pest/PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
XDEBUG_MODE: coverage
run: php artisan test --coverage