Skip to content

Commit a394318

Browse files
Merge pull request #1441 from liberu-genealogy/copilot/replace-docker-setup-and-install-octane
Fix Docker build, CI test failures, and add workflow caching
2 parents 96821fc + 0f98315 commit a394318

File tree

14 files changed

+1387
-85
lines changed

14 files changed

+1387
-85
lines changed

.github/workflows/install.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,65 @@ jobs:
1111
install:
1212
runs-on: ubuntu-latest
1313

14+
services:
15+
mysql:
16+
image: mysql:8.0
17+
env:
18+
MYSQL_ROOT_PASSWORD: root
19+
MYSQL_DATABASE: liberu
20+
ports:
21+
- 3306:3306
22+
options: >-
23+
--health-cmd="mysqladmin ping"
24+
--health-interval=10s
25+
--health-timeout=5s
26+
--health-retries=3
27+
1428
steps:
15-
- uses: actions/checkout@v5
29+
- uses: actions/checkout@v4
1630

1731
- name: Setup PHP
1832
uses: shivammathur/setup-php@v2
1933
with:
20-
php-version: '8.5'
34+
php-version: '8.4'
35+
extensions: mbstring, bcmath, pdo_mysql, redis, intl, gd, zip
36+
tools: composer:v2
2137

2238
- name: Setup Node.js
23-
uses: actions/setup-node@v5
39+
uses: actions/setup-node@v4
2440
with:
2541
node-version: '24'
42+
cache: 'npm'
2643

44+
- name: Get Composer cache directory
45+
id: composer-cache
46+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2747

28-
- name: Start database
29-
run: sudo /etc/init.d/mysql start
30-
31-
- name: Create database
32-
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot
48+
- name: Cache Composer dependencies
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{ steps.composer-cache.outputs.dir }}
52+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
53+
restore-keys: ${{ runner.os }}-composer-
3354

3455
- name: Copy environment file
3556
run: cp .env.testing .env
3657

3758
- name: Install dependencies
38-
run: composer install
59+
run: composer install --prefer-dist --no-progress
3960

4061
- name: Generate application key
4162
run: php artisan key:generate
4263

4364
- name: Run database migrations
44-
run: php artisan migrate
65+
run: php artisan migrate --force
4566

4667
- name: Seed database
47-
run: php artisan db:seed
68+
run: php artisan db:seed --force
4869

4970
- name: Install npm dependencies
50-
run: npm install
71+
run: npm ci
5172

5273
- name: Build frontend assets
5374
run: npm run build
75+

.github/workflows/main.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
if: github.event_name == 'push'
1919
runs-on: ubuntu-latest
2020
steps:
21+
-
22+
name: Checkout
23+
uses: actions/checkout@v4
24+
2125
-
2226
name: Login to Docker Hub
2327
uses: docker/login-action@v3
@@ -28,7 +32,7 @@ jobs:
2832
-
2933
name: Extract metadata (tags, labels) for Docker
3034
id: meta
31-
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f
35+
uses: docker/metadata-action@v5
3236
with:
3337
images: liberu/genealogy
3438

@@ -38,11 +42,26 @@ jobs:
3842
name: Set up Docker Buildx
3943
uses: docker/setup-buildx-action@v3
4044

45+
- name: Cache Docker layers
46+
uses: actions/cache@v4
47+
with:
48+
path: /tmp/.buildx-cache
49+
key: ${{ runner.os }}-buildx-${{ github.sha }}
50+
restore-keys: |
51+
${{ runner.os }}-buildx-
52+
4153
- name: Build and push Docker image
42-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
54+
uses: docker/build-push-action@v6
4355
with:
44-
# context: "{{defaultContext}}:.docker/prod/app/"
56+
context: .
4557
file: Dockerfile
4658
push: true
4759
tags: ${{ steps.meta.outputs.tags }}
48-
labels: ${{ steps.meta.outputs.labels }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
cache-from: type=local,src=/tmp/.buildx-cache
62+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
63+
64+
- name: Move cache
65+
run: |
66+
rm -rf /tmp/.buildx-cache
67+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/security.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,67 @@ jobs:
1818
phpcpd:
1919
runs-on: ubuntu-24.04
2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v4
2222
- uses: shivammathur/setup-php@v2
2323
with:
24-
php-version: '8.5'
24+
php-version: '8.4'
25+
tools: composer:v2
26+
27+
- name: Get Composer cache directory
28+
id: composer-cache
29+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
30+
31+
- name: Cache Composer dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.composer-cache.outputs.dir }}
35+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
36+
restore-keys: ${{ runner.os }}-composer-
37+
2538
- name: 'Run Phpcpd'
2639
run: |
27-
sudo composer install
28-
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
29-
sudo php phpcpd.phar app/
40+
composer install --prefer-dist --no-progress
41+
test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
42+
php phpcpd.phar app/
3043
3144
php-insights:
3245
runs-on: ubuntu-24.04
3346
steps:
34-
- uses: actions/checkout@v5
47+
- uses: actions/checkout@v4
3548
- uses: shivammathur/setup-php@v2
3649
with:
37-
php-version: '8.5'
50+
php-version: '8.4'
51+
tools: composer:v2
52+
53+
- name: Get Composer cache directory
54+
id: composer-cache
55+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
56+
57+
- name: Cache Composer dependencies
58+
uses: actions/cache@v4
59+
with:
60+
path: ${{ steps.composer-cache.outputs.dir }}
61+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: ${{ runner.os }}-composer-
63+
3864
- name: 'Run php-insight'
3965
run: |
40-
sudo composer install
41-
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
66+
composer install --prefer-dist --no-progress
67+
php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
4268
4369
security:
4470
runs-on: ubuntu-24.04
4571
steps:
46-
- uses: actions/checkout@v5
72+
- uses: actions/checkout@v4
4773
- uses: shivammathur/setup-php@v2
4874
with:
49-
php-version: '8.5'
50-
- name: 'Run php-insight'
75+
php-version: '8.4'
76+
77+
- name: 'Run php security checker'
5178
run: |
5279
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
5380
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
5481
chmod +x ./php-security-checker
5582
unset PHP_SC_VERSION
5683
./php-security-checker
84+

