Skip to content

Commit

Permalink
feat(debug): add action to download logs (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine authored Oct 23, 2024
1 parent 68290ae commit a421c52
Show file tree
Hide file tree
Showing 42 changed files with 804 additions and 89 deletions.
5 changes: 5 additions & 0 deletions .env.local.template → .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
API_KEY_MYPARCEL=
API_KEY_BELGIE=
API_KEY_FLESPAKKET=

###
# Docker image
###
IMAGE_NAME=ghcr.io/myparcelnl/pdk
20 changes: 14 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ name: 'Setup'
description: ''

inputs:
token:
description: 'GitHub token'
required: true

php-version:
description: 'PHP version'
required: true

runs:
using: composite
steps:
- uses: myparcelnl/actions/build-docker-image-reg@v4
id: build
with:
registry-password: ${{ inputs.token }}

- name: 'Handle composer cache'
uses: actions/cache@v4
with:
Expand All @@ -22,22 +31,21 @@ runs:
composer-${{ hashFiles('**/composer.json') }}-
composer-
- uses: myparcelnl/actions/pull-docker-image@v4
with:
image: 'ghcr.io/myparcelnl/php-xd:${{ inputs.php-version }}-cli-alpine'

- name: 'Prepare environment'
shell: bash
#language=bash
run: |
touch .env.local
touch .env
echo "COMPOSER_HOME=/root/.composer" >> .env
echo "COMPOSER_MEMORY_LIMIT=-1" >> .env
- name: 'Install composer dependencies'
shell: bash
env:
IMAGE_NAME: ${{ steps.build.outputs.tagged-image }}
#language=bash
run: |
docker compose run \
--volume $HOME/.composer:/root/.composer \
--env COMPOSER_CACHE_DIR=/root/.composer \
php \
composer update --no-progress --no-scripts --no-plugins
1 change: 1 addition & 0 deletions .github/workflows/--analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- uses: ./.github/actions/setup
if: steps.phpstan-cache.outputs.cache-hit != 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ vars.PHP_VERSION }}

- name: 'Run PHPStan analysis'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/--quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- uses: ./.github/actions/setup
if: steps.rector-cache.outputs.cache-hit != 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ vars.PHP_VERSION }}

- name: 'Run quality checks in dry-run mode'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/--setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ jobs:

- uses: ./.github/actions/setup
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ vars.PHP_VERSION }}
1 change: 1 addition & 0 deletions .github/workflows/--test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:

- uses: ./.github/actions/setup
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ vars.PHP_VERSION }}

- name: 'Run integration tests'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/--test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- uses: ./.github/actions/setup
if: steps.coverage-cache.outputs.cache-hit != 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ vars.PHP_VERSION }}

- name: 'Run unit tests'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ composer.lock
clover.xml

docker-compose.override.yml
.env.local
.env

/.cache/
/.nx/
Expand Down
41 changes: 7 additions & 34 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ghcr.io/myparcelnl/php-xd:7.4-fpm-alpine

# install php zip extension
RUN apk add --no-cache libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip \
&& docker-php-ext-enable zip
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ View our [contribution guidelines] for information on how to contribute to the P

### Installation

Create `.env.local`:
Create `.env`:

```shell
cp .env.local.template .env.local
cp .env.template .env
```

Install Yarn dependencies:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"homepage": "https://myparcel.nl",
"license": "MIT",
"require": {
"ext-zip": "*",
"justinrainbow/json-schema": "^5.2",
"myparcelnl/sdk": ">= 7",
"php": ">=7.1.0",
Expand Down Expand Up @@ -71,4 +72,4 @@
"pestphp/pest-plugin": true
}
}
}
}
10 changes: 10 additions & 0 deletions config/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MyParcelNL\Pdk\App\Action\Backend\Account\DeleteAccountAction;
use MyParcelNL\Pdk\App\Action\Backend\Account\UpdateAccountAction;
use MyParcelNL\Pdk\App\Action\Backend\Account\UpdateSubscriptionFeaturesAction;
use MyParcelNL\Pdk\App\Action\Backend\Debug\DownloadLogsAction;
use MyParcelNL\Pdk\App\Action\Backend\Order\ExportOrderAction;
use MyParcelNL\Pdk\App\Action\Backend\Order\FetchOrdersAction;
use MyParcelNL\Pdk\App\Action\Backend\Order\PostOrderNotesAction;
Expand All @@ -31,6 +32,7 @@
use MyParcelNL\Pdk\App\Request\Account\UpdateAccountEndpointRequest;
use MyParcelNL\Pdk\App\Request\Account\UpdateSubscriptionFeaturesEndpointRequest;
use MyParcelNL\Pdk\App\Request\Context\FetchContextEndpointRequest;
use MyParcelNL\Pdk\App\Request\Debug\DownloadLogsEndpointRequest;
use MyParcelNL\Pdk\App\Request\Orders\ExportOrdersEndpointRequest;
use MyParcelNL\Pdk\App\Request\Orders\FetchOrdersEndpointRequest;
use MyParcelNL\Pdk\App\Request\Orders\PostOrderNotesEndpointRequest;
Expand Down Expand Up @@ -215,5 +217,13 @@
'request' => FetchWebhooksEndpointRequest::class,
'action' => FetchWebhooksAction::class,
],

