Skip to content

Commit 92c36b1

Browse files
committed
Configures CI for Bref and Vapor testing
Sets up a GitHub Actions workflow to run tests on Bref and Vapor platforms. This commit introduces a new GitHub Action that builds Docker images for Bref and Vapor based on the provided PHP and Laravel versions, and then executes tests within those containers. This ensures that the package functions correctly on both platforms. Also, includes docker-compose and related files to set up local testing environments.
1 parent 9c030f5 commit 92c36b1

File tree

9 files changed

+125
-170
lines changed

9 files changed

+125
-170
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
vendor/
2-
test-app/vendor/
32
package/
3+
build/
4+
.phpunit.cache/
5+
.git/

.github/actions/test-action/action.yaml

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ inputs:
1515
runs:
1616
using: 'composite'
1717
steps:
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ inputs.php-version }}
22+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
23+
coverage: none
24+
1825
- name: Set environment variables
1926
shell: bash
2027
run: |
21-
php_version="${{ inputs.php-version }}"
28+
PHP_VERSION_TAG="${{ inputs.php-version }}"
2229
laravel_version="${{ inputs.laravel-version }}"
2330
platform="${{ inputs.platform }}"
2431
25-
php_tag="${php_version//./}"
32+
php_tag="${PHP_VERSION_TAG//./}"
2633
laravel_tag="${laravel_version//[.*]/}"
2734
2835
# Convert to numbers and calculate port: 9090 + php_tag + laravel_tag
@@ -36,95 +43,30 @@ runs:
3643
port=$base_port
3744
fi
3845
39-
echo "PHP_VERSION=$php_version" >> $GITHUB_ENV
46+
echo "PHP_VERSION_TAG=$PHP_VERSION_TAG" >> $GITHUB_ENV
4047
echo "LARAVEL_VERSION=$laravel_version" >> $GITHUB_ENV
41-
echo "PHP_TAG=$php_tag" >> $GITHUB_ENV
48+
echo "PHP_VERSION=$php_tag" >> $GITHUB_ENV
4249
echo "LARAVEL_TAG=$laravel_tag" >> $GITHUB_ENV
4350
echo "SLS_TINKER_LAMBDA_ENDPOINT=http://localhost:$port" >> $GITHUB_ENV
4451
echo "PORT=$port" >> $GITHUB_ENV
4552
echo "PLATFORM=$platform" >> $GITHUB_ENV
53+
echo "DOCKER_IMAGE=${{ inputs.platform }}-$php_tag-$laravel_tag" >> $GITHUB_ENV
4654
47-
- name: Setup PHP
48-
uses: shivammathur/setup-php@v2
49-
with:
50-
php-version: ${{ inputs.php-version }}
51-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
52-
coverage: none
53-
54-
- name: Install dependencies & Laravel App
55+
- name: Create App
5556
shell: bash
5657
run: |
57-
composer create-project "laravel/laravel:${{ inputs.laravel-version }}" --no-interaction app
58-
cd app
59-
php artisan key:generate
60-
61-
- name: Install Bref
62-
if: inputs.platform == 'bref'
63-
shell: bash
64-
run: |
65-
cd app
66-
composer require bref/bref:^2 --no-interaction
67-
68-
- name: Install Vapor Core
69-
if: inputs.platform == 'vapor'
70-
shell: bash
71-
run: |
72-
cd app
73-
composer require laravel/vapor-core --no-interaction
74-
composer global require laravel/vapor-cli
75-
mkdir -p ~/.laravel-vapor
76-
cat <<EOF > ~/.laravel-vapor/config.json
77-
{
78-
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiMDdjMmVlODhmYzkyNjQyNjg1YWI5N2FhMjIzNGU2MjYwZWMyM2RjYWQzYjJmOWM0YjVlY2JjY2YwZTU3MzJhNDI3NDRiZDI1NWIwYjg0NDEiLCJpYXQiOjE3NTUzNjQzOTIuMTE3NzExLCJuYmYiOjE3NTUzNjQzOTIuMTE3NzE0LCJleHAiOjE5MTMxMzA3OTIuMTA3ODU3LCJzdWIiOiI2ODk5OSIsInNjb3BlcyI6WyIqIl19.Ma0-GJjBvqs2irvHbW5oOrEJn0I-FCjSXV-zK20LIzwbgSfZNTMvViheazfO1roOow1UyANmzoPGnTyo2EndFM6G0p-UDiB03ce-36Bgj7JKOJ_156omPXsqrPhN7P9nDER1zmas9gM4UHwlHW2k67U9v050FjVT_TBeFvVe6gtWPKLZdTLTT5xmaqZvnAWbNUO_wq4exnmPnzFYVXpDYuuD2fgtzPXAzXauvm1BGR4YBMGvzSx1JCyc-OBnEwdsQIMAomU6lHrybQJzYefHugNx6oHIe2BQtMblsWQOPPSRqD5ciGTnzWdQ1PxBYd7FS3jWRoqv4FWJuTJo7krIPYiBfQtsUXaCnzOyx8pLpFiOCQE5HeldtdmT4KH5VXkYWsZKoA3_gdnTwyeoBaP8TvKt0mE6a6mQhMzasUkPk8-lASsRBHti5dqEu8FEQWWdEGm4--fzH7bN7i2vMsR9nUCXrJx0lLL7e3VL9j6igAKqQssK8gkxhd4q38g1L2esbdkNa6nbv8fGfPaWcOlbEyKog19pRIblCDj3wdtXNJjts1FNmxNSeYuxjKh5Wselx_PRkhLEbFoAIMmWbBEGdVC0p_gByt7yL3-wOFD69PA2SoctyoSKnae9E7w6V_OeDKrcXimbZugW6O0oCLbzhFslcZ0rMbaN0W3r-CRYUDA",
79-
"team": 83505
80-
}
81-
EOF
82-
83-
- name: Install package from local path
84-
shell: bash
85-
working-directory: app
86-
run: |
87-
# Add local package to composer.json
88-
composer config repositories.local path ../package
89-
composer require datpmwork/sls-tinker:@dev
90-
rm -rf vendor/datpmwork/sls-tinker
91-
cp -r ../package vendor/datpmwork/sls-tinker
92-
93-
- name: Vapor Build
94-
shell: bash
95-
working-directory: app
96-
if: inputs.platform == 'vapor'
97-
run: |
98-
cat <<EOF > vapor.yml
99-
id: 72679
100-
name: vapor
101-
environments:
102-
production:
103-
memory: 1024
104-
cli-memory: 512
105-
runtime: 'php-8.4:al2'
106-
build:
107-
- 'rm -rf bootstrap/cache/*'
108-
- 'composer install --no-dev'
109-
- 'php artisan event:cache'
110-
# - 'npm ci && npm run build && rm -rf node_modules'
111-
EOF
112-
~/.composer/vendor/bin/vapor build production || exit 0
58+
docker build --build-arg PHP_VERSION_TAG=$PHP_VERSION_TAG \
59+
--build-arg PHP_VERSION=$PHP_VERSION \
60+
--build-arg PHP_LARAVEL_TAG=$LARAVEL_VERSION \
61+
-t $DOCKER_IMAGE -f Dockerfile --target ${{ inputs.platform }} .
11362
11463
- name: Create Docker Instance
11564
shell: bash
11665
run: |
117-
if [[ "${{ inputs.platform }}" == "bref" ]]; then
118-
docker build -t ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG -f package/tests/Dockerfile --build-arg PHP_VERSION=$PHP_TAG --target ${{ inputs.platform }} .
119-
docker run -d --rm -p $PORT:8080 --name ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG artisan
120-
elif [[ "${{ inputs.platform }}" == "vapor" ]]; then
121-
docker build -t ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG -f package/tests/Dockerfile --build-arg PHP_VERSION=$PHP_TAG --target ${{ inputs.platform }} .
122-
docker run -d --rm -p $PORT:8080 -e VAPOR_SSM_PATH=test -e LAMBDA_TASK_ROOT=/var/task -e APP_RUNNING_IN_CONSOLE=true --name ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG artisan
123-
fi
66+
docker run -d --rm -p $PORT:8080 --name $DOCKER_IMAGE $DOCKER_IMAGE artisan
12467
12568
- name: Execute tests
12669
shell: bash
127-
working-directory: package
12870
run: |
12971
composer install
13072
php vendor/bin/testbench package:sync-skeleton
@@ -134,4 +76,4 @@ runs:
13476
if: always()
13577
shell: bash
13678
run: |
137-
docker stop ${{ inputs.platform }}-$PHP_TAG-$LARAVEL_TAG
79+
docker stop ${{ inputs.platform }}-$PHP_VERSION-$LARAVEL_TAG

