Skip to content

Commit

Permalink
feat: use devcontainer and ci from portals
Browse files Browse the repository at this point in the history
  • Loading branch information
simonostendorf committed Oct 6, 2024
1 parent 24cb9f2 commit 69b7ccb
Show file tree
Hide file tree
Showing 12 changed files with 691 additions and 162 deletions.
37 changes: 18 additions & 19 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// https://aka.ms/devcontainer.json
{
"name": "Laravel Sail",
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "laravel.test",
"workspaceFolder": "/var/www/html",
"customizations": {
"vscode": {
"extensions": [
"name": "Laravel Sail",
"dockerComposeFile": ["../docker-compose.sail.yaml"],
"service": "laravel.test",
"workspaceFolder": "/var/www/html",
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client",
"bradlc.vscode-tailwindcss",
"christian-kohler.path-intellisense",
Expand All @@ -22,14 +20,15 @@
"neilbrayfield.php-docblocker",
"steoates.autoimport",
"Vue.volar",
"xdebug.php-debug"
],
"settings": {}
}
},
"remoteUser": "sail",
"postCreateCommand": "chown -R 1000:1000 /var/www/html"
// "forwardPorts": [],
// "runServices": [],
// "shutdownAction": "none",
"xdebug.php-debug",
"github.copilot"
],
"settings": {}
}
},
"remoteUser": "sail",
"postCreateCommand": "chown -R 1000:1000 /var/www/html"
// "forwardPorts": [],
// "runServices": [],
// "shutdownAction": "none",
}
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
OCTANE_HTTPS=false
OCTANE_WORKERS=4
OCTANE_MAX_REQUESTS=512
OCTANE_SERVER=frankenphp
22 changes: 17 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
php-version: ["8.2"]
php-version: ["8.3"]
node-version: [20.x]

steps:
Expand All @@ -23,7 +23,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.4.1
uses: actions/setup-node@v4.0.3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand All @@ -33,7 +33,13 @@ jobs:
run: composer update --ignore-platform-req=php+ --no-interaction --no-progress
- name: Install Node.js Dependencies
run: |
npm ci --force --legacy-peer-deps
npm ci
- name: Execute Node.js linting
run: |
npm run lint
- name: Execute PHP linting
run: |
./vendor/bin/pint
- name: Execute build
run: npm run build --if-present
- name: Generate key
Expand All @@ -50,8 +56,14 @@ jobs:
DB_DATABASE: database/database.sqlite
run: |
php artisan migrate
- name: Execute tests (Unit and Feature tests) via PHPUnit
- name: Execute seeders
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit
run: |
php artisan db:seed
# - name: Execute tests (Unit and Feature tests) via PHPUnit
# env:
# DB_CONNECTION: sqlite
# DB_DATABASE: database/database.sqlite
# run: vendor/bin/phpunit
27 changes: 0 additions & 27 deletions .github/workflows/docker-dev.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/docker-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Docker e2e Test

on:
pull_request: {}

env:
IMAGE_REGISTRY: ghcr.io
IMAGE_PATH: ${{ github.repository }}
IMAGE_TAG: ${{ github.ref_name }}

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Image
uses: docker/build-push-action@v6
with:
push: false
load: true
tags: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:latest
- name: Create Environment
run: |
cat > .env << EOF
APP_NAME="Erstiwoche FB5"
APP_ENV=local
APP_KEY=1234567890ABCDEFGHIJ1234567890AB
APP_DEBUG=true
APP_URL=http://localhost
APP_FORCE_HTTPS=false
APP_EVENT_TYPE=demo
TUTOR_PASSWORD=password
ADMIN_PASSWORD=admin
LOG_CHANNEL=stack
LOG_LEVEL=debug
BROADCAST_CONNECTION=log
CACHE_STORE=file # TODO
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file # TODO
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
OCTANE_HTTPS=false
OCTANE_WORKERS=1
OCTANE_MAX_REQUESTS=512
WWWGROUP=1000
WWWUSER=1000
OCTANE_SERVER=roadrunner
EOF
- name: Run Image
uses: isbang/[email protected]
with:
compose-file: "docker-compose.yaml"
down-flags: "--volumes"
- name: Wait
run: |
# wait 10 seconds for the docker container to start
sleep 10
- name: Run DB Seed
run: |
# run "php artisan migrate:fresh --seed" inside docker container
docker exec portals-web php artisan migrate:fresh --seed
- name: Debug
run: |
curl http://localhost:8000
- name: Test reachable
run: |
# test every 10 seconds if http://localhost:8000 is reachable and has a OK status code. Timeout after 2 minutes
timeout 120 bash -c 'until curl --output /dev/null --silent --head --fail http://localhost:8000; do printf "."; sleep 10; done'
49 changes: 36 additions & 13 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
name: Docker CI (release)
name: Docker Release

on:
release:
types: [published]
types:
- published
push:
branches:
- dev

env:
REGISTRY: ghcr.io
IMAGE_REGISTRY: ghcr.io
IMAGE_PATH: ${{ github.repository }}
IMAGE_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
- name: Get latest release
id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
registry: ${{ env.REGISTRY }}
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker
run: |
docker build -f ./Dockerfile . --tag ${{ env.REGISTRY }}/fsr5-fhaachen/strichlistensystem:${{ env.RELEASE_VERSION }} --tag ${{ env.REGISTRY }}/fsr5-fhaachen/strichlistensystem:latest
docker push ${{ env.REGISTRY }}/fsr5-fhaachen/strichlistensystem:${{ env.RELEASE_VERSION }}
docker push ${{ env.REGISTRY }}/fsr5-fhaachen/strichlistensystem:latest
- name: Build and push (latest release)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release == github.ref_name }} # run only on latest release
with:
push: true
tags: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}, ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:latest
- name: Build and push (release)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release != github.ref_name }} # run only on release (not latest)
with:
push: true
tags: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
- name: Build and push (push)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'push' }} # run only on push (to dev)
with:
push: true
tags: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
Loading

0 comments on commit 69b7ccb

Please sign in to comment.