|
| 1 | +name: Check migrations and seed |
| 2 | + |
| 3 | +# This job should run whenever a migration is updated |
| 4 | +# it should check whether the migration + seed still works as well as |
| 5 | +# check whether the pull request message mentions the migration |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - synchronize |
| 11 | + - reopened |
| 12 | + paths: |
| 13 | + - '**/migrations/*.php' |
| 14 | + - '**/test/Seeder/*.php' |
| 15 | + |
| 16 | +jobs: |
| 17 | + migration_seed: |
| 18 | + name: Check migrations and seed |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Echo |
| 23 | + run: echo "This job should only run in if migrations or fixtures are updated" |
| 24 | + |
| 25 | + - name: Checkout base branch |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + ref: ${{ github.event.pull_request.base.ref }} |
| 29 | + |
| 30 | + - name: Copy .env |
| 31 | + run: cp .env.dist .env |
| 32 | + |
| 33 | + - name: setup docker buildx |
| 34 | + uses: docker/setup-buildx-action@v2 |
| 35 | + |
| 36 | + - name: build base |
| 37 | + run: docker buildx bake --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml |
| 38 | + |
| 39 | + - name: run base |
| 40 | + run: docker compose --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml up -d --build --quiet-pull |
| 41 | + |
| 42 | + - name: migrate base |
| 43 | + run: make migrate |
| 44 | + |
| 45 | + - name: get migration status |
| 46 | + run: | |
| 47 | + MIGRATION_BASE_DEFAULT=$(docker compose exec -u www-data -it web ./orm migrations:current --no-interaction --object-manager doctrine.entitymanager.orm_default | sed 's/\s-.*//' | sed 's/\s//') |
| 48 | + echo "Default is at: $MIGRATION_BASE_DEFAULT" |
| 49 | + echo "MIGRATION_BASE_DEFAULT=$MIGRATION_BASE_DEFAULT" >> $GITHUB_ENV |
| 50 | + MIGRATION_BASE_REPORT=$(docker compose exec -u www-data -it web ./orm migrations:current --no-interaction --object-manager doctrine.entitymanager.orm_report | sed 's/\s-.*//' | sed 's/\s//') |
| 51 | + echo "Report is at: $MIGRATION_BASE_REPORT" |
| 52 | + echo "MIGRATION_BASE_REPORT=$MIGRATION_BASE_REPORT" >> $GITHUB_ENV |
| 53 | +
|
| 54 | + - name: seed base |
| 55 | + run: make seed |
| 56 | + |
| 57 | + - name: cleanup base |
| 58 | + run: docker compose --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml down |
| 59 | + |
| 60 | + - name: Checkout head branch |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Copy .env |
| 64 | + run: cp .env.dist .env |
| 65 | + |
| 66 | + - name: build head |
| 67 | + run: docker buildx bake --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml |
| 68 | + |
| 69 | + - name: run head |
| 70 | + run: docker compose --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml up -d --build --quiet-pull |
| 71 | + |
| 72 | + - name: migrate head |
| 73 | + run: make migrate |
| 74 | + |
| 75 | + - name: seed head |
| 76 | + run: make seed |
| 77 | + |
| 78 | + - name: revert to base migration |
| 79 | + run: | |
| 80 | + docker compose exec -u www-data -it web ./orm migrations:migrate --no-interaction --object-manager doctrine.entitymanager.orm_default $MIGRATION_BASE_DEFAULT |
| 81 | + docker compose exec -u www-data -it web ./orm migrations:migrate --no-interaction --object-manager doctrine.entitymanager.orm_report $MIGRATION_BASE_REPORT |
| 82 | +
|
| 83 | + - name: stop |
| 84 | + run: docker compose down |
0 commit comments