Skip to content

Commit

Permalink
Add migration to upgrade version commands when unset
Browse files Browse the repository at this point in the history
Contents based on the values in the DefaultData/LanguageFixture.
  • Loading branch information
vmcj committed May 19, 2024
1 parent 1361ca7 commit d074fff
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 5 deletions.
82 changes: 82 additions & 0 deletions webapp/migrations/Version20240511091916.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240511091916 extends AbstractMigration
{
private const COMPILER_VERSION_COMMAND = ['adb'=> 'gnatmake --version',
'awk'=> 'awk --version',
'bash'=> 'bash --version',
'c' => 'gcc --version',
'cpp' => 'g++ --version',
'csharp' => 'mcs --version',
'f95' => 'gfortran --version',
'hs' => 'ghc --version',
'java' => 'javac --version',
'js' => 'nodejs --version',
'kt' => 'kotlinc --version',
'lua' => 'luac -v',
'pas' => 'fpc -iW',
'pl' => 'perl -v',
'plg' => 'swipl --version',
'py3' => 'pypy3 --version',
'ocaml' => 'ocamlopt --version',
'r' => 'Rscript --version',
'rb' => 'ruby --version',
'rs' => 'rustc --version',
'scala' => 'scalac --version',
'sh' => 'md5sum /bin/sh',
'swift' => 'swiftc --version'];

private const RUNNER_VERSION_COMMAND = ['awk'=> 'awk --version',
'bash'=> 'bash --version',
'csharp' => 'mono --version',
'java' => 'java --version',
'js' => 'nodejs --version',
'kt' => 'kotlin --version',
'lua' => 'lua -v',
'pl' => 'perl -v',
'py3' => 'pypy3 --version',
'r' => 'Rscript --version',
'rb' => 'ruby --version',
'scala' => 'scala --version',
'sh' => 'md5sum /bin/sh'];

public function getDescription(): string
{
return 'Fill default version command for compiler/runner.';
}

public function up(Schema $schema): void
{
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET compiler_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND compiler_version_command IS NULL;");
}
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET runner_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND runner_version_command IS NULL;");
}
}

public function down(Schema $schema): void
{
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET compiler_version_command = NULL WHERE langid='" . $lang . "' AND compiler_version_command = '" . $versionCommand ."';");
}
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
$this->addSql("UPDATE language SET runner_version_command = NULL WHERE langid='" . $lang . "' AND runner_version_command = '" . $versionCommand ."';");
}
}

public function isTransactional(): bool
{
return false;
}
}
10 changes: 5 additions & 5 deletions webapp/src/DataFixtures/DefaultData/LanguageFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ public function load(ObjectManager $manager): void
// ID external ID name extensions require entry point allow allow time compile compiler version runner version
// entry point description submit judge factor script command command
['adb', 'ada', 'Ada', ['adb', 'ads'], false, null, false, true, 1, 'adb', 'gnatmake --version', ''],
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', ''],
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --version', ''],
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', 'awk --version'],
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --version', 'bash --version'],
['c', 'c', 'C', ['c'], false, null, true, true, 1, 'c', 'gcc --version', ''],
['cpp', 'cpp', 'C++', ['cpp', 'cc', 'cxx', 'c++'], false, null, true, true, 1, 'cpp', 'g++ --version', ''],
['csharp', 'csharp', 'C#', ['csharp', 'cs'], false, null, false, true, 1, 'csharp', 'mcs --version', 'mono --version'],
['f95', 'f95', 'Fortran', ['f95', 'f90'], false, null, false, true, 1, 'f95', 'gfortran --version', ''],
['hs', 'haskell', 'Haskell', ['hs', 'lhs'], false, null, false, true, 1, 'hs', 'ghc --version', ''],
['java', 'java', 'Java', ['java'], false, 'Main class', true, true, 1, 'java_javac_detect', 'javac -version', 'java -version'],
['js', 'javascript', 'JavaScript', ['js'], false, 'Main file', false, true, 1, 'js', 'nodejs --version', 'nodejs --version'],
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', ''],
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', 'lua -v'],
['kt', 'kotlin', 'Kotlin', ['kt'], true, 'Main class', false, true, 1, 'kt', 'kotlinc -version', 'kotlin -version'],
['pas', 'pascal', 'Pascal', ['pas', 'p'], false, 'Main file', false, true, 1, 'pas', 'fpc -iW', ''],
['pl', 'pl', 'Perl', ['pl'], false, 'Main file', false, true, 1, 'pl', 'perl -v', 'perl -v'],
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', 'swipl --version', 'swipl --version'],
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', 'swipl --version', ''],
['py3', 'python3', 'Python 3', ['py'], false, 'Main file', true, true, 1, 'py3', 'pypy3 --version', 'pypy3 --version'],
['ocaml', 'ocaml', 'OCaml', ['ml'], false, null, false, true, 1, 'ocaml', 'ocamlopt --version', ''],
['r', 'r', 'R', ['R'], false, 'Main file', false, true, 1, 'r', 'Rscript --version', 'Rscript --version'],
['rb', 'ruby', 'Ruby', ['rb'], false, 'Main file', false, true, 1, 'rb', 'ruby --version', 'ruby --version'],
['rs', 'rust', 'Rust', ['rs'], false, null, false, true, 1, 'rs', 'rustc --version', ''],
['scala', 'scala', 'Scala', ['scala'], false, null, false, true, 1, 'scala', 'scalac -version', 'scala -version'],
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', 'md5sum /bin/sh', ''],
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', 'md5sum /bin/sh', 'md5sum /bin/sh'],
['swift', 'swift', 'Swift', ['swift'], false, 'Main file', false, true, 1, 'swift', 'swiftc --version', ''],
];

Expand Down

0 comments on commit d074fff

Please sign in to comment.