-
-
Notifications
You must be signed in to change notification settings - Fork 692
108 lines (93 loc) · 3.73 KB
/
Copy pathtests.yml
File metadata and controls
108 lines (93 loc) · 3.73 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
101
102
103
104
105
106
107
108
name: Backend Tests
on:
push:
branches: [main, develop, 'v[0-9]+.[0-9]+.[0-9]+-*']
paths:
- 'backend/**'
- '.github/workflows/tests.yml'
pull_request:
paths:
- 'backend/**'
- '.github/workflows/tests.yml'
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.3', '8.4', '8.5']
services:
# Postgres is started for the Feature suite. The Unit suite does not need
# a live connection — it only reads DB_DATABASE for the _test guard check
# in CreatesApplication — so it runs in parallel with Postgres warming up.
postgres:
image: postgres:15
env:
POSTGRES_DB: hievents_test
POSTGRES_USER: hievents
POSTGRES_PASSWORD: hievents
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U hievents -d hievents_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Job-level env. .env.testing supplies the rest, but the DB host on a CI
# runner is 127.0.0.1 (service container exposes its port on the runner),
# not the docker network alias used locally — override here.
env:
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_DATABASE: hievents_test
DB_USERNAME: hievents
DB_PASSWORD: hievents
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, pdo_pgsql, pgsql, tokenizer, gd
ini-values: post_max_size=256M, upload_max_filesize=256M
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Create Laravel bootstrap cache directory
run: mkdir -p ./backend/bootstrap/cache && chmod -R 777 ./backend/bootstrap/cache
- name: Install dependencies
run: cd backend && composer install --prefer-dist --no-progress --no-interaction
- name: Stage .env for testing
# Laravel auto-loads .env.testing when APP_ENV=testing, but artisan
# commands run outside that flow read .env directly. Copy .env.testing
# to .env so both paths see the same config.
run: cp backend/.env.testing backend/.env
- name: Run Unit test suite
# Pure unit tests — no DB connection, no migrations. The CreatesApplication
# bootstrap detects the absence of DatabaseTransactions / RefreshDatabase
# traits and skips migrate:fresh entirely. Runs in parallel with the
# Postgres service container coming up.
run: cd backend && ./vendor/bin/phpunit --testsuite=Unit --no-coverage
- name: Wait for Postgres
run: |
for i in {1..30}; do
if pg_isready -h 127.0.0.1 -p 5432 -U hievents -d hievents_test; then
exit 0
fi
sleep 1
done
echo "Postgres did not become ready in time" >&2
exit 1
- name: Run Feature test suite
# Integration tests against the real PostgreSQL test database. The first
# test that boots Laravel triggers migrate:fresh once per process via
# CreatesApplication::ensureTestDatabaseIsMigrated.
run: cd backend && ./vendor/bin/phpunit --testsuite=Feature --no-coverage