From 22f62852591e60d7122b4898c56beaa13a9fde7d Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Sun, 8 Sep 2024 16:08:39 +0200 Subject: [PATCH] Run GitHub Actions in separate service without the volume --- .github/workflows/main.yml | 45 +++----------------------------------- docker-compose.yml | 11 ++++++++++ 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0bb02a95..6ad948c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,63 +9,24 @@ on: - master jobs: - install_dependencies: - runs-on: ubuntu-latest - name: Install dependencies - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: docker compose run --rm builder composer install - - name: Cache installed dependencies - id: cache-composer-dependencies - uses: actions/cache/save@v4 - with: - path: | - ./vendor/ - ./composer.lock - key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} linting: - needs: install_dependencies runs-on: ubuntu-latest name: Linting steps: - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - name: Restore cached dependencies - with: - path: | - ./vendor/ - ./composer.lock - key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} - name: Run linting - run: docker compose run --rm builder composer test:lint + run: docker compose run --rm actions-tester composer test:lint testing: - needs: install_dependencies runs-on: ubuntu-latest name: Testing steps: - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - name: Restore cached dependencies - with: - path: | - ./vendor/ - ./composer.lock - key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} - name: Run testing - run: docker compose run --rm builder composer test:phpunit + run: docker compose run --rm actions-tester composer test:phpunit analysis: - needs: install_dependencies runs-on: ubuntu-latest name: Analysis steps: - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - name: Restore cached dependencies - with: - path: | - ./vendor/ - ./composer.lock - key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} - name: Run analysis - run: docker compose run --rm builder composer test:phpstan + run: docker compose run --rm actions-tester composer test:phpstan diff --git a/docker-compose.yml b/docker-compose.yml index 1def9525..8835bc8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,14 @@ services: volumes: - .:/mozart/ command: /bin/sh -c "while sleep 1000; do :; done" + actions-tester: + # This service is technically the same as the builder service, only this one + # has no volume mounted to the working directory. This causes the files to + # be used (for example installed dependencies) that are created _inside_ the + # container to be used, rather than having to set them up in the working + # directory, during GitHub Actions for example. + build: + context: . + dockerfile: Dockerfile + target: builder + command: /bin/sh -c "while sleep 1000; do :; done"