Skip to content

Commit

Permalink
Run GitHub Actions in separate service without the volume
Browse files Browse the repository at this point in the history
  • Loading branch information
coenjacobs committed Sep 8, 2024
1 parent 1c1d818 commit 22f6285
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
45 changes: 3 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 22f6285

Please sign in to comment.