WIP
This commit is contained in:
Binary file not shown.
221
.github/workflows/main.yaml
vendored
221
.github/workflows/main.yaml
vendored
@@ -1,221 +0,0 @@
|
|||||||
name: Telegram Mini App Shop Builder
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- 'issue/**'
|
|
||||||
- develop
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
version_meta:
|
|
||||||
name: Compute version metadata
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
tag: ${{ steps.meta.outputs.tag }}
|
|
||||||
filename: ${{ steps.meta.outputs.filename }}
|
|
||||||
is_release: ${{ steps.meta.outputs.is_release }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Extract tag and set filename
|
|
||||||
id: meta
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
RELEASE_TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)
|
|
||||||
|
|
||||||
if [ -n "$RELEASE_TAG" ]; then
|
|
||||||
echo "Это полноценный релиз"
|
|
||||||
TAG="$RELEASE_TAG"
|
|
||||||
FILENAME="oc_telegram_shop_${TAG}.ocmod.zip"
|
|
||||||
IS_RELEASE=true
|
|
||||||
else
|
|
||||||
echo "Это dev-сборка"
|
|
||||||
LAST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)
|
|
||||||
[ -z "$LAST_TAG" ] && LAST_TAG="v0.0.0"
|
|
||||||
SHORT_SHA=$(git rev-parse --short=7 HEAD)
|
|
||||||
DATE=$(date +%Y%m%d%H%M)
|
|
||||||
TAG="${LAST_TAG}-dev.${DATE}+${SHORT_SHA}"
|
|
||||||
FILENAME="oc_telegram_shop_${TAG}.ocmod.zip"
|
|
||||||
IS_RELEASE=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "is_release=$IS_RELEASE" >> $GITHUB_OUTPUT
|
|
||||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
||||||
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
test_frontend:
|
|
||||||
name: Run Frontend tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v6
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
working-directory: frontend/spa
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
working-directory: frontend/spa
|
|
||||||
env:
|
|
||||||
APP_ENV: testing
|
|
||||||
run: npm run test
|
|
||||||
|
|
||||||
test_backend:
|
|
||||||
name: Run Backend tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup PHP 7.4
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '7.4'
|
|
||||||
tools: composer
|
|
||||||
extensions: mbstring
|
|
||||||
|
|
||||||
- name: Install Composer dependencies
|
|
||||||
working-directory: module/oc_telegram_shop/upload/oc_telegram_shop
|
|
||||||
run: composer install --no-progress --no-interaction
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
working-directory: module/oc_telegram_shop/upload/oc_telegram_shop
|
|
||||||
env:
|
|
||||||
APP_ENV: testing
|
|
||||||
run: ./vendor/bin/phpunit --testdox tests/Unit tests/Telegram
|
|
||||||
|
|
||||||
- name: Static Analyzer
|
|
||||||
working-directory: module/oc_telegram_shop/upload/oc_telegram_shop
|
|
||||||
run: ./vendor/bin/phpstan analyse
|
|
||||||
|
|
||||||
phpcs:
|
|
||||||
name: Run PHP_CodeSniffer
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup PHP 7.4
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '7.4'
|
|
||||||
tools: phpcs
|
|
||||||
|
|
||||||
- name: Run PHP_CodeSniffer
|
|
||||||
working-directory: module/oc_telegram_shop/upload/oc_telegram_shop
|
|
||||||
run: phpcs --standard=PSR12 bastion framework src
|
|
||||||
|
|
||||||
module-build:
|
|
||||||
name: Build module.
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: version_meta
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v6
|
|
||||||
|
|
||||||
- name: Setup PHP 7.4
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '7.4'
|
|
||||||
tools: composer
|
|
||||||
|
|
||||||
- name: Write version.txt
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
MODULE_ROOT="module/oc_telegram_shop/upload/oc_telegram_shop"
|
|
||||||
echo "${{ needs.version_meta.outputs.tag }}" > "${MODULE_ROOT}/version.txt"
|
|
||||||
|
|
||||||
- name: Build module
|
|
||||||
run: |
|
|
||||||
bash scripts/ci/build.sh "${GITHUB_WORKSPACE}"
|
|
||||||
|
|
||||||
- name: Upload build artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: oc_telegram_shop.ocmod.zip
|
|
||||||
path: ./build/oc_telegram_shop.ocmod.zip
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [ version_meta, test_frontend, test_backend, module-build ]
|
|
||||||
if: github.ref == 'refs/heads/master' || github.event_name == 'pull_request'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download build artifact
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: oc_telegram_shop.ocmod.zip
|
|
||||||
path: ./build
|
|
||||||
|
|
||||||
- name: Rename artifact file
|
|
||||||
run: mv ./build/oc_telegram_shop.ocmod.zip ./build/${{ needs.version_meta.outputs.filename }}
|
|
||||||
|
|
||||||
- name: Delete existing GitHub release and tag
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
TAG=${{ needs.version_meta.outputs.tag }}
|
|
||||||
echo "⛔ Deleting existing release and tag (if any): $TAG"
|
|
||||||
gh release delete "$TAG" --cleanup-tag --yes || true
|
|
||||||
git push origin ":refs/tags/$TAG" || true
|
|
||||||
|
|
||||||
- name: Create GitHub Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
draft: ${{ needs.version_meta.outputs.is_release == 'false' }}
|
|
||||||
tag_name: ${{ needs.version_meta.outputs.tag }}
|
|
||||||
files: ./build/${{ needs.version_meta.outputs.filename }}
|
|
||||||
generate_release_notes: true
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Delete draft releases older than 7 days
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
const daysToKeep = 7;
|
|
||||||
const cutoffDate = new Date(Date.now() - daysToKeep * 24 * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
const releases = await github.rest.repos.listReleases({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
per_page: 100
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const release of releases.data) {
|
|
||||||
if (release.draft) {
|
|
||||||
const created = new Date(release.created_at);
|
|
||||||
if (created < cutoffDate) {
|
|
||||||
console.log(`Deleting draft release: ${release.name || release.tag_name} (${release.id})`);
|
|
||||||
await github.rest.repos.deleteRelease({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: release.id
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
await github.rest.git.deleteRef({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
ref: `tags/${release.tag_name}`
|
|
||||||
});
|
|
||||||
console.log(`Deleted tag: ${release.tag_name}`);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(`Tag ${release.tag_name} not found or already deleted.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -79,7 +79,6 @@ $items = Arr::mergeArraysRecursively($json, [
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create logger
|
|
||||||
$logger = new Logger('TeleCart_CLI', [], [], new DateTimeZone('UTC'));
|
$logger = new Logger('TeleCart_CLI', [], [], new DateTimeZone('UTC'));
|
||||||
$logger->pushHandler(
|
$logger->pushHandler(
|
||||||
new RotatingFileHandler(
|
new RotatingFileHandler(
|
||||||
@@ -87,12 +86,10 @@ $logger->pushHandler(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Creates TeleCart application.
|
|
||||||
$app = ApplicationFactory::create($items);
|
$app = ApplicationFactory::create($items);
|
||||||
$app->setLogger($logger);
|
$app->setLogger($logger);
|
||||||
$app->boot();
|
$app->boot();
|
||||||
|
|
||||||
// Creates Console and bind commands.
|
|
||||||
$console = new Application('TeleCart', module_version());
|
$console = new Application('TeleCart', module_version());
|
||||||
$console->add($app->get(VersionCommand::class));
|
$console->add($app->get(VersionCommand::class));
|
||||||
$console->add($app->get(ScheduleRunCommand::class));
|
$console->add($app->get(ScheduleRunCommand::class));
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Openguru\\OpenCartFramework\\": "framework/",
|
"Openguru\\OpenCartFramework\\": "framework/",
|
||||||
"App\\": "src/",
|
"App\\": "app/",
|
||||||
"Bastion\\": "bastion/",
|
"Bastion\\": "bastion/",
|
||||||
"Console\\": "console/",
|
"Console\\": "console/",
|
||||||
"Tests\\": "tests/"
|
"Tests\\": "tests/"
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user