feat(ci): add GitHub Actions workflow for testing and Docker builds #20
+13
-33
@@ -8,6 +8,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.arthurerlich.de
|
REGISTRY: git.arthurerlich.de
|
||||||
|
DEV_IMAGE: git.arthurerlich.de/${{ gitea.repository }}:ci-${{ gitea.sha }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-dev:
|
build-dev:
|
||||||
@@ -26,24 +27,17 @@ jobs:
|
|||||||
username: ${{ gitea.actor }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Build dev image (PHP 8.4 + composer deps)
|
- name: Build and push dev image (PHP 8.4 + composer deps)
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.dev
|
file: Dockerfile.dev
|
||||||
target: dev
|
target: dev
|
||||||
outputs: type=docker,dest=/tmp/graph-dev.tar
|
push: true
|
||||||
tags: graph-dev:ci
|
tags: ${{ env.DEV_IMAGE }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max
|
||||||
|
|
||||||
- name: Upload dev image
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: graph-dev-image
|
|
||||||
path: /tmp/graph-dev.tar
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
build-prod:
|
build-prod:
|
||||||
needs: build-dev
|
needs: build-dev
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -65,31 +59,17 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
needs: build-dev
|
needs: build-dev
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.DEV_IMAGE }}
|
||||||
|
credentials:
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download dev image
|
- name: Run tests
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: graph-dev-image
|
|
||||||
path: /tmp
|
|
||||||
|
|
||||||
- name: Load dev image
|
|
||||||
run: docker load --input /tmp/graph-dev.tar
|
|
||||||
|
|
||||||
- name: Debug workspace
|
|
||||||
run: |
|
run: |
|
||||||
echo "pwd: $(pwd)"
|
composer install --no-interaction
|
||||||
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
|
vendor/bin/phpunit --testdox
|
||||||
ls -la
|
composer phpstan
|
||||||
|
|
||||||
- name: Run tests in dev image
|
|
||||||
run: |
|
|
||||||
docker run --rm -v "$(pwd)":/app -v /app/vendor graph-dev:ci sh -c "
|
|
||||||
echo '--- /app contents ---' &&
|
|
||||||
ls -la /app &&
|
|
||||||
composer install --no-interaction &&
|
|
||||||
vendor/bin/phpunit --testdox &&
|
|
||||||
composer phpstan
|
|
||||||
"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user