.github/workflows/run-tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [ 8.1, 8.2, 8.3, 8.4 ]
13-
laravel: [ 10.*, 11.*, 12.* ]
12+
php: [ 8.1 ]
13+
laravel: [ 10.* ]
1414
stability: [ prefer-stable ]
1515
exclude:
1616
# Laravel 11 requires PHP 8.2+
@@ -24,11 +24,9 @@ jobs:
2424
steps:
2525
- name: Checkout package code
2626
uses: actions/checkout@v4
27-
with:
28-
path: ./package
2927

3028
- name: Run tests
31-
uses: ./package/.github/actions/test-action
29+
uses: ./.github/actions/test-action
3230
with:
3331
php-version: ${{ matrix.php }}
3432
laravel-version: ${{ matrix.laravel }}
@@ -40,8 +38,8 @@ jobs:
4038
strategy:
4139
fail-fast: false
4240
matrix:
43-
php: [ 8.1, 8.2, 8.3, 8.4 ]
44-
laravel: [ 10.*, 11.*, 12.* ]
41+
php: [ 8.1 ]
42+
laravel: [ 10.* ]
4543
stability: [ prefer-stable ]
4644
exclude:
4745
# Laravel 11 requires PHP 8.2+
@@ -55,11 +53,9 @@ jobs:
5553
steps:
5654
- name: Checkout package code
5755
uses: actions/checkout@v4
58-
with:
59-
path: ./package
6056

