|
| 1 | +# Do not edit this file! Make a pull request on changing |
| 2 | +# github/workflows/composer.yaml in |
| 3 | +# https://github.com/itk-dev/devops_itkdev-docker if need be. |
| 4 | + |
| 5 | +### ### Composer |
| 6 | +### |
| 7 | +### Validates composer.json and checks that it's normalized. |
| 8 | +### |
| 9 | +### #### Assumptions |
| 10 | +### |
| 11 | +### 1. A docker compose service named `phpfpm` can be run and `composer` can be |
| 12 | +### run inside the `phpfpm` service. |
| 13 | +### 2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) |
| 14 | +### is a dev requirement in `composer.json`: |
| 15 | +### |
| 16 | +### ``` shell |
| 17 | +### docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize |
| 18 | +### ``` |
| 19 | +### |
| 20 | +### Normalize `composer.json` by running |
| 21 | +### |
| 22 | +### ``` shell |
| 23 | +### docker compose run --rm phpfpm composer normalize |
| 24 | +### ``` |
| 25 | + |
| 26 | +name: Composer |
| 27 | + |
| 28 | +env: |
| 29 | + COMPOSE_USER: runner |
| 30 | + |
| 31 | +on: |
| 32 | + pull_request: |
| 33 | + push: |
| 34 | + branches: |
| 35 | + - main |
| 36 | + - develop |
| 37 | + |
| 38 | +jobs: |
| 39 | + composer-validate: |
| 40 | + name: Validate composer (${{ matrix.prefer }}) |
| 41 | + runs-on: ubuntu-latest |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + prefer: [prefer-lowest, prefer-stable] |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v5 |
| 48 | + |
| 49 | + - name: Create docker network |
| 50 | + run: | |
| 51 | + docker network create frontend |
| 52 | +
|
| 53 | + - run: | |
| 54 | + docker compose run --rm phpfpm composer validate --strict |
| 55 | +
|
| 56 | + composer-normalized: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + strategy: |
| 59 | + fail-fast: false |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v5 |
| 62 | + |
| 63 | + - name: Create docker network |
| 64 | + run: | |
| 65 | + docker network create frontend |
| 66 | +
|
| 67 | + - run: | |
| 68 | + docker compose run --rm phpfpm composer install |
| 69 | + docker compose run --rm phpfpm composer normalize --dry-run |
| 70 | +
|
| 71 | + composer-audit: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + strategy: |
| 74 | + fail-fast: false |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v5 |
| 77 | + |
| 78 | + - name: Create docker network |
| 79 | + run: | |
| 80 | + docker network create frontend |
| 81 | +
|
| 82 | + - run: | |
| 83 | + docker compose run --rm phpfpm composer audit |
0 commit comments