Skip to content

Commit

Permalink
Added GHA for Database, Build, Test and Deploy.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Sep 9, 2024
1 parent 41925f2 commit 278992b
Show file tree
Hide file tree
Showing 17 changed files with 812 additions and 106 deletions.
381 changes: 365 additions & 16 deletions .github/workflows/build-test-deploy.yml

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions .github/workflows/vortex-test-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: drevops/ci-runner:latest
image: drevops/ci-runner:24.9.0
env:
# Prevent GitHub overriding the Docker config.
DOCKER_CONFIG: /root/.docker
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
batch: [0, 1, 2]

container:
image: drevops/ci-runner:latest
image: drevops/ci-runner:24.9.0
env:
# Prevent GitHub overriding the Docker config.
DOCKER_CONFIG: /root/.docker
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
batch: [0, 1]

container:
image: drevops/ci-runner:latest
image: drevops/ci-runner:24.9.0
env:
# Prevent GitHub overriding the Docker config.
DOCKER_CONFIG: /root/.docker
Expand Down Expand Up @@ -179,6 +179,7 @@ jobs:
- name: Run tests
run: ./tests/test.deployment.sh
working-directory: .vortex
timeout-minutes: 10

- name: Upload coverage report as an artifact
uses: actions/upload-artifact@v4
Expand Down
Binary file modified .vortex/docs/static/img/diagram-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .vortex/docs/static/img/diagram-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions .vortex/installer/src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ protected function replaceTokens() {
'database_download_source',
'database_image',
'override_existing_db',
'ci_provider',
'deploy_type',
'preserve_acquia',
'preserve_lagoon',
Expand Down Expand Up @@ -415,6 +416,46 @@ protected function processOverrideExistingDb(string $dir) {
}
}

protected function processCiProvider(string $dir) {
$type = $this->getAnswer('ci_provider');

$remove_gha = FALSE;
$remove_circleci = FALSE;

switch ($type) {
case 'CircleCI':
$remove_gha = TRUE;
break;

case 'GitHub Actions':
$remove_circleci = TRUE;
break;

default:
$remove_circleci = TRUE;
$remove_gha = TRUE;
}

if ($remove_gha) {
@unlink($dir . '/.github/workflows/build-test-deploy.yml');
$this->removeTokenWithContent('CI_PROVIDER_GHA', $dir);
}

if ($remove_circleci) {
static::rmdirRecursive($dir . '/.circleci');
@unlink($dir . '/tests/phpunit/CircleCiConfigTest.php');
$this->removeTokenWithContent('CI_PROVIDER_CIRCLECI', $dir);
}

if ($remove_gha && $remove_circleci) {
@unlink($dir . '/docs/ci.md');
$this->removeTokenWithContent('CI_PROVIDER_ANY', $dir);
}
else {
$this->removeTokenWithContent('!CI_PROVIDER_ANY', $dir);
}
}

protected function processDeployType(string $dir) {
$type = $this->getAnswer('deploy_type');
if ($type != 'none') {
Expand Down Expand Up @@ -762,6 +803,8 @@ protected function collectAnswers() {

$this->askForAnswer('override_existing_db', 'Do you want to override existing database in the environment?');

$this->askForAnswer('ci_provider', 'Which provider do you want to use for CI ([c]ircleci, [g]ithub actions, [n]one)?');

$this->askForAnswer('deploy_type', 'How do you deploy your code to the hosting ([w]ebhook call, [c]ode artifact, [d]ocker image, [l]agoon, [n]one as a comma-separated list)?');

if ($this->getAnswer('database_download_source') != 'ftp') {
Expand Down Expand Up @@ -1059,6 +1102,10 @@ protected function getDefaultValueOverrideExistingDb(): string {
return self::ANSWER_NO;
}

protected function getDefaultValueCiProvider(): string {
return 'GitHub Actions';
}

protected function getDefaultValueDeployType(): string {
return 'artifact';
}
Expand Down Expand Up @@ -1294,6 +1341,18 @@ protected function discoverValueOverrideExistingDb(): string {
return $this->getValueFromDstDotenv('VORTEX_PROVISION_OVERRIDE_DB') ? self::ANSWER_YES : self::ANSWER_NO;
}

protected function discoverValueCiProvider() {
if (is_readable($this->getDstDir() . '/.github/workflows/build-test-deploy.yml')) {
return 'GitHub Actions';
}

if (is_readable($this->getDstDir() . '/.circleci/config.yml')) {
return 'CircleCI';
}

return $this->isInstalled() ? 'none' : NULL;
}

protected function discoverValueDeployType() {
return $this->getValueFromDstDotenv('VORTEX_DEPLOY_TYPES');
}
Expand Down Expand Up @@ -1501,6 +1560,23 @@ protected function normaliseAnswerOverrideExistingDb($value): string {
return strtolower((string) $value) !== self::ANSWER_YES ? self::ANSWER_NO : self::ANSWER_YES;
}

protected function normaliseAnswerCiProvider($value): string {
$value = trim(strtolower((string) $value));

switch ($value) {
case 'c':
case 'circleci':
return 'CircleCI';

case 'g':
case 'gha':
case 'github actions':
return 'GitHub Actions';
}

return 'none';
}

protected function normaliseAnswerDeployType($value): ?string {
$types = explode(',', (string) $value);

Expand Down Expand Up @@ -1669,6 +1745,7 @@ protected function printSummary() {
}

$values['Override existing database'] = $this->formatYesNo($this->getAnswer('override_existing_db'));
$values['CI provider'] = $this->formatNotEmpty($this->getAnswer('ci_provider'), 'None');
$values['Deployment'] = $this->formatNotEmpty($this->getAnswer('deploy_type'), 'Disabled');
$values['FTP integration'] = $this->formatEnabled($this->getAnswer('preserve_ftp'));
$values['Acquia integration'] = $this->formatEnabled($this->getAnswer('preserve_acquia'));
Expand Down
Loading

1 comment on commit 278992b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.