/**
* Download logs
*/
PdkBackendActions::DOWNLOAD_LOGS => [
'request' => DownloadLogsEndpointRequest::class,
'action' => DownloadLogsAction::class,
],
],
];
7 changes: 7 additions & 0 deletions config/pdk-services.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
use MyParcelNL\Pdk\Base\Contract\CountryServiceInterface;
use MyParcelNL\Pdk\Base\Contract\CurrencyServiceInterface;
use MyParcelNL\Pdk\Base\Contract\WeightServiceInterface;
use MyParcelNL\Pdk\Base\Contract\ZipServiceInterface;
use MyParcelNL\Pdk\Base\FileSystem;
use MyParcelNL\Pdk\Base\FileSystemInterface;
use MyParcelNL\Pdk\Base\Pdk;
use MyParcelNL\Pdk\Base\Service\CountryService;
use MyParcelNL\Pdk\Base\Service\CurrencyService;
use MyParcelNL\Pdk\Base\Service\WeightService;
use MyParcelNL\Pdk\Base\Service\ZipService;
use MyParcelNL\Pdk\Carrier\Contract\CarrierRepositoryInterface;
use MyParcelNL\Pdk\Carrier\Repository\CarrierRepository;
use MyParcelNL\Pdk\Context\Contract\ContextServiceInterface;
Expand Down Expand Up @@ -215,4 +217,9 @@
* Handles executing webhooks.
*/
PdkWebhookManagerInterface::class => autowire(PdkWebhookManager::class),

/**
* Handles zipping files.
*/
ZipServiceInterface::class => autowire(ZipService::class),
];
1 change: 1 addition & 0 deletions config/platform/belgie.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'name' => 'belgie',
'human' => 'SendMyParcel',
'backofficeUrl' => 'https://backoffice.sendmyparcel.be',
'supportUrl' => 'https://developer.myparcel.nl/contact',
'localCountry' => CountryCodes::CC_BE,
'defaultCarrier' => Carrier::CARRIER_BPOST_NAME,
'defaultCarrierId' => Carrier::CARRIER_BPOST_ID,
Expand Down
1 change: 1 addition & 0 deletions config/platform/flespakket.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'name' => 'flespakket',
'human' => 'Flespakket',
'backofficeUrl' => 'https://backoffice.flespakket.nl',
'supportUrl' => 'https://developer.myparcel.nl/contact',
'localCountry' => CountryCodes::CC_NL,
'defaultCarrier' => Carrier::CARRIER_POSTNL_NAME,
'defaultCarrierId' => Carrier::CARRIER_POSTNL_ID,
Expand Down
1 change: 1 addition & 0 deletions config/platform/myparcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'name' => 'myparcel',
'human' => 'MyParcel',
'backofficeUrl' => 'https://backoffice.myparcel.nl',
'supportUrl' => 'https://developer.myparcel.nl/contact',
'localCountry' => CountryCodes::CC_NL,
'defaultCarrier' => Carrier::CARRIER_POSTNL_NAME,
'defaultCarrierId' => Carrier::CARRIER_POSTNL_ID,
Expand Down
17 changes: 11 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
x-image: &image ghcr.io/myparcelnl/php-xd:7.4-cli-alpine
x-common: &common
build:
context: .
dockerfile: Dockerfile
# Set in .env
image: $IMAGE_NAME

services:
php:
image: *image
command: ['composer', 'install', '--no-interaction', '--no-progress', '--no-suggest']
<<: *common
init: true
command: ['composer', 'install', '--no-interaction', '--no-progress']
env_file:
- .env.local
- .env
volumes:
- ./:/app

console:
image: *image
command: []
<<: *common
init: true
command: []
entrypoint: ['php', 'bin/console']
volumes:
- ./:/app
Loading

0 comments on commit a421c52

Please sign in to comment.