-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests via bats and Github Actions (#2)
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 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,37 @@ | ||
name: tests | ||
on: [push] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
drupal_version: ['9.3', '9.4', '9.5', '10.0', '10.1'] | ||
|
||
steps: | ||
- name: Create project | ||
run: | | ||
composer create-project --ignore-platform-reqs mstrelan/drupal-contrib:dev-${{ github.ref_name }} | ||
- name: Initialise environment | ||
run: | | ||
cd drupal-contrib | ||
make ${{ matrix.drupal_version }} | ||
- name: Setup bats | ||
run: | | ||
brew tap kaos/shell | ||
brew install bats-support bats-assert bats-file | ||
- name: Run tests | ||
env: | ||
DRUPAL_VERSION: ${{ matrix.drupal_version }} | ||
run: | | ||
cd drupal-contrib | ||
bats tests |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
setup_file() { | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
cd "$DIR/../" || exit | ||
run make composer | ||
} | ||
|
||
setup() { | ||
BREW_PREFIX="$(brew --prefix)" | ||
load "${BREW_PREFIX}/lib/bats-assert/load.bash" | ||
load "${BREW_PREFIX}/lib/bats-file/load.bash" | ||
} | ||
|
||
dce() { | ||
docker-compose exec -T php-cli "$@" | ||
} | ||
|
||
@test "Composer packages are installed" { | ||
run dce composer show --direct -N | ||
assert_output --partial "drupal/core" | ||
} | ||
|
||
@test "Composer files are scaffolded" { | ||
assert_file_exist 'app/vendor/autoload.php' | ||
assert_file_exist 'app/sites/default/settings.php' | ||
assert_file_exist 'app/.git/info/exclude' | ||
} |
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,40 @@ | ||
DRUPAL_VERSION="${DRUPAL_VERSION:-9.4}" | ||
|
||
setup() { | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
cd "$DIR/../" || exit | ||
BREW_PREFIX="$(brew --prefix)" | ||
load "${BREW_PREFIX}/lib/bats-assert/load.bash" | ||
} | ||
|
||
dce() { | ||
docker-compose exec -T php-cli "$@" | ||
} | ||
|
||
drush() { | ||
dce drush "$@" | ||
} | ||
|
||
@test "Drupal version is $DRUPAL_VERSION" { | ||
run drush status --fields=drupal-version --format=string | ||
assert_output --partial "$DRUPAL_VERSION." | ||
} | ||
|
||
@test "Drupal bootstrap is successful" { | ||
run drush status --fields=bootstrap --format=string | ||
assert_output "Successful" | ||
} | ||
|
||
@test "Install minimal profile" { | ||
run make minimal | ||
assert_output --partial "[success] Installation complete." | ||
run drush pm:list --type=profile --field=name | ||
assert_output minimal | ||
} | ||
|
||
@test "Install standard profile" { | ||
run make standard | ||
assert_output --partial "[success] Installation complete." | ||
run drush pm:list --type=profile --field=name | ||
assert_output standard | ||
} |