updating structure

This commit is contained in:
Your Name
2024-08-25 18:34:01 +03:00
parent dbfb2c03bb
commit af9260a35c
23 changed files with 7546 additions and 65 deletions

View File

@@ -0,0 +1,4 @@
.idea
.github
var
vendor

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_size = 2
[Makefile]
indent_style = tab

5
.env.dist Normal file
View File

@@ -0,0 +1,5 @@
GITEA_INSTANCE_BASE_URL="https://gitea.example.com"
GITEA_ACCESS_TOKEN="access_token"
GITEA_OWNER="owner"
GITEA_REPOSITORY="repository"
GITEA_PACKAGE_REGISTRY="composer"

26
.gitattributes vendored Normal file
View File

@@ -0,0 +1,26 @@
* text=auto
AUTHORS text
CHANGELOG text
CHANGES text
CONTRIBUTING text
COPYING text
LICENSE text
NEWS text
.editorconfig text
.gitattributes text
.gitconfig text
.env text
.env.example text
.env.ci text
.gitignore text
.dockerignore text
Dockerfile text
Makefile text
composer.json text eol=lf
*.md text diff=markdown
*.php text diff=php
*.sh text eol=lf
*.yml text
*.json text

View File

@@ -1,24 +0,0 @@
on:
issues:
types: [opened, edited, reopened]
issue_comment:
types: [created, edited]
jobs:
send_telegram_message:
name: send telegram message
runs-on: ubuntu-latest
steps:
- name: send telegram message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Gitea. Creating new issue
Author: ${{ gitea.actor }}
Repository: ${{ gitea.repository }}
See changes: https://gitea.com/${{ gitea.repository }}/issues/${{ gitea.event.issue.number }}

178
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,178 @@
name: tests
on:
pull_request: ~
push:
branches: ['*.*.*']
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- run: cp .env.dist .env
- uses: falti/dotenv-action@v1
id: dotenv
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
PHP_VERSION=${{ steps.dotenv.outputs.PHP_VERSION }}
push: false
composer-validate:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- run: composer validate --strict --ansi
composer-require-checker:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer require-checker
composer-unused:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer unused
composer-normalize:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer normalize --dry-run --diff --ansi
php-cs-fixer:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, cs2pr
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer fixcs -- --dry-run --diff --format=checkstyle --ansi | cs2pr
rector:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer rector -- --dry-run
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer psalm -- --php-version=${{ matrix.php }} --stats --output-format=github --shepherd
phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
# - run: composer test -- --colors=always --order-by=random --coverage-clover coverage.xml
- run: composer test -- --colors=always --order-by=random

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.idea .idea
/.env .env
vendor

27
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PHPyh\CodingStandard\PhpCsFixerCodingStandard;
$finder = Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->append([
__FILE__,
])
->notPath([
'benchmark.php',
]);
$config = (new Config())
->setFinder($finder)
->setCacheFile(__DIR__ . '/var/.php-cs-fixer.cache');
(new PhpCsFixerCodingStandard())->applyTo($config);
return $config;

View File

