-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
425 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,52 +58,55 @@ jobs: | |
|
||
- name: Run phpstan | ||
run: ./vendor/bin/phpstan analyse | ||
# phpunit: | ||
# permissions: | ||
# contents: read # for actions/checkout to fetch code | ||
# name: PHPUnit | ||
# runs-on: ubuntu-latest | ||
# strategy: | ||
# matrix: | ||
# php: [ '8.1', '8.2' ] | ||
# fail-fast: false | ||
# steps: | ||
# - name: Setup PHP | ||
# uses: shivammathur/setup-php@v2 | ||
# with: | ||
# php-version: ${{ matrix.php }} | ||
# extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, simplexml | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - uses: actions/checkout@v3 | ||
|
||
# - name: PrestaShop Configuration | ||
# run: cp .github/workflows/phpunit/parameters.yml app/config/parameters.yml | ||
|
||
# - name: Get Composer Cache Directory | ||
# id: composer-cache | ||
# run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
# - name: Cache Composer Directory | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: ${{ steps.composer-cache.outputs.dir }} | ||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
# restore-keys: ${{ runner.os }}-composer- | ||
|
||
# - name: Composer Install | ||
# run: composer install --ansi --prefer-dist --no-interaction --no-progress | ||
|
||
# - name: Update phpunit version | ||
# if: ${{ startsWith(matrix.php, '8.') }} | ||
# run: composer update -w --ignore-platform-reqs --no-interaction phpunit/phpunit | ||
|
||
# - name: Run phpunit | ||
# run: ./vendor/phpunit/phpunit/phpunit -c tests/Unit/phpunit.xml | ||
# env: | ||
# SYMFONY_DEPRECATIONS_HELPER: disabled | ||
|
||
# - name: Test git versionned files unchanged | ||
# if: ${{ !startsWith(matrix.php, '8.') }} # composer.lock changes when updating phpunit version | ||
# run: git diff --exit-code | ||
phpunit: | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
name: PHPUnit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup MySQL | ||
uses: mirromutth/[email protected] | ||
with: | ||
mysql version: '8.0' | ||
mysql database: 'qanightlyresults' | ||
mysql root password: 'password' | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Config | ||
run: cp .env.dist .env | ||
|
||
- name: Composer Install | ||
run: composer install --ansi --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Change MySQL authentication method | ||
run: sleep 15 && mysql -h127.0.0.1 -uroot -ppassword -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;" | ||
|
||
- name: Setup database | ||
run: php bin/console doctrine:schema:update --dump-sql --force --env=test | ||
|
||
- name: Inject data for AutoUpgrade | ||
run: | | ||
DATE=$(date -d "1 day ago" +"%Y-%m-%d") | ||
php bin/console nightly:import autoupgrade_$DATE-develop\ | ||
-p cli \ | ||
-c autoupgrade \ | ||
--env test | ||
- name: Inject data for Core | ||
run: | | ||
DATE=$(date -d "1 day ago" +"%Y-%m-%d") | ||
php bin/console nightly:import $DATE-develop\ | ||
-p chromium \ | ||
-c functional \ | ||
--env test | ||
- name: Run phpunit | ||
run: ./vendor/bin/phpunit |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use App\Service\ReportImporter; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
#[AsCommand(name: 'nightly:import')] | ||
class ImportCommand extends Command | ||
{ | ||
private ReportImporter $reportImporter; | ||
|
||
private string $nightlyGCPUrl; | ||
|
||
public function __construct(ReportImporter $reportImporter, string $nightlyGCPUrl) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->reportImporter = $reportImporter; | ||
$this->nightlyGCPUrl = $nightlyGCPUrl; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->addArgument('filename', InputArgument::REQUIRED) | ||
->addOption('platform', 'p', InputOption::VALUE_REQUIRED, '', ReportImporter::FILTER_PLATFORMS[0], ReportImporter::FILTER_PLATFORMS) | ||
->addOption('campaign', 'c', InputOption::VALUE_REQUIRED, '', ReportImporter::FILTER_CAMPAIGNS[0], ReportImporter::FILTER_CAMPAIGNS) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}-(.*)?\.json/', $input->getArgument('filename'), $matchesVersion); | ||
if (!isset($matchesVersion[1]) || strlen($matchesVersion[1]) < 1) { | ||
$output->writeln(sprintf( | ||
'<error>Version found not correct (%s) from filename %s</error>', | ||
$matchesVersion[1], | ||
$output->getArgument('filename') | ||
)); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$fileContent = @file_get_contents($this->nightlyGCPUrl . 'reports/' . $input->getArgument('filename')); | ||
if (!$fileContent) { | ||
$output->writeln('<error>Unable to retrieve content from GCP URL</error>'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$jsonContent = json_decode($fileContent); | ||
if (!$jsonContent) { | ||
$output->writeln('<error>Unable to decode JSON data</error>'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$dateformat = $input->getOption('campaign') === 'autoupgrade' | ||
? ReportImporter::FORMAT_DATE_MOCHA5 | ||
: ReportImporter::FORMAT_DATE_MOCHA6; | ||
$startDate = \DateTime::createFromFormat( | ||
$dateformat, | ||
$jsonContent->stats->start | ||
); | ||
|
||
$this->reportImporter->import( | ||
$input->getArgument('filename'), | ||
$input->getOption('platform'), | ||
$input->getOption('campaign'), | ||
$matchesVersion[1], | ||
$startDate, | ||
$jsonContent, | ||
$dateformat | ||
); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
Oops, something went wrong.