-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from mittwald/task/functionaltests
Add CI pipelines for testing the actual deployment functionality
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Functional testing | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: {} | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
max-parallel: 1 | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['8.2', '8.3'] | ||
deployer-version: ['7.3'] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: 'git/mittwald-recipe' | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: mbstring, intl, json | ||
coverage: pcov | ||
|
||
- name: Setup test project with composer | ||
run: | | ||
composer init --name mittwald/deployer-recipes-test --type project --repository '{"type":"path","url":"git/mittwald-recipe"}' | ||
composer require --dev 'deployer/deployer:${{ matrix.deployer-version }}.*' | ||
composer require --dev mittwald/deployer-recipes:dev-${GITHUB_SHA} | ||
cp git/mittwald-recipe/functionaltest/deploy.php deploy.php | ||
- name: Deploy testing SSH key | ||
run: | | ||
mkdir ~/.ssh | ||
echo -n "${MITTWALD_SSH_PRIVATE_KEY}" | base64 -d > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub | ||
env: | ||
MITTWALD_SSH_PRIVATE_KEY: ${{ secrets.MITTWALD_SSH_PRIVATE_KEY }} | ||
|
||
- name: Generate unique test file | ||
run: | | ||
openssl rand -hex 32 > testing.txt | ||
- name: Run test deployment | ||
run: | | ||
./vendor/bin/dep deploy -vvv | ||
env: | ||
MITTWALD_APP_ID: ${{ secrets.MITTWALD_APP_ID }} | ||
MITTWALD_APP_DOMAIN: ${{ secrets.MITTWALD_APP_DOMAIN }} | ||
MITTWALD_API_TOKEN: ${{ secrets.MITTWALD_API_TOKEN }} | ||
|
||
- name: Assert deployment was successful | ||
run: | | ||
deployed=$(curl -f -s https://${MITTWALD_APP_DOMAIN}/testing.txt) | ||
expected=$(< testing.txt) | ||
echo "::debug::got output: ${deployed}" | ||
echo "::debug::expected: ${expected}" | ||
test "${deployed}" = "${expected}" | ||
env: | ||
MITTWALD_APP_DOMAIN: ${{ secrets.MITTWALD_APP_DOMAIN }} |
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,33 @@ | ||
<?php | ||
|
||
namespace Deployer; | ||
|
||
require 'recipe/common.php'; | ||
require 'contrib/rsync.php'; | ||
require __DIR__ . '/vendor/autoload.php'; | ||
require __DIR__ . '/vendor/mittwald/deployer-recipes/recipes/deploy.php'; | ||
|
||
// Config | ||
|
||
set('rsync_src', __DIR__); | ||
set('php_version', '8.2'); | ||
set('domain', getenv("MITTWALD_APP_DOMAIN")); | ||
|
||
// Hosts | ||
|
||
mittwald_app(getenv("MITTWALD_APP_ID")) | ||
->set('public_path', '/'); | ||
|
||
// Hooks | ||
|
||
task('deploy:prepare', [ | ||
'deploy:info', | ||
'deploy:setup', | ||
'deploy:lock', | ||
'deploy:release', | ||
'rsync', | ||
'deploy:shared', | ||
'deploy:writable', | ||
]); | ||
|
||
after('deploy:failed', 'deploy:unlock'); |