Skip to content

Commit 3e438e7

Browse files
committed
chore: simplify CI workflow by removing formatting steps and consolidating jobs
1 parent 2786dc3 commit 3e438e7

File tree

1 file changed

+31
-143
lines changed

1 file changed

+31
-143
lines changed

.github/workflows/tests.yml

Lines changed: 31 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,63 @@
1-
name: Test and Format Code
1+
name: tests
22

33
on:
44
push:
55
branches:
6-
- dev
76
- main
87
pull_request:
9-
types: [opened, synchronize, reopened, ready_for_review]
8+
branches:
9+
- main
1010

1111
jobs:
12-
format-code:
13-
if: github.event.pull_request.draft == false
12+
ci:
1413
runs-on: ubuntu-latest
1514

1615
steps:
17-
- name: Checkout code
16+
- name: Checkout
1817
uses: actions/checkout@v4
19-
with:
20-
ref: ${{ github.head_ref }}
21-
22-
- name: Get changed PHP files
23-
id: changed-php-files
24-
uses: tj-actions/changed-files@v45
25-
with:
26-
files: |
27-
**/*.php
2818

2919
- name: Setup PHP
30-
if: steps.changed-php-files.outputs.any_changed == 'true'
3120
uses: shivammathur/setup-php@v2
3221
with:
3322
php-version: 8.4
34-
extensions: json, dom, curl, libxml, mbstring
35-
coverage: none
36-
37-
- name: Install Pint
38-
if: steps.changed-php-files.outputs.any_changed == 'true'
39-
run: composer global require laravel/pint
40-
41-
- name: Run Pint
42-
if: steps.changed-php-files.outputs.any_changed == 'true'
43-
run: |
44-
pint ${{ steps.changed-php-files.outputs.all_changed_files }}
45-
46-
- name: Get changed frontend files for formatting
47-
id: changed-frontend-files
48-
uses: tj-actions/changed-files@v45
49-
with:
50-
files: |
51-
resources/**/*.{js,vue}
23+
tools: composer:v2
24+
coverage: xdebug
5225

5326
- name: Setup Node
54-
if: steps.changed-frontend-files.outputs.any_changed == 'true'
5527
uses: actions/setup-node@v4
5628
with:
57-
node-version: 22
29+
node-version: '22'
5830

5931
- name: Install Dependencies
60-
if: steps.changed-frontend-files.outputs.any_changed == 'true'
61-
run: npm i
62-
63-
- name: Run Prettier
64-
if: steps.changed-frontend-files.outputs.any_changed == 'true'
65-
run: |
66-
npx prettier --write ${{ steps.changed-frontend-files.outputs.all_changed_files }} "tests/e2e/**/*.{js,ts}"
32+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
6733

68-
- name: Run ESLint
69-
if: steps.changed-frontend-files.outputs.any_changed == 'true'
70-
run: |
71-
npx eslint ${{ steps.changed-frontend-files.outputs.all_changed_files }} --fix
72-
73-
- name: Commit linted files
74-
if: steps.changed-php-files.outputs.any_changed == 'true'
75-
uses: stefanzweifel/git-auto-commit-action@v5
76-
with:
77-
commit_message: '[Bot] Format and apply lint fixes'
78-
79-
laravel-tests:
80-
if: github.event.pull_request.draft == false
81-
needs: format-code
82-
runs-on: ubuntu-latest
83-
84-
services:
85-
mysql:
86-
image: mysql:8
87-
env:
88-
MYSQL_ROOT_PASSWORD: root
89-
MYSQL_DATABASE: devsbuddy
90-
ports:
91-
- 3306:3306
92-
options: >-
93-
--health-cmd="mysqladmin ping --silent"
94-
--health-interval=10s
95-
--health-timeout=5s
96-
--health-retries=5
97-
98-
typesense:
99-
image: typesense/typesense:28.0
100-
101-
steps:
102-
- name: Checkout code
103-
uses: actions/checkout@v4
104-
with:
105-
ref: ${{ github.head_ref }}
106-
107-
- name: Start Typesense
108-
run: |
109-
docker run -d \
110-
-p 8108:8108 \
111-
--name typesense \
112-
-v /tmp/typesense:/data \
113-
typesense/typesense:28.0 \
114-
--api-key=xyz \
115-
--data-dir /data \
116-
--enable-cors
117-
118-
- name: Curl Typesense
119-
run: sleep 1 && curl http://localhost:8108/health
120-
121-
- uses: shivammathur/setup-php@v2
122-
with:
123-
php-version: '8.4'
124-
extensions: mbstring, pdo, pdo_mysql, bcmath, exif, gd
125-
coverage: none
126-
127-
- name: Copy .env
34+
- name: Copy Environment File
12835
run: cp .env.example .env
12936

130-
- name: Configure Laravel for MySQL and Typesense
131-
run: |
132-
sed -i "s|DB_HOST=.*|DB_HOST=127.0.0.1|" .env
133-
sed -i "s|DB_PORT=.*|DB_PORT=3306|" .env
134-
sed -i "s|DB_USERNAME=.*|DB_USERNAME=root|" .env
135-
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=root|" .env
136-
137-
# Leave default DB_CONNECTION=mysql and port 3306
138-
139-
# Configure queue
140-
sed -i "s|QUEUE_CONNECTION=database|QUEUE_CONNECTION=sync|" .env
141-
142-
# Configure Typesense
143-
echo "TYPESENSE_PROTOCOL=http" >> .env
144-
sed -i "s|TYPESENSE_API_KEY=LARAVEL-HERD|TYPESENSE_API_KEY=xyz|" .env
37+
- name: Generate Application Key
38+
run: php artisan key:generate
14539

146-
- name: Display .env
147-
run: cat .env
40+
- name: Install Node Dependencies
41+
run: npm install
14842

149-
- name: Install Dependencies
150-
run: composer install -q -o --no-ansi --no-interaction --no-progress --prefer-dist
151-
152-
- name: Generate Ziggy Routes
153-
run: php artisan ziggy:generate
43+
- name: Build Assets
44+
run: npm run build
15445

155-
- name: Setup Node
156-
uses: actions/setup-node@v4
46+
- name: Rector Cache
47+
uses: actions/cache@v4
15748
with:
158-
node-version: 22
49+
path: /tmp/rector
50+
key: ${{ runner.os }}-rector-${{ hashFiles('composer.lock') }}
51+
restore-keys: ${{ runner.os }}-rector-
52+
- run: mkdir -p /tmp/rector
15953

160-
- name: Install Dependencies
161-
run: npm ci && npm run build
162-
163-
- name: Directory Permissions
164-
run: chmod -R 777 storage bootstrap/cache
165-
166-
- name: Disable AppArmor
167-
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
168-
169-
- name: Prep environment
170-
run: |
171-
php artisan key:generate
172-
php artisan migrate --force
54+
- name: PHPStan Cache
55+
uses: actions/cache@v4
56+
with:
57+
path: /tmp/phpstan
58+
key: ${{ runner.os }}-phpstan-${{ hashFiles('composer.lock') }}
59+
restore-keys: ${{ runner.os }}-phpstan-
60+
- run: mkdir -p /tmp/phpstan
17361

174-
- name: Run Tests
175-
run: php artisan test
62+
- name: Tests
63+
run: composer test

0 commit comments

Comments
 (0)