From a8f5680e6ee0edb3afc6bbc006b155145db02453 Mon Sep 17 00:00:00 2001 From: Haylan Date: Fri, 31 Jul 2026 14:17:39 +0200 Subject: [PATCH] fix(ci): update dev image build process and run tests in the same job --- .gitea/workflows/test.yml | 46 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 50b596c..5631d53 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -26,17 +26,30 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - - name: Build and push dev image (PHP 8.4 + composer deps) + - name: Build dev image (PHP 8.4 + composer deps) uses: docker/build-push-action@v5 with: context: . file: Dockerfile.dev target: dev - push: true - tags: ${{ env.REGISTRY }}/${{ gitea.repository }}:ci-${{ gitea.sha }} + load: true + tags: graph-dev:ci cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max + - name: Run tests in dev image + run: | + cid=$(docker create graph-dev:ci sh -c " + composer install --no-interaction && + vendor/bin/phpunit --testdox && + composer phpstan + ") + docker cp . "$cid":/app + rc=0 + docker start -a "$cid" || rc=$? + docker rm "$cid" > /dev/null + exit $rc + build-prod: needs: build-dev runs-on: ubuntu-latest @@ -47,6 +60,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Log in to Gitea registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build prod image (final target) uses: docker/build-push-action@v5 with: @@ -54,21 +74,5 @@ jobs: file: Dockerfile target: final push: false - - test: - needs: build-dev - runs-on: ubuntu-latest - container: - image: ${{ env.REGISTRY }}/${{ gitea.repository }}:ci-${{ gitea.sha }} - credentials: - username: ${{ gitea.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Run tests - run: | - composer install --no-interaction - vendor/bin/phpunit --testdox - composer phpstan + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod,mode=max