Skip to content

Commit

Permalink
ci: workflow for php8.2 and php8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Sep 5, 2024
1 parent e1c0c45 commit eb0bfc8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 57 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
name: Lint
name: Coding standards
on: [push]
jobs:
lint:
name: PHP Lint
name: Coding standards
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.2', '8.3' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Setup cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache Composer dependencies
- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-latest-
- name: Update composer
run: composer self-update

- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- uses: actions/checkout@master
- name: lint
run: make lint
- name: Run code quality analysis
run: make lint
53 changes: 36 additions & 17 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
name: Test
name: Tests
on: [push]
jobs:
lint:
name: PHP Test
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
test:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.2', '8.3' ]

- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/checkout@master
- name: test
run: make test
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Setup cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-latest-
- name: Update composer
run: composer self-update

- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests
run: make test
27 changes: 6 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
.DEFAULT_GOAL := help

# -----------------------------------
# Variables
# -----------------------------------
is_docker := $(shell docker info > /dev/null 2>&1 && echo 1)
user := $(shell id -u)
group := $(shell id -g)

ifeq ($(is_docker), 1)
php := USER_ID=$(user) GROUP_ID=$(group) docker-compose run --rm --no-deps php
composer := $(php) composer
else
php := php
composer := composer
endif

# -----------------------------------
# Recipes
# -----------------------------------
Expand All @@ -24,17 +9,17 @@ help: ## affiche cet aide

.PHONY: lint
lint: vendor/autoload.php ## affiche les erreurs de formatage de code
$(php) vendor/bin/ecs
$(php) vendor/bin/phpstan
php vendor/bin/ecs
php vendor/bin/phpstan

.PHONY: test
test: vendor/autoload.php ## lance les tests
$(php) vendor/bin/phpunit
php vendor/bin/phpunit

.PHONY: lint-fix
lint-fix: vendor/autoload.php ## corrige les erreurs de formatage de code
$(php) vendor/bin/ecs --fix
php vendor/bin/ecs --fix

vendor/autoload.php: composer.lock # installe les dépendances PHP
$(composer) update
$(composer) dump-autoload
composer update
composer dump-autoload
10 changes: 0 additions & 10 deletions docker-compose.yaml

This file was deleted.

0 comments on commit eb0bfc8

Please sign in to comment.