Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Quality and Checks #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
unit-tests:
docker:
- image: circleci/php:7.0
- image: circleci/php:8.1
steps:
- run: sudo composer self-update && sudo composer self-update --1
- checkout
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
machine:
enabled: true
docker:
- image: circleci/php:7.0
- image: circleci/php:8.1
steps:
- add_ssh_keys:
fingerprints:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Check Codestyle

on:
push:
branches:
- master
pull_request:
branches:
- "*"
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
fix-style:
name: Fix Code Style
timeout-minutes: 15
runs-on: ubuntu-latest
env:
COMPOSER_NO_INTERACTION: 1

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.x
coverage: none
tools: composer, cs2pr

- name: Install dependencies
run: |
composer update --prefer-dist --no-suggest --no-progress --no-interaction
- name: Check Code Style
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml

61 changes: 61 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:
branches:
- "*"
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: ['8.1']
experimental: [false]

include:
- php: '8.2'
experimental: true

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
continue-on-error: ${{ matrix.experimental }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL, display_errors=On
coverage: none
tools: composer

- name: Install dependencies - normal
if: ${{ matrix.php < 8.2 }}
run: |
composer install --prefer-dist --no-progress --no-interaction

- name: Install dependencies - ignore platform reqs
if: ${{ matrix.php >= 8.2 }}
run: |
composer update --prefer-dist --no-progress --ignore-platform-reqs --no-interaction

- name: Execute Unit Tests
run: vendor/bin/phpunit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
composer.phar
/vendor/
.env
.phpunit.result.cache
.phpcs-cache
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# set all to phony
SHELL=bash

.PHONY: *

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(abspath $(patsubst %/,%,$(dir $(mkfile_path))))

THREADS := $(shell docker info -f '{{ .NCPU }}')

export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
export LOCAL_COMPOSER_HOME=$(shell composer config --global home 2> /dev/null || echo ${HOME}/.config/composer)
export LOCAL_COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir 2> /dev/null || echo ${HOME}/.config/composer/cache)

DOCKER_RUN=@docker run -it --rm \
--volume=$(shell pwd):/opt/project \
amsphp-console-cli

DOCKER_RUN_COMPOSER=@docker run -it --rm \
--volume=${LOCAL_COMPOSER_CACHE_DIR}:/tmp/composer/cache \
--volume=${LOCAL_COMPOSER_HOME}:/.config/composer \
--volume=$(shell pwd):/opt/project \
amsphp-console-cli

DOCKER_RUN_TEST=@docker run -it --rm \
--volume=$(shell pwd):/opt/project \
amsphp-console-cli

DOCKER_RUN_XDEBUG_COVERAGE=@XDEBUG_MODE=coverage docker run -it --rm \
--volume=$(shell pwd):/opt/project \
amsphp-console-cli

all: build composer-install test

install: env-check docker-lint docker-build composer-install ## Builds the project

build:
@echo -e "\033[33mBuilding PHP docker images\033[0m"
@docker build -f docker/cli.Dockerfile -t amsphp-console-cli .

composer-install: ## Install dependencies with composer, according to the existing composer.lock
@echo -e "\033[33mInstalling dependencies\033[0m"
$(DOCKER_RUN_COMPOSER) composer install -n -o

composer-require-checker: env-check ## Checks if all root dependencies are declared
@echo -e "\033[33mChecking composer requirements\033[0m"
$(DOCKER_RUN_COMPOSER) vendor/bin/composer-require-checker check --config-file=composer-require-checker.json

composer-validate: env-check ## Runs composer validate
@echo -e "\033[33mValidating composer.json\033[0m"
$(DOCKER_RUN_COMPOSER) composer validate --no-check-all --strict

test:
@echo -e "\033[33mRunning Tests\033[0m"
$(DOCKER_RUN_TEST) ./vendor/bin/phpunit

run-cmd:
$(DOCKER_RUN) bin/console $(ARGS)

shell: ## Gives shell access inside the container
$(DOCKER_RUN) sh

help:
@echo "\033[33mUsage:\033[0m\n make [target] [FLAGS=\"val\"...]\n\n\033[33mTargets:\033[0m"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-18s\033[0m %s\n", $$1, $$2}'
33 changes: 21 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
{
"require": {
"symfony/console": "^3.0",
"mcrumm/phlack": "^0.7.0",
"dms/meetup-api-client": "^2.0",
"joindin/api-client": "^0.1.3",
"codeliner/array-reader": "^1.2",
"php-di/php-di": "^5.2",
"vlucas/phpdotenv": "^2.2"
"symfony/console": "^6",
"codeliner/array-reader": "^2",
"php-di/php-di": "^6",
"guzzlehttp/guzzle": "^7.5",
"ext-json": "*",
"ramsey/collection": "^1.2",
"ext-intl": "*"
},

"autoload": {
"psr-4": {
"AmsterdamPHP\\Console\\": ["src/", "tests/"],
"Deployer\\": "vendor/deployer/deployer/"
"AmsterdamPHP\\Console\\": ["src/", "tests/"]
}
},
"require-dev": {
"deployer/deployer": "^4@dev",
"phpunit/phpunit": "^5.3",
"mockery/mockery": "^0.9.5"
"mockery/mockery": "^1",
"phpunit/phpunit": "^9",
"vlucas/phpdotenv": "^5",
"deployer/deployer": "^7",
"doctrine/coding-standard": "^10.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"phpcs": "phpcs"
}
}
Loading