fix test #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of the sshilko/php-api-myrpc package. | |
# | |
# (c) Sergei Shilko <[email protected]> | |
# | |
# MIT License | |
# | |
# For the full copyright and license information, please view the LICENSE | |
# file that was distributed with this source code. | |
# @license https://opensource.org/licenses/mit-license.php MIT | |
name: 8.2 PHPUnit | |
on: | |
push: | |
branches: [ "master" ] | |
permissions: | |
contents: read | |
jobs: | |
build-containers: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-ci')" | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker php-image | |
id: docker-php-image-cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/docker-save | |
key: ${{ runner.os }}-docker-php-build-save-${{ hashFiles('build/Dockerfile.php.common', 'build/Dockerfile.php82') }} | |
- name: Load cached Docker image | |
run: docker load -i /tmp/docker-save/snapshot.tar || true | |
if: steps.docker-php-image-cache.outputs.cache-hit == 'true' | |
- name: Build Docker image | |
run: ls -l && docker build -f build/Dockerfile.php82 --build-arg BUILDKIT_INLINE_CACHE=1 -t app/php-image --cache-from=app/php-image-cache ./build | |
if: steps.docker-php-image-cache.outputs.cache-hit != 'true' | |
env: | |
DOCKER_BUILDKIT: '1' | |
COMPOSE_DOCKER_CLI_BUILD: '1' | |
- name: Tag Docker image | |
run: docker tag app/php-image app/php-image-cache && mkdir -p /tmp/docker-save && docker save app/php-image-cache -o /tmp/docker-save/snapshot.tar && ls -lh /tmp/docker-save || true | |
if: always() && steps.docker-php-image-cache.outputs.cache-hit != 'true' | |
build: | |
needs: build-containers | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-ci')" | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Load cached app docker image | |
id: docker-php-image-cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/docker-save | |
key: ${{ runner.os }}-docker-php-build-save-${{ hashFiles('build/Dockerfile.php.common', 'build/Dockerfile.php82') }} | |
- name: Load cached Docker image | |
run: docker load -i /tmp/docker-save/snapshot.tar && docker tag app/php-image-cache app/php82 | |
- name: Docker boot | |
env: | |
DOCKER_BUILDKIT: '1' | |
COMPOSE_DOCKER_CLI_BUILD: '1' | |
SERVICES_NAME: "app.php82" | |
run: docker-compose up --force-recreate -d $SERVICES_NAME | |
timeout-minutes: 3 | |
- name: Wait for all services to become healthy | |
run: for SVC in "app.php82"; do while [ "\"healthy\"" != "$(docker inspect --format '{{json .State.Health.Status }}' ${SVC})" ];do docker-compose ps && sleep 5; done; done | |
timeout-minutes: 3 | |
- name: Sleep | |
run: sleep 4 | |
- run: docker-compose ps | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('composer.lock') }}-composer-dev | |
- name: Docker install dependencies | |
run: docker-compose exec -T app.php82 composer install | |
- name: Docker run PHPUnit | |
run: docker-compose exec -T app.php82 composer app-phpunit-coverage |