Skip to content

Commit d661d94

Browse files
committed
Initial commit
0 parents  commit d661d94

36 files changed

+6156
-0
lines changed

.github/workflows/tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
php-version: ['8.1', '8.2', '8.3']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
25+
coverage: xdebug
26+
27+
- name: Cache Composer packages
28+
id: composer-cache
29+
uses: actions/cache@v3
30+
with:
31+
path: vendor
32+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-php-${{ matrix.php-version }}-
35+
36+
- name: Install dependencies
37+
run: composer update --prefer-dist --no-progress --no-interaction
38+
39+
- name: Execute tests
40+
run: vendor/bin/phpunit
41+
42+
- name: Upload coverage to Codecov
43+
if: matrix.php-version == '8.1'
44+
uses: codecov/codecov-action@v3
45+
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
files: ./coverage.xml
48+
fail_ci_if_error: false

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/vendor/
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
.env
6+
.phpunit.result.cache
7+
/logs/
8+
9+
# PHPUnit
10+
/coverage/
11+
.phpunit.cache/
12+
13+
# IDEs
14+
/.idea
15+
/.vscode
16+
*.swp
17+
*.swo
18+
19+
# OS
20+
.DS_Store
21+
Thumbs.db

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM php:8.2-fpm
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
curl \
7+
libpng-dev \
8+
libonig-dev \
9+
libxml2-dev \
10+
zip \
11+
unzip \
12+
libzip-dev \
13+
libicu-dev \
14+
--no-install-recommends \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install PHP extensions
18+
RUN docker-php-ext-install -j$(nproc) \
19+
bcmath \
20+
intl \
21+
mbstring \
22+
opcache \
23+
pcntl \
24+
zip \
25+
&& docker-php-source delete
26+
27+
# Install Xdebug for code coverage
28+
RUN pecl install xdebug \
29+
&& docker-php-ext-enable xdebug
30+
31+
# Copy Xdebug configuration
32+
COPY docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
33+
34+
# Install Composer
35+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
36+
37+
# Set working directory
38+
WORKDIR /var/www
39+
40+
## Do not copy the full app into the image; rely on bind mount in docker-compose
41+
# COPY . /var/www
42+
43+
# Set up the entry point
44+
COPY docker-entrypoint.sh /usr/local/bin/
45+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
46+
47+
# Set up bash prompt
48+
RUN echo 'export PS1="\[\e[32m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\] \$ "' >> /root/.bashrc
49+
50+
# Set default command
51+
CMD ["php-fpm"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Scott Laurent
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.PHONY: up down build ensure-build ssh composer test test-coverage test-phpunit install update help
2+
3+
# Project variables
4+
DOCKER_COMPOSE = docker compose
5+
DOCKER_COMPOSE_FILE = docker-compose.yml
6+
DOCKER_SERVICE = fsrs
7+
COMPOSER = $(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) composer
8+
9+
## —— Docker Compose ————————————————————————————————————————————————————————————
10+
up: ## Start all containers in the background
11+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up -d
12+
13+
up-verbose: ## Start all containers in the foreground
14+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up
15+
16+
down: ## Stop and remove all containers
17+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down
18+
19+
down-v: ## Stop and remove all containers and volumes
20+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down -v
21+
22+
build: ## Rebuild the Docker containers
23+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) build --no-cache
24+
25+
ensure-build: ## Ensure the Docker image is built (uses cache)
26+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) build
27+
28+
ssh: up ## Get shell access to the container
29+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) exec $(DOCKER_SERVICE) bash
30+
31+
## —— Composer ——————————————————————————————————————————————————————————————————
32+
composer: ## Run composer commands
33+
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) run --rm $(DOCKER_SERVICE) composer $(filter-out $@,$(MAKECMDGOALS))
34+
35+
install: ensure-build ## Install dependencies
36+
@$(COMPOSER) install --no-interaction --prefer-dist
37+
38+
update: ## Update dependencies
39+
@$(COMPOSER) update
40+
41+
## —— Testing ———————————————————————————————————————————————————————————————————
42+
test: ## Run all tests with coverage report
43+
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --testdox --coverage-text"
44+
45+
test-coverage: ## Generate HTML test coverage report
46+
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html=coverage"
47+
48+
coverage: test-coverage ## Alias for test-coverage
49+
50+
open-coverage: test-coverage ## Open the coverage report in default browser
51+
@if command -v xdg-open > /dev/null; then \
52+
xdg-open coverage/index.html; \
53+
elif command -v open > /dev/null; then \
54+
open coverage/index.html; \
55+
else \
56+
echo "Please open coverage/index.html in your browser"; \
57+
fi
58+
59+
test-phpunit: ## Run PHPUnit tests with optional arguments
60+
$(DOCKER_COMPOSE) run --rm $(DOCKER_SERVICE) bash -c "cd /var/www && ./vendor/bin/phpunit $(filter-out $@,$(MAKECMDGOALS))"
61+
62+
## —— Help ——————————————————————————————————————————————————————————————————————
63+
help: ## Display this help screen
64+
@echo "\n\033[33mUsage:\033[0m\n make [command] [arguments...]\n"
65+
@echo "\033[33mAvailable commands:\033[0m"
66+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
67+
68+
.DEFAULT_GOAL := help
69+
70+
%:
71+
@:

0 commit comments

Comments
 (0)