-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: MadCat34 <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,66 @@ on: | |
types: [opened, reopened] | ||
|
||
jobs: | ||
build: | ||
lint: | ||
name: Lint Dockerfile | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and run docker compose file | ||
- name: Lint Dockerfile | ||
uses: hadolint/[email protected] | ||
with: | ||
recursive: true | ||
|
||
build_and_test: | ||
name: Build and Test Docker Images | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
target: | ||
- { name: dev, port: 8080 } | ||
- { name: prod, port: 8081 } | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build image for ${{ matrix.target.name }} | ||
run: docker buildx build --target ${{ matrix.target.name }} -t laminas:${{ matrix.target.name }} . | ||
|
||
- name: PHPUnit for dev only | ||
if: matrix.target.name == 'dev' | ||
run: docker run --rm laminas:${{ matrix.target.name }} vendor/bin/phpunit module/*/test | ||
|
||
- name: Start container for ${{ matrix.target.name }} | ||
run: docker run --rm -d -p ${{ matrix.target.port }}:80 --name laminas-test-${{ matrix.target.name }} laminas:${{ matrix.target.name }} | ||
|
||
- name: Check HTTP status | ||
run: | | ||
retries=15 | ||
while [ $retries -gt 0 ]; do | ||
http_status_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${{ matrix.target.port }}) | ||
response_body=$(curl -s http://localhost:${{ matrix.target.port }}) | ||
if [ "$http_status_code" -eq 200 ] && [[ "$response_body" =~ "Welcome" ]]; then | ||
echo "HTTP status code: $http_status_code" | ||
echo "Response body: $response_body" | ||
break | ||
fi | ||
echo "Waiting for service to be ready..." | ||
sleep 10 | ||
retries=$((retries-1)) | ||
done | ||
if [ $retries -eq 0 ]; then | ||
echo "Service did not start successfully." | ||
echo "HTTP status code: $http_status_code" | ||
echo "Response body: $response_body" | ||
exit 1 | ||
fi | ||
- name: Stop and remove container for ${{ matrix.target.name }} | ||
run: | | ||
docker compose up -d --build | ||
docker compose run laminas echo "ok" | ||
docker ps | ||
docker stop laminas-test-${{ matrix.target.name }} |