Skip to content

Commit

Permalink
WIP Use only docker in GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed Nov 3, 2021
1 parent 9257cb0 commit e478119
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 158 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: "coding standards"
name: "docker coding standards"

on: ["pull_request", "push"]

jobs:
coding-standards:
name: "coding standards"
name: "docker coding standards"
runs-on: "ubuntu-latest"
steps:
- name: "checkout"
uses: "actions/checkout@v2"

- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr, php-cs-fixer
- name: "build the environment"
run: "dev/bin/docker-compose build"

- name: "checking coding standards"
run: "php-cs-fixer fix --dry-run --diff --ansi"
run: "dev/bin/php php-cs-fixer fix --dry-run --diff --ansi"

- name: Clear docker volumes
if: ${{ always() }}
run: dev/bin/docker-compose down --volumes
17 changes: 0 additions & 17 deletions .github/workflows/docker-coding-standards.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/docker-static-analysis.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/docker-unit-tests.yml

This file was deleted.

23 changes: 11 additions & 12 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
name: "static analysis"
name: "docker static analysis"

on: ["pull_request", "push"]

jobs:
static-analysis:
name: "static analysis"
name: "docker static analysis"
runs-on: "ubuntu-latest"
steps:
- name: "checkout"
uses: "actions/checkout@v2"

- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
ini-values: memory_limit=-1
tools: composer:v2, psalm
extensions: intl, bcmath, curl, openssl, mbstring, pdo, pdo_sqlite
- name: "build the environment"
run: "dev/bin/docker-compose build"

- name: "installing dependencies"
run: "composer update --no-interaction --no-progress"
- name: "install dependencies"
run: "dev/bin/php composer install"

- name: "running static analysis"
run: "psalm --shepherd --stats"
run: "dev/bin/php psalm --shepherd --stats"

- name: Clear docker volumes
if: ${{ always() }}
run: dev/bin/docker-compose down --volumes
91 changes: 29 additions & 62 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,32 @@
name: "unit tests"
name: "docker unit tests"

on: [ "pull_request", "push" ]
on: ["pull_request", "push"]

jobs:
unit-tests:
name: "unit tests"

runs-on: "ubuntu-latest"

strategy:
matrix:
symfony-version:
- "5.3.*"
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
dependencies:
- "lowest"
- "highest"

steps:
- name: "checkout"
uses: "actions/checkout@v2"

- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
tools: composer:v2, cs2pr
extensions: intl, bcmath, curl, openssl, mbstring, pdo, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1

- name: "caching dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}"
restore-keys: "php-${{ matrix.php-version }}"

- name: "configuring composer platform"
if: (startsWith(matrix.php, '8.0'))
run: composer config platform.php 7.4.99

- name: "install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: composer update --prefer-lowest --no-interaction --no-progress --prefer-dist

- name: "install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: |
composer require --no-update symfony/config=${{ matrix.symfony-version }} symfony/http-kernel=${{ matrix.symfony-version }} symfony/dependency-injection=${{ matrix.symfony-version }} symfony/options-resolver=${{ matrix.symfony-version }}
composer require --no-update --dev symfony/framework-bundle=${{ matrix.symfony-version }} symfony/yaml=${{ matrix.symfony-version }}
composer update --no-interaction --no-progress --prefer-dist
- name: "installing phpunit"
run: vendor/bin/simple-phpunit install

- name: "running unit tests"
run: vendor/bin/simple-phpunit
unit-tests:
name: "docker unit tests"
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
matrix:
php: [ '7.2', '7.3', '7.4', '8.0' ]
symfony: [ '5.3' ]
composer-flags: [ '', '--prefer-lowest', '--prefer-stable']
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}.*
steps:
- name: "checkout"
uses: "actions/checkout@v2"

- name: "build the environment"
run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} php"

- name: "install dependencies"
run: "dev/bin/php composer update --ansi ${{ matrix.composer-flags }}"

- name: "running unit tests"
run: "dev/bin/php-test vendor/bin/simple-phpunit --colors=always"

- name: Clear docker volumes
if: ${{ always() }}
run: dev/bin/docker-compose down --volumes
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=7.2",
"doctrine/doctrine-bundle": "^2.0",
"doctrine/doctrine-bundle": "^2.0.8",
"doctrine/orm": "^2.7.1",
"league/oauth2-server": "^8.0",
"nyholm/psr7": "^1.4",
Expand Down
27 changes: 10 additions & 17 deletions dev/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
ARG PHP_VERSION=7.4

FROM php:${PHP_VERSION}-cli-alpine3.14
FROM php:${PHP_VERSION}-cli-alpine
LABEL maintainer="Petar Obradović <[email protected]>"

ARG COMPOSER_VERSION=2.1.9
ARG FLEX_VERSION=1.17.1
ARG PHP_CS_FIXER_VERSION=3.2.1
ARG XDEBUG_VERSION=3.1.1
ARG PSALM_VERSION=4.11.2

ENV XDEBUG_START_WITH_REQUEST 0

# This is where we're going to store all of our non-project specific binaries
RUN mkdir -p /app/bin
ENV PATH /app/bin:$PATH
Expand All @@ -25,13 +17,15 @@ RUN apk add --update --no-cache --virtual .build-deps \
xml \
zip \
&& pecl install \
xdebug-${XDEBUG_VERSION} \
xdebug \
&& docker-php-ext-enable \
xdebug \
&& apk del --purge .build-deps

RUN mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini

ENV XDEBUG_START_WITH_REQUEST 0

RUN echo '[xdebug]' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
&& echo 'xdebug.start_with_request = ${XDEBUG_START_WITH_REQUEST}' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
&& echo 'xdebug.mode = debug' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
Expand All @@ -47,26 +41,25 @@ RUN apk add --update --no-cache \
shadow

# Composer
RUN curl --show-error https://getcomposer.org/installer | php -- \
--install-dir=/app/bin \
--filename=composer \
--version=${COMPOSER_VERSION}
RUN curl --location --output /app/bin/composer --show-error \
https://github.com/composer/composer/releases/latest/download/composer.phar \
&& chmod a+x /app/bin/composer

# PHP-CS-Fixer
RUN curl --location --output /app/bin/php-cs-fixer --show-error \
https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v${PHP_CS_FIXER_VERSION}/php-cs-fixer.phar \
https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar \
&& chmod a+x /app/bin/php-cs-fixer

# Psalm
RUN curl --location --output /app/bin/psalm --show-error \
https://github.com/vimeo/psalm/releases/download/${PSALM_VERSION}/psalm.phar \
https://github.com/vimeo/psalm/releases/latest/download/psalm.phar \
&& chmod a+x /app/bin/psalm

# Create the user that's going to run our application
RUN useradd -ms /bin/sh app

# Enable parallel package installation for Composer
RUN su-exec app composer global require symfony/flex:${FLEX_VERSION}
RUN su-exec app composer global require symfony/flex

COPY entrypoint.sh /usr/local/bin/docker-entrypoint

Expand Down

0 comments on commit e478119

Please sign in to comment.