Skip to content
Closed
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
65 changes: 62 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: "Tests"

on: [pull_request]
jobs:
lint:
name: Tests ${{ matrix.php-versions }}
docker-tests:
name: Tests ${{ matrix.php-versions }} (Docker)
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -29,4 +29,63 @@ jobs:
run: docker compose up -d && sleep 15

- name: Run tests
run: docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml
run: docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml

k8s-tests:
name: K8s adapters (kind)
runs-on: ubuntu-latest
needs: docker-tests
env:
HOST_DIR: ${{ github.workspace }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup PHP 8.1
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install dependencies
run: composer install --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist

- name: Set up kind cluster
uses: helm/kind-action@v1.10.0
with:
cluster_name: test-cluster

- name: Setup kubectl
uses: azure/setup-kubectl@v4

- name: Verify KinD Cluster
run: |
kubectl cluster-info
kubectl get nodes

- name: Setup Docker network for KinD access
run: |
# Make kubeconfig accessible to containers
kind get kubeconfig --name test-cluster --internal > /tmp/kind-kubeconfig

- name: Start container
run: docker compose up -d && sleep 15

- name: Connect container to kind network
run: |
CONTAINER_ID=$(docker compose ps -q tests)
docker network connect kind "$CONTAINER_ID" || true

- name: Run K8s CLI adapter tests
run: docker compose exec tests vendor/bin/phpunit tests/Orchestration/Adapter/K8sCLITest.php

- name: Run K8s SDK adapter tests
run: |
docker compose exec tests vendor/bin/phpunit tests/Orchestration/Adapter/K8sTest.php

- name: Cleanup
if: always()
run: |
docker compose -f docker-compose.yml down -v || true
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN \
apk update \
&& apk add --no-cache make automake autoconf gcc g++ git brotli-dev docker-cli \
&& apk add --no-cache make automake autoconf gcc g++ git brotli-dev docker-cli curl \
&& docker-php-ext-install sockets \
&& docker-php-ext-install opcache

# Install kubectl for K8s CLI adapter tests
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
&& chmod +x kubectl \
&& mv kubectl /usr/local/bin/kubectl

WORKDIR /usr/src/code

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"require": {
"php": ">=8.0",
"utopia-php/console": "0.0.*"
"utopia-php/console": "0.0.*",
"renoki-co/php-k8s": "^3.8"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
Expand Down
Loading