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
10 changes: 10 additions & 0 deletions .config/lefthook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://json.schemastore.org/lefthook.json
pre-commit:
commands:
unit-tests:
run: mise run tests:**unit

pre-push:
commands:
all-tests:
run: mise run tests:**
4 changes: 2 additions & 2 deletions mago.toml → .config/mago.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Welcome to Mago!
# For full documentation, see https://mago.carthage.software/tools/overview
#:schema ./.mago/schema.json
#:schema ../.schema/mago.json

php-version = "8.5.0"

[source]
workspace = "."
paths = ["src/", "config/**/*"]
paths = ["../src/", "../config/**/*"]
includes = ["vendor"]
excludes = []

Expand Down
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: HTTP Tests
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: REST API Tests

on:
pull_request:
branches:
- main

jobs:
test-http:
tests_api:
runs-on: ubuntu-latest

steps:
Expand All @@ -19,7 +20,7 @@ jobs:
- name: Set USER_ID
run: echo "UID=$(id -u)" >> $GITHUB_ENV

- name: Run HTTP tests
- name: Run REST API tests
env:
USER_ID: ${{ env.UID }}
run: mise run test-http
run: mise run tests:**api
27 changes: 27 additions & 0 deletions .github/workflows/tests_mutation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Mutation Tests

on:
push:
pull_request:
branches:
- main

jobs:
tests_api:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: jdx/mise-action@v4
with:
cache: true

- name: Set USER_ID
run: echo "UID=$(id -u)" >> $GITHUB_ENV

- name: Run mutation tests
env:
USER_ID: ${{ env.UID }}
run: mise run tests:**mutation
27 changes: 27 additions & 0 deletions .github/workflows/tests_unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Unit Tests

on:
push:
pull_request:
branches:
- main

jobs:
tests_api:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: jdx/mise-action@v4
with:
cache: true

- name: Set USER_ID
run: echo "UID=$(id -u)" >> $GITHUB_ENV

- name: Run unit tests
env:
USER_ID: ${{ env.UID }}
run: mise run tests:**unit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ compose.override.yaml
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
/.phpunit.cache/
###< phpunit/phpunit ###
Empty file added .mise/lib/cli.sh
Empty file.
21 changes: 21 additions & 0 deletions .mise/lib/io.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

source "${MISE_PROJECT_ROOT}/.mise/lib/is_true.sh"

VERBOSE="${VERBOSE:-false}"

# verbose cmd args...
# Runs command silently if VERBOSE=1|true, otherwise normally
verbose() {
if is_true "$VERBOSE"; then
"$@"
else
"$@" > /dev/null 2>&1
fi
}

# log "message" -- prints if not silent
log() {
if is_true "$VERBOSE"; then echo "$@"; fi
return 0
}
4 changes: 4 additions & 0 deletions .mise/lib/is_true.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
is_true () {
[ "${1}" = "1" ] || [ "${1}" = "true" ]
}
23 changes: 0 additions & 23 deletions .mise/scripts/cli.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .mise/scripts/docker-compose-down.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .mise/scripts/docker-compose-up.sh

This file was deleted.

18 changes: 0 additions & 18 deletions .mise/scripts/docker-healthcheck.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .mise/scripts/lib/silent.sh

This file was deleted.

5 changes: 5 additions & 0 deletions .mise/tasks/composer/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# [MISE] description = ""
# [MISE] depends = [ "docker:healthcheck" ]

mise docker:compose:exec --service php -- composer install
5 changes: 5 additions & 0 deletions .mise/tasks/composer/require.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# [MISE] description = ""
# [MISE] depends = ["docker:healthcheck"]

mise docker:compose:exec --service php -- composer require "$@"
9 changes: 9 additions & 0 deletions .mise/tasks/docker/compose/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
#MISE description="Stop and remove containers"

source "${MISE_PROJECT_ROOT}/.mise/lib/io.sh"

verbose docker compose -f "${COMPOSE_FILE:-'docker-compose.yaml'}" down \
--remove-orphans \
--rmi local \
--timeout "${DC_TIMEOUT:-10}"
41 changes: 41 additions & 0 deletions .mise/tasks/docker/compose/exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# [MISE] description = "Run a command in a given container"
# [MISE] depends = [ "docker:healthcheck" ]
source "${MISE_PROJECT_ROOT}/.mise/lib/io.sh"

docker_exec() {
local SERVICE="${EXEC_TARGET_SERVICE:-php}"
local ENVS=()
local ARGS=()

while [[ $# -gt 0 ]]; do
case "$1" in
--)
shift
ARGS+=("$@")
break
;;
-e|--env)
ENVS+=("$1" "$2")
shift 2
;;
--service)
SERVICE="$2"
shift 2
;;
*)
ARGS+=("$1")
shift
;;
esac
done