.github/workflows/tests.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,56 @@ jobs:
1111
tests:
1212
runs-on: ubuntu-latest
1313

14+
services:
15+
mysql:
16+
image: mysql:8.0
17+
env:
18+
MYSQL_ROOT_PASSWORD: root
19+
MYSQL_DATABASE: liberu
20+
ports:
21+
- 3306:3306
22+
options: >-
23+
--health-cmd="mysqladmin ping"
24+
--health-interval=10s
25+
--health-timeout=5s
26+
--health-retries=3
27+
1428
steps:
15-
- uses: actions/checkout@v5
29+
- uses: actions/checkout@v4
1630

1731
- name: Setup PHP
1832
uses: shivammathur/setup-php@v2
1933
with:
20-
php-version: '8.5'
21-
34+
php-version: '8.4'
35+
extensions: mbstring, bcmath, pdo_mysql, redis, intl, gd, zip
36+
coverage: xdebug
37+
tools: composer:v2
2238

23-
- name: Start database
24-
run: sudo /etc/init.d/mysql start
39+
- name: Get Composer cache directory
40+
id: composer-cache
41+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2542

26-
- name: Create database
27-
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot
43+
- name: Cache Composer dependencies
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ steps.composer-cache.outputs.dir }}
47+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
48+
restore-keys: ${{ runner.os }}-composer-
2849

2950
- name: Copy environment file
3051
run: cp .env.testing .env
3152

3253
- name: Install dependencies
33-
run: composer install
54+
run: composer install --prefer-dist --no-progress
3455

3556
- name: Generate application key
3657
run: php artisan key:generate
3758

3859
- name: Run database migrations
39-
run: php artisan migrate
60+
run: php artisan migrate --force
4061

4162
- name: Seed database
42-
run: php artisan db:seed
63+
run: php artisan db:seed --force
4364

4465
- name: Run tests
4566
run: vendor/bin/phpunit --coverage-clover=coverage.xml
@@ -52,4 +73,3 @@ jobs:
5273
flags: unittests
5374
name: codecov-umbrella
5475
fail_ci_if_error: true
55-

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Accepted values: 8.5+
2-
ARG PHP_VERSION=8.5
1+
# Accepted values: 8.3+
2+
ARG PHP_VERSION=8.4
33

44
ARG COMPOSER_VERSION=latest
55

@@ -85,7 +85,7 @@ RUN apk update && \
8585
zip \
8686
intl \
8787
gd \
88-
redis@stable \
88+
redis \
8989
ldap \
9090
&& docker-php-source delete \
9191
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
context: .
55
dockerfile: Dockerfile
66
args:
7-
PHP_VERSION: 8.5
7+
PHP_VERSION: 8.4
88
WWWUSER: 1000
99
WWWGROUP: 1000
1010
image: genealogy-laravel
@@ -89,7 +89,7 @@ services:
8989
context: .
9090
dockerfile: Dockerfile
9191
args:
92-
PHP_VERSION: 8.5
92+
PHP_VERSION: 8.4
9393
WWWUSER: 1000
9494
WWWGROUP: 1000
9595
image: genealogy-laravel
@@ -122,7 +122,7 @@ services:
122122
context: .
123123
dockerfile: Dockerfile
124124
args:
125-
PHP_VERSION: 8.5
125+
PHP_VERSION: 8.4
126126
WWWUSER: 1000
127127
WWWGROUP: 1000
128128
image: genealogy-laravel

phpunit.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
2323
<env name="BCRYPT_ROUNDS" value="4"/>
2424
<env name="CACHE_STORE" value="array"/>
25-
<env name="DB_CONNECTION" value="sqlite"/>
26-
<env name="DB_DATABASE" value=":memory:"/>
25+
<env name="DB_CONNECTION" value="mysql"/>
26+
<env name="DB_HOST" value="127.0.0.1"/>
27+
<env name="DB_PORT" value="3306"/>
28+
<env name="DB_DATABASE" value="liberu"/>
29+
<env name="DB_USERNAME" value="root"/>
30+
<env name="DB_PASSWORD" value="root"/>
2731
<env name="MAIL_MAILER" value="array"/>
2832
<env name="PULSE_ENABLED" value="false"/>
2933
<env name="QUEUE_CONNECTION" value="sync"/>

0 commit comments

Comments
 (0)