6157
- name: Run tests
62-
uses: ./package/.github/actions/test-action
58+
uses: ./.github/actions/test-action
6359
with:
6460
php-version: ${{ matrix.php }}
6561
laravel-version: ${{ matrix.laravel }}

Dockerfile

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,53 @@
1-
FROM bref/php-82-console:2
1+
ARG PHP_VERSION=82
2+
ARG PHP_VERSION_TAG=8.2
3+
ARG LARAVEL_VERSION=10.0
4+
5+
FROM bref/php-${PHP_VERSION}-console:2 AS bref
26

37
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
4-
COPY --from=bref/extra-xdebug-php-82:1.8.2 /opt /opt
58

6-
COPY composer.json /var/package/
7-
COPY config/ /var/package/config/
8-
COPY src/ /var/package/src/
9+
COPY . /tmp/package
10+
ENV COMPOSER_MIRROR_PATH_REPOS=1
11+
RUN composer create-project "laravel/laravel:${LARAVEL_VERSION}" --no-interaction . && \
12+
composer config repositories.local path /tmp/package && \
13+
composer require datpmwork/sls-tinker:@dev && \
14+
composer require bref/bref:^2 --no-interaction
15+
16+
FROM laravelphp/vapor:php${PHP_VERSION} AS vapor
17+
18+
# Expose port 8080 for RIE
19+
EXPOSE 8080
20+
21+
WORKDIR /var/task
922

