Skip to content

Commit

Permalink
Merge pull request #56 from upmind-automation/TR-77-update-for-compat…
Browse files Browse the repository at this point in the history
…ibility-with-base-library-v4

Update for base library v4
  • Loading branch information
uphlewis authored Jun 25, 2024
2 parents 90f98af + 115eb3a commit 4e22ff1
Show file tree
Hide file tree
Showing 46 changed files with 1,242 additions and 384 deletions.
30 changes: 30 additions & 0 deletions .docker/Dockerfile.php81
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.1-cli

# Install dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y \
git \
curl \
zip \
unzip \
libxml2-dev

# Install additional PHP extensions
RUN docker-php-ext-install soap

# Install Packages via PECL as not provided by PHP Source
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Clear cache
RUN apt clean && \
rm -rf /var/lib/apt/lists/*

# Install composer (get latest v2, change to `--1` if you want to install the latest v1).
RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer

COPY . /usr/src/lib
WORKDIR /usr/src/lib

CMD [ "php"]
30 changes: 30 additions & 0 deletions .docker/Dockerfile.php82
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.2-cli

# Install dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y \
git \
curl \
zip \
unzip \
libxml2-dev

# Install additional PHP extensions
RUN docker-php-ext-install soap

# Install Packages via PECL as not provided by PHP Source
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Clear cache
RUN apt clean && \
rm -rf /var/lib/apt/lists/*

# Install composer (get latest v2, change to `--1` if you want to install the latest v1).
RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer

COPY . /usr/src/lib
WORKDIR /usr/src/lib

CMD [ "php"]
30 changes: 30 additions & 0 deletions .docker/Dockerfile.php83
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.3-cli

# Install dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y \
git \
curl \
zip \
unzip \
libxml2-dev

# Install additional PHP extensions
RUN docker-php-ext-install soap

# Install Packages via PECL as not provided by PHP Source
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Clear cache
RUN apt clean && \
rm -rf /var/lib/apt/lists/*

# Install composer (get latest v2, change to `--1` if you want to install the latest v1).
RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer

COPY . /usr/src/lib
WORKDIR /usr/src/lib

CMD [ "php"]
47 changes: 47 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Workflow name
name: Static Analysis

# Triggers
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'

# Jobs/Pipelines
jobs:
phpstan:
name: 'PHP Stan'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3 ]
steps:
- name: "Checkout Code"
uses: actions/checkout@v4

- name: "Setup PHP with tools"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer, phpstan

- name: "Get composer cache directory"
id: composer-cache
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

- name: "Cache dependencies"
uses: actions/cache@v4
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "${{ runner.os }}-php-${{ matrix.php}}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-php-${{ matrix.php}}-composer-"

- name: "Install Composer dependencies"
run: composer install --no-ansi --no-interaction --no-progress --no-scripts --prefer-dist

- name: "Run PHPStan Static Analysis"
run: phpstan analyse
23 changes: 21 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
vendor
# Composer
composer.lock
vendor/

# Tools
.php-cs-fixer.cache
phpunit.xml
phpstan.neon
.phpunit.result.cache
.phpunit.cache/

# Docker
.docker/Dockerfile
docker-compose.yml

# IDE
.vscode/
.idea/
.vscode/launch.json
.php-cs-fixer.cache

# System
.DS_Store
error_log
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/php.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/provision-provider-shared-hosting.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

84 changes: 84 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
.PHONY: help

# List all available Makefile commands.
help:
@echo "Available commands:"
@echo " make help : List all available Makefile commands"
@echo " make setup-php81 : Start the dev environment with PHP 8.1"
@echo " make setup-php82 : Start the dev environment with PHP 8.2"
@echo " make setup-php83 : Start the dev environment with PHP 8.3"
@echo " make shell : Get an interactive shell on the PHP container"
@echo " make static-analysis : Run Static Analysis (PHPStan)"
@echo " make coding-standards : Run Coding Standards (PHP-CS-Fixer)"
@echo " make start-containers : Start the dev environment"
@echo " make stop-containers : Stop the dev environment"
@echo " make kill-containers : Stop and remove all containers"
@echo " make composer-install : Install composer dependencies"

# Typing 'make setup-php81' will start the dev environment with PHP 8.1
setup-php81: stop-containers --prep-dockerfile-php81 start-containers --remove-packages composer-install

# Typing 'make setup-php82' will start the dev environment with PHP 8.2
setup-php82: stop-containers --prep-dockerfile-php82 start-containers --remove-packages composer-install

# Typing 'make setup-php83' will start the dev environment with PHP 8.3
setup-php83: stop-containers --prep-dockerfile-php83 start-containers --remove-packages composer-install

# Get a shell on the PHP container
shell:
docker compose exec -it provision-provider-shared-hosting /bin/bash

# Run Static Analysis (PHPStan)
static-analysis:
docker compose exec provision-provider-shared-hosting ./vendor/bin/phpstan analyse --memory-limit=1G

coding-standards:
docker compose exec provision-provider-shared-hosting php ./bin/php-cs-fixer-v3.phar fix --config=./.php-cs-fixer.dist.php

# Start the dev environment
start-containers:
docker compose up -d --build

# Stop the dev environment
stop-containers:
docker compose down

# Stop and remove all containers
kill-containers:
docker compose kill
docker compose rm --force

# Install composer dependencies
composer-install:
docker compose exec provision-provider-shared-hosting composer install --no-interaction

# Copy Dockerfile for PHP 8.1
--prep-dockerfile-php81: --remove-dockerfile --prep-docker-compose-file
cp "./.docker/Dockerfile.php81" "./.docker/Dockerfile"

# Copy Dockerfile for PHP 8.2
--prep-dockerfile-php82: --remove-dockerfile --prep-docker-compose-file
cp "./.docker/Dockerfile.php82" "./.docker/Dockerfile"

# Copy Dockerfile for PHP 8.3
--prep-dockerfile-php83: --remove-dockerfile --prep-docker-compose-file
cp "./.docker/Dockerfile.php83" "./.docker/Dockerfile"

# Copy docker-compose.yml file
--prep-docker-compose-file:
[ -f "./docker-compose.yml" ] || cp "./docker-compose.yml.example" "./docker-compose.yml"

# Remove Dockerfile
--remove-dockerfile:
rm -f ./docker/Dockerfile

# Remove composer related files
--remove-packages: --remove-lockfile --remove-vendor

# Remove composer.lock file
--remove-lockfile:
docker compose exec provision-provider-shared-hosting rm -f ./composer.lock

# Remove vendor directory
--remove-vendor:
docker compose exec provision-provider-shared-hosting rm -rf ./vendor
Binary file renamed bin/php-cs-fixer → bin/php-cs-fixer-v3.phar
Binary file not shown.
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
}
},
"require": {
"php": "^7.4|^8.0",
"upmind/provision-provider-base": "^3.6",
"php": "8.1 - 8.3",
"upmind/provision-provider-base": "^4.0",
"plesk/api-php-lib": "^1.1",
"upmind/20i-php-sdk": "^1.0",
"upmind/enhance-sdk": "^10"
"upmind/20i-php-sdk": "^1.1",
"upmind/enhance-sdk": "^10",
"ext-curl": "*",
"ext-soap": "*"
},
"require-dev": {
"phpstan/phpstan": "^1.10"
},
"extra": {
"laravel": {
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.3'
services:

#PHP Service
provision-provider-shared-hosting:
build:
context: .
dockerfile: ./.docker/Dockerfile
container_name: provision-provider-shared-hosting
tty: true
environment:
SERVICE_NAME: provision-provider-shared-hosting
SERVICE_TAGS: dev
working_dir: /usr/src/lib
volumes:
- ./:/usr/src/lib
networks:
- provision-provider-shared-hosting-network

#Docker Networks
networks:
provision-provider-shared-hosting-network:
driver: bridge
1 change: 0 additions & 1 deletion fix_formatting.sh

This file was deleted.

4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 4
paths:
- src
1 change: 0 additions & 1 deletion src/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Upmind\ProvisionBase\Provider\BaseCategory;
use Upmind\ProvisionBase\Provider\DataSet\AboutData;
use Upmind\ProvisionBase\Provider\DataSet\ResultData;
use Upmind\ProvisionProviders\SharedHosting\Data\AccountInfo;
use Upmind\ProvisionProviders\SharedHosting\Data\AccountUsage;
use Upmind\ProvisionProviders\SharedHosting\Data\CreateParams;
Expand Down
6 changes: 3 additions & 3 deletions src/Data/AccountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function setSuspended(bool $suspended): self
}

/**
* @param string $reason Reason for suspension
* @param string|null $reason Reason for suspension
*/
public function setSuspendReason(?string $reason): self
{
Expand All @@ -137,7 +137,7 @@ public function setIp(?string $ip): self
}

/**
* @param string[]|null[]|null
* @param string[]|null[]|null $nameservers
*/
public function setNameservers(?array $nameservers): self
{
Expand All @@ -161,7 +161,7 @@ public function setSoftware($installation): self
}

/**
* @param string $location
* @param string|null $location
* @return $this
*/
public function setLocation(?string $location): self
Expand Down
1 change: 0 additions & 1 deletion src/Data/AccountUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Upmind\ProvisionProviders\SharedHosting\Data;

use Upmind\ProvisionBase\Provider\DataSet\DataSet;
use Upmind\ProvisionBase\Provider\DataSet\ResultData;
use Upmind\ProvisionBase\Provider\DataSet\Rules;

Expand Down
Loading

0 comments on commit 4e22ff1

Please sign in to comment.