Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Continual Integration

on:
workflow_dispatch:
push:
branches:
- main
- feature/**
- bugfix/**
- dependabot/**

jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php-versions }}, Laravel ${{ matrix.laravel-versions }})

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
laravel-versions: ['9.*', '10.*', '11.*', '12.*']
exclude:
- php-versions: '8.1'
laravel-versions: '11.*' # Laravel 11 typically requires PHP 8.2+
- php-versions: '8.1'
laravel-versions: '12.*' # Laravel 12 typically requires PHP 8.2+

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

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

- name: Validate composer files
run: composer validate --strict

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-versions }}-laravel-${{ matrix.laravel-versions }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-versions }}-laravel-${{ matrix.laravel-versions }}
${{ runner.os }}-php-${{ matrix.php-versions }}-laravel-
${{ runner.os }}-php-${{ matrix.php-versions }}-

- name: Install Composer dependencies
run: |
composer install --prefer-dist --no-progress --no-interaction
composer update "illuminate/support:${{ matrix.laravel-versions }}" "illuminate/container:${{ matrix.laravel-versions }}" --with-all-dependencies --prefer-dist --no-progress --no-interaction

- name: Run PHPUnit tests
run: vendor/bin/phpunit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Composer
/vendor/
composer.lock

# IDE
.idea
Expand All @@ -13,3 +14,6 @@

# Test Coverage
/test-reports

# OS
.DS_Store
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget Windows! 🥳

Suggested change
# OS
.DS_Store
# OS
.DS_Store
Thumbs.db

15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.4-cli

RUN apt-get update && apt-get install -y \
git \
unzip \
$PHPIZE_DEPS \
&& rm -rf /var/lib/apt/lists/*

RUN pecl install pcov && docker-php-ext-enable pcov

RUN echo "pcov.enabled=1" > /usr/local/etc/php/conf.d/99-pcov.ini

COPY --from=composer/composer:latest-bin /composer /usr/local/bin/composer

WORKDIR /app
41 changes: 41 additions & 0 deletions Makefile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thing of beauty 😍

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

IMAGE_NAME := json-diff
CURRENT_DIR := $(shell pwd)

.PHONY: help

# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)

TARGET_MAX_CHAR_NUM=20

## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

## Start and log into the container
up: build run

## Build a new version of the container
build:
@docker build -t $(IMAGE_NAME) .

## Run the existing container
run:
@docker run -it --rm -v "$(CURRENT_DIR):/app" $(IMAGE_NAME) bash
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "covergenius/json-diff",
"description": "JSON Diff",
"type": "library",
"license": "GNUv3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composer validate does not recognise this license key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! ❤️

"license": "GPL-3.0-only",
"autoload": {
"psr-4": {
"Jet\\JsonDiff\\": "src/"
Expand All @@ -20,13 +21,16 @@
},
"authors": [
{
"name": "Jet Lim and Ruben Funai"
"name": "Jet Lim"
},
{
"name": "Ruben Funai"
}
],
"require": {
"php": "^8.0",
"illuminate/support": "^9.0 || ^10.0",
"illuminate/container": "^9.0 || ^10.0"
"illuminate/support": "^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/container": "^9.0 || ^10.0 || ^11.0 || ^12.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
Expand All @@ -41,8 +45,11 @@
"lint": [
"php-cs-fixer fix -v"
],
"test:with-coverage": [
"test:coverage": [
"phpunit --coverage-html ./test-reports"
],
"test": [
"phpunit"
]
}
}
Loading