10-
COPY composer.json ./
23+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
24+
25+
# Download and install AWS Lambda Runtime Interface Emulator
26+
RUN curl -Lo /opt/aws-lambda-rie \
27+
https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/download/v1.27/aws-lambda-rie && \
28+
chmod +x /opt/aws-lambda-rie
1129

12-
RUN composer install --no-autoloader --no-scripts
30+
COPY docker/vapor/bootstrap /opt/bootstrap
31+
COPY docker/vapor/entrypoint.sh /opt/entrypoint.sh
1332

14-
COPY . /var/task
33+
COPY . /tmp/package
34+
ENV COMPOSER_MIRROR_PATH_REPOS=1
35+
RUN composer create-project "laravel/laravel:${LARAVEL_VERSION}" --no-interaction . && \
36+
composer config repositories.local path /tmp/package && \
37+
composer require datpmwork/sls-tinker:@dev && \
38+
composer require laravel/vapor-core --no-interaction && \
39+
cp vendor/laravel/vapor-core/stubs/cliRuntime.php cliRuntime.php && \
40+
cp vendor/laravel/vapor-core/stubs/runtime.php runtime.php
1541

1642
RUN composer dump-autoload
43+
44+
# Make entrypoint executable
45+
RUN chmod +x /opt/entrypoint.sh
46+
# Make bootstrap executable
47+
RUN chmod +x /opt/bootstrap
48+
# Set the CMD to use our entrypoint
49+
ENTRYPOINT ["/opt/entrypoint.sh"]
50+
51+
ENV LAMBDA_TASK_ROOT=/var/task
52+
ENV APP_RUNNING_IN_CONSOLE=true
53+
ENV VAPOR_SSM_PATH=test

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
up:
2+
@echo "Starting up the application..."
3+
@docker compose up -d
4+
5+
build-app:
6+
@echo "Building the application..."
7+
docker compose build

docker-compose.yaml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,46 @@ services:
44
networks:
55
- net
66

7-
test-app:
8-
image: sls-tinker-test-app
9-
container_name: sls-tinker-test-app
7+
bref-app:
8+
image: bref-app
9+
container_name: bref-app
1010
build:
1111
context: .
1212
dockerfile: Dockerfile
13+
target: bref
14+
args:
15+
PHP_VERSION_TAG: ${PHP_VERSION_TAG:-81}
16+
PHP_VERSION: ${PHP_VERSION:-8.1}
17+
PHP_LARAVEL_TAG: ${PHP_LARAVEL_TAG:-11.*}
1318
networks:
1419
- net
1520
ports:
1621
- 9090:8080
1722
volumes:
1823
- ./src:/var/task/vendor/datpmwork/sls-tinker/src
19-
- ./test-app/php:/var/task/php/
2024
command:
2125
- artisan
26+
27+
vapor-app:
28+
image: vapor-app
29+
container_name: vapor-app
30+
build:
31+
context: .
32+
dockerfile: Dockerfile
33+
target: vapor
34+
args:
35+
PHP_VERSION_TAG: ${PHP_VERSION_TAG:-81}
36+
PHP_VERSION: ${PHP_VERSION:-8.1}
37+
PHP_LARAVEL_TAG: ${PHP_LARAVEL_TAG:-11.*}
38+
networks:
39+
- net
40+
ports:
41+
- 9091:8080
42+
volumes:
43+
- ./src:/var/task/vendor/datpmwork/sls-tinker/src
44+
command:
45+
- artisan
46+
2247
networks:
2348
net:
2449
driver: "bridge"

docker/vapor/bootstrap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
while true
4+
do
5+
php /opt/bootstrap.php
6+
done

docker/vapor/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# Check if we're running locally with RIE
4+
if [ -z "$AWS_LAMBDA_RUNTIME_API" ]; then
5+
echo "Running locally with AWS Lambda RIE"
6+
exec /opt/aws-lambda-rie /opt/bootstrap
7+
else
8+
echo "Running in AWS Lambda environment"
9+
exec /opt/bootstrap
10+
fi

tests/Dockerfile

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)