local TTY
if [ -t 0 ]; then TTY=1; fi
log "TTY value: ${TTY}"
docker compose exec -i ${TTY:+"-t"} "${ENVS[@]}" "${SERVICE}" "${ARGS[@]}"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
docker_exec "$@"
fi
3 changes: 3 additions & 0 deletions .mise/tasks/docker/compose/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# [MISE] description = "Start containers in detached mode"
# [MISE] depends = ["docker:compose:down", "docker:compose:up"]
35 changes: 35 additions & 0 deletions .mise/tasks/docker/compose/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# [MISE] description="Start containers in detached mode"
# [MISE] wait_for=["docker:compose:down"]

source "${MISE_PROJECT_ROOT}/.mise/lib/io.sh"

SERVICES=()
IFS=';' read -ra SERVICES <<< "${DC_SERVICES}"
log "Docker Compose services: [${SERVICES[@]}]"
are_all_running() {
local expected=${#SERVICES[@]}
local actual
actual=$(docker compose ps "${SERVICES[@]}" \
--format '{{.Service}}' \
--status running \
2>/dev/null | wc -l)
if [[ "$expected" == "$actual" ]]; then
log "All expected services (${SERVICES[@]}) are in status 'running'"
return 0;
else
return 1;
fi
}

# early exit
if are_all_running && [[ -z "${FORCE_RERUN}" || "${FORCE_RERUN,,}" == "false" || "${FORCE_RERUN}" == "0" ]]; then
verbose echo "Nothing to do";
exit 0;
fi

verbose docker compose ${COMPOSE_FILE:+"-f"} "${COMPOSE_FILE}" up \
--build \
--remove-orphans \
--force-recreate "${SERVICES[@]}" \
-d
18 changes: 18 additions & 0 deletions .mise/tasks/docker/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#MISE description="Wait until all containers are healthy"
#MISE depends=["docker:compose:up"]
source "${MISE_PROJECT_ROOT}/.mise/lib/io.sh"

SERVICES=()
IFS=';' read -ra SERVICES <<< "${DC_SERVICES}"

VERBOSE=1 log "Waiting for services to be healthy..."

for service in "${SERVICES[@]}"; do
until [[ "$(docker inspect --format='{{.State.Health.Status}}' $(docker compose ps ${service} -q))" == "healthy" ]]; do
sleep 1
done
log "Service [$service] is healthy"
done

VERBOSE=1 log "All services are healthy"
4 changes: 4 additions & 0 deletions .mise/tasks/docker/logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
#MISE description="Follow container logs"

docker compose -f "${COMPOSE_FILE:-'docker-compose.yaml'}" logs --follow
3 changes: 3 additions & 0 deletions .mise/tasks/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
#MISE description="Tear down all containers"
#MISE depends=["docker:compose-down"]
7 changes: 7 additions & 0 deletions .mise/tasks/tests/api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# [MISE] description = ""
# [MISE] depends = ["docker:healthcheck", "composer:install"]
# [MISE] wait_for = ["docker:compose:down"]
# [MISE] env = { VERBOSE = 1, COLOR = 1 }

hurl ${HURL_REQUESTS_FILES} --variables-file ${HURL_VARS_FILE:-hurl.env} ${VERBOSE:+--verbose} ${COLOR+--color}
11 changes: 11 additions & 0 deletions .mise/tasks/tests/mutation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# [MISE] description = "Runs mutation tests with Pest"
# [MISE] depends = ["docker:healthcheck", "composer:install"]
# [MISE] wait_for = ["docker:compose:down"]
# [MISE] env = { RUN_PARALLEL = 1}

mise docker:compose:exec --service php -- \
"${PHP_TEST_RUNNER:-vendor/bin/pest}" \
--mutate \
"${RUN_PARALLEL:+--parallel}" \
"$@"
10 changes: 10 additions & 0 deletions .mise/tasks/tests/unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# [MISE] description = "Runs unit tests with Pest"
# [MISE] depends = ["docker:healthcheck", "composer:install"]
# [MISE] wait_for = ["docker:compose:down"]
# [MISE] env = { RUN_PARALLEL = 1 }

mise docker:compose:exec --service php -- \
"${PHP_TEST_RUNNER:-vendor/bin/pest}" \
"${RUN_PARALLEL:+--parallel}" \
"$@"
3 changes: 3 additions & 0 deletions .mise/tasks/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# [MISE] description="Full environment bootstrap"
# [MISE] depends=["docker:compose-up", "docker:healthcheck"]
File renamed without changes.
Loading
Loading