Skip to content

Commit

Permalink
adds resources for running tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
louismrose committed Mar 21, 2024
1 parent 1abd9a5 commit f1f244e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ build/*
composer.lock

# Ignore test files
.phpunit.result.cache
/tests/tinker/
/tests/TestConfig.php

# IDEs
/.vscode/
/.idea

# TODO list
TODO.md
# scratch files
TODO.md

# docker compose overrides
docker-compose.override.yml
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:7.2-cli

# Install PHP extensions and composer
RUN apt-get update && \
apt-get install -y libzip-dev zlib1g-dev zip && \
docker-php-ext-install zip && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy application files
RUN mkdir -p /usr/src/zamzar-php
COPY . /usr/src/zamzar-php
WORKDIR /usr/src/zamzar-php
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: up test

up:
@docker compose up -d
@docker compose exec php composer install --no-interaction

test: up
@docker compose exec php vendor/bin/phpunit
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'
services:
php:
build: .
depends_on:
- mock
entrypoint: [ "/bin/sh", "-c", "sleep infinity" ]
environment:
- ZAMZAR_API_KEY=GiVUYsF4A8ssq93FR48H
- ZAMZAR_API_URL=http://mock:8080
volumes:
- '.:/usr/src/zamzar-php'
working_dir: '/usr/src/zamzar-php'
mock:
image: zamzar/zamzar-mock:latest
ports:
- "8080:8080"
12 changes: 12 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit f1f244e

Please sign in to comment.