Skip to content
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
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Docker ignore file for secrets_cli_php
.git
.gitignore
.github
vendor/
.env
.env.*
.secrets
*.log
.phpunit.cache/
.idea/
.vscode/
*.md
LICENSE
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['8.4']

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

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, zip
coverage: xdebug

- name: Validate composer.json
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-

- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-interaction

- name: Run test suite
run: ./vendor/bin/phpunit --no-progress

- name: Run test suite with coverage
run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml --no-progress
continue-on-error: true

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

docker:
runs-on: ubuntu-latest

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

- name: Build Docker image
run: docker build -t secrets-cli-php:test .

- name: Run tests in Docker
run: docker run --rm secrets-cli-php:test ./vendor/bin/phpunit
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ vendor
.env
.env.development
.secrets
.idea/*
.idea/*

# PHPUnit
.phpunit.cache/
coverage.xml
.coverage/
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM php:8.4-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
zip \
&& docker-php-ext-install zip \
&& rm -rf /var/lib/apt/lists/*

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /app

# Copy composer files
COPY composer.json ./

# Install PHP dependencies (will create/update composer.lock)
RUN composer update --no-interaction --no-scripts --no-autoloader --prefer-dist

# Copy application files
COPY . .

# Generate autoloader
RUN composer dump-autoload --optimize

# Default command
CMD ["./vendor/bin/phpunit"]
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.PHONY: help build install test test-coverage shell clean

# Default target
.DEFAULT_GOAL := help

# Docker image name
IMAGE_NAME = secrets-cli-php
CONTAINER_NAME = secrets-cli-php-test

help: ## Display this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'

build: ## Build the Docker image
docker build -t $(IMAGE_NAME) .

install: build ## Build image and install composer dependencies
docker run --rm -v $(PWD):/app $(IMAGE_NAME) composer update

update: build ## Update composer dependencies
docker run --rm -v $(PWD):/app $(IMAGE_NAME) composer update

test: ## Run PHPUnit tests in Docker container
@docker run --rm -v $(PWD):/app $(IMAGE_NAME) ./vendor/bin/phpunit --no-progress || ([ $$? -eq 1 ] && exit 1 || exit 0)

test-coverage: ## Run PHPUnit tests with coverage report
docker run --rm -v $(PWD):/app $(IMAGE_NAME) ./vendor/bin/phpunit --coverage-text

test-filter: ## Run specific test (usage: make test-filter FILTER=ApplicationTest)
docker run --rm -v $(PWD):/app $(IMAGE_NAME) ./vendor/bin/phpunit --filter=$(FILTER)

shell: ## Open a shell in the Docker container
docker run --rm -it -v $(PWD):/app $(IMAGE_NAME) /bin/bash

composer: ## Run composer command (usage: make composer CMD="require package/name")
docker run --rm -v $(PWD):/app $(IMAGE_NAME) composer $(CMD)

clean: ## Clean up Docker containers and images
docker rmi $(IMAGE_NAME) || true

lint: ## Run PHP linting
docker run --rm -v $(PWD):/app $(IMAGE_NAME) find src tests -name "*.php" -exec php -l {} \;
Loading