@@ -1,4 +1,6 @@
FROM rosven9856/php:8.3.10-1 ARG PHP_VERSION=8.3.10-1
FROM rosven9856/php:$PHP_VERSION
RUN addgroup -g 1000 --system php RUN addgroup -g 1000 --system php
RUN adduser -G php --system -D -s /bin/sh -u 1000 php RUN adduser -G php --system -D -s /bin/sh -u 1000 php
@@ -6,17 +8,16 @@ RUN adduser -G php --system -D -s /bin/sh -u 1000 php
RUN chown php:php /home/php RUN chown php:php /home/php
RUN chown php:php /usr/local/bin/composer RUN chown php:php /usr/local/bin/composer
RUN mkdir /var/src RUN mkdir /usr/bin/app
RUN chown -R php:php /var/src RUN chown -R php:php /usr/bin/app
WORKDIR /var/src COPY . /usr/bin/app
WORKDIR /usr/bin/app
COPY ./src /var/src
RUN composer install RUN composer install
VOLUME ["/usr/bin/app"]
USER php USER php
COPY entrypoint.sh /entrypoint.sh CMD ["php", "-f", "/usr/bin/app/app.php"]
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -19,4 +19,23 @@ This action will update the package version in the Gitea system using the API an
gitea_access_token: "${{ secrets._GITEA_ACCESS_TOKEN }}" gitea_access_token: "${{ secrets._GITEA_ACCESS_TOKEN }}"
gitea_owner: "owner" gitea_owner: "owner"
gitea_repository: "repository" gitea_repository: "repository"
gitea_package_registry: "composer" gitea_package_registry: "composer"
```
## Developing
build
```shell
docker build . --build-arg=PHP_VERSION=8.3.10-1 -t=gitea-package-action
```
initialization
```shell
docker run --rm -e GITHUB_WORKSPACE=/usr/bin/app -v .:/usr/bin/app gitea-package-action composer install
```
running
```shell
docker run --rm -e GITHUB_WORKSPACE=/usr/bin/app -v .:/usr/bin/app gitea-package-action php app.php
```

12
action.Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
ARG PHP_VERSION=8.3.10-1
FROM rosven9856/php:$PHP_VERSION
COPY . /usr/bin/app
WORKDIR /usr/bin/app
RUN composer install
VOLUME ["/usr/bin/app"]
ENTRYPOINT ["php", "-f", "/usr/bin/app/app.php"]

View File

@@ -18,7 +18,7 @@ inputs:
required: true required: true
runs: runs:
using: "docker" using: "docker"
image: "Dockerfile" image: "action.Dockerfile"
args: args:
- ${{ inputs.gitea_instance_base_url }} - ${{ inputs.gitea_instance_base_url }}
- ${{ inputs.gitea_access_token }} - ${{ inputs.gitea_access_token }}
@@ -27,4 +27,4 @@ runs:
- ${{ inputs.gitea_package_registry }} - ${{ inputs.gitea_package_registry }}
branding: branding:
icon: 'package' icon: 'package'
color: 'green' color: 'green'

View File

@@ -1,19 +0,0 @@
services:
php-fpm:
container_name: php-fpm
build:
context: ./
dockerfile: Dockerfile
environment:
gitea_instance_base_url: ${GITEA_INSTANCE_BASE_URL}
gitea_access_token: ${GITEA_ACCESS_TOKEN}
gitea_owner: ${GITEA_OWNER}
gitea_repository: ${GITEA_REPOSITORY}
gitea_package_registry: ${GITEA_PACKAGE_REGISTRY}
volumes:
- ./src:/var/src
networks:
- bridge
networks:
bridge:
driver: bridge

View File

@@ -0,0 +1,16 @@
{
"symbol-whitelist" : [],
"php-core-extensions" : [
"Core",
"date",
"json",
"hash",
"pcre",
"Phar",
"Reflection",
"SPL",
"random",
"standard"
],
"scan-files" : []
}

52
composer.json Normal file
View File

@@ -0,0 +1,52 @@
{
"name": "rosven9856/gitea-package-action",
"description": "",
"license": "MIT",
"authors": [
{
"name": "rosven9856",
"email": "rosven9856@gmail.com"
}
],
"require": {
"php": "^8.3",
"ext-curl": "*"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"friendsofphp/php-cs-fixer": "^3.57",
"icanhazstring/composer-unused": "^0.8.11",
"maglnet/composer-require-checker": "^4.11",
"phpunit/phpunit": "^10.4.2",
"phpyh/coding-standard": "^2.6",
"psalm/plugin-phpunit": "^0.18.4",
"rector/rector": "^1.1",
"vimeo/psalm": "^5.24"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "tests/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"infection/extension-installer": true
},
"sort-packages": true
},
"scripts": {
"fixcs": "php-cs-fixer fix --diff --verbose",
"infection": "infection --threads=max --show-mutations",
"psalm": "psalm --show-info=true --no-diff",
"rector": "rector process",
"require-checker": "composer-require-checker check --config-file=composer-require-checker.json composer.json",
"test": "phpunit",
"unused": "composer-unused"
}
}

7045
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
#!/bin/sh
php /var/src/app.php

27
phpunit.xml.dist Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory="var/phpunit"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>

75
psalm.xml.dist Normal file
View File

@@ -0,0 +1,75 @@
<?xml version="1.0"?>
<psalm
cacheDirectory="var/psalm"
checkForThrowsDocblock="true"
checkForThrowsInGlobalScope="true"
disableSuppressAll="true"
ensureArrayStringOffsetsExist="true"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedPsalmSuppress="true"
findUnusedVariablesAndParams="true"
memoizeMethodCallResults="true"
reportMixedIssues="true"
sealAllMethods="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<enableExtensions>
<extension name="dom"/>
</enableExtensions>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<projectFiles>
<file name="app.php"/>
<directory name="src"/>
<directory name="tests"/>
<ignoreFiles>
<directory name="var"/>
<directory name="vendor"/>
<file name="tests/benchmark.php"/>
</ignoreFiles>
</projectFiles>
<ignoreExceptions>
<classAndDescendants name="LogicException"/>
<classAndDescendants name="RuntimeException"/>
<classAndDescendants name="ReflectionException"/>
</ignoreExceptions>
<issueHandlers>
<MissingThrowsDocblock>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</MissingThrowsDocblock>
<MixedAssignment errorLevel="suppress"/>
<PossiblyUnusedMethod>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</PossiblyUnusedMethod>
<UnusedMethodCall>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</UnusedMethodCall>
</issueHandlers>
<forbiddenFunctions>
<function name="dd"/>
<function name="die"/>
<function name="dump"/>
<function name="echo"/>
<function name="eval"/>
<function name="exit"/>
<function name="print"/>
<function name="sleep"/>
<function name="usleep"/>
</forbiddenFunctions>
</psalm>

20
rector.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\DowngradeLevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->cacheDirectory(__DIR__ . '/var/rector');
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_83,
// DowngradeLevelSetList::DOWN_TO_PHP_81,
]);
};

View File

@@ -1,5 +1,7 @@
<?php <?php
exit('++++');
\define('RED', "\033[0;31m"); \define('RED', "\033[0;31m");
\define('GREEN', "\033[1;32m"); \define('GREEN', "\033[1;32m");
\define('YELLOW', "\033[1;33m"); \define('YELLOW', "\033[1;33m");
@@ -222,4 +224,4 @@ try {
} }
showTerminalMessage("\r\n"); showTerminalMessage("\r\n");
showTerminalMessage('SUCCESS!', GREEN); showTerminalMessage('SUCCESS!', GREEN);

View File

@@ -1,5 +0,0 @@
{
"require": {
"ext-curl": "*"
}
}

2
var/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore