Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated tests github actions #3

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c912c32
Automated tests github actions
piotrkwiecinski Feb 3, 2021
521e149
helpers
piotrkwiecinski Feb 3, 2021
2c5eab6
wip
piotrkwiecinski Feb 3, 2021
f8bc64c
wip
piotrkwiecinski Feb 3, 2021
5c10a48
sudo
piotrkwiecinski Feb 3, 2021
d718f70
ca-certificates
piotrkwiecinski Feb 3, 2021
23dc5ee
install
piotrkwiecinski Feb 3, 2021
746fd53
does it compose?
piotrkwiecinski Feb 3, 2021
1ed55e3
fix path
piotrkwiecinski Feb 3, 2021
604d796
github path
piotrkwiecinski Feb 3, 2021
e73d398
Global composer credentials
piotrkwiecinski Feb 6, 2021
936c146
fix flag
piotrkwiecinski Feb 6, 2021
93c1936
remove auth.json copy
piotrkwiecinski Feb 6, 2021
2b82911
fix typo
piotrkwiecinski Feb 6, 2021
3f3eb30
more typos
piotrkwiecinski Feb 6, 2021
9716f37
wip
piotrkwiecinski Feb 7, 2021
2a6e581
wip
piotrkwiecinski Feb 7, 2021
4a89e98
wip
piotrkwiecinski Feb 7, 2021
ec2b4d3
wip
piotrkwiecinski Feb 7, 2021
d4c2dc1
wip
piotrkwiecinski Feb 7, 2021
ee4d5d8
wip
piotrkwiecinski Feb 7, 2021
cec8f2c
wip
piotrkwiecinski Feb 7, 2021
b9626fd
wip
piotrkwiecinski Feb 7, 2021
a103872
specify shell
piotrkwiecinski Feb 7, 2021
8621cdc
wip
piotrkwiecinski Feb 7, 2021
8eb3675
non root?
piotrkwiecinski Feb 8, 2021
72cbdaa
node name
piotrkwiecinski Feb 8, 2021
eb416d6
wip
piotrkwiecinski Feb 8, 2021
1781619
remove container options
piotrkwiecinski Feb 8, 2021
b2fd688
wip change user
piotrkwiecinski Feb 8, 2021
325e43b
wip
piotrkwiecinski Feb 8, 2021
15bafc0
Merge remote-tracking branch 'upstream/master' into automated-tests-v2
piotrkwiecinski Feb 17, 2021
c00dbd3
wip
piotrkwiecinski Feb 17, 2021
4d47bed
wip
piotrkwiecinski Feb 17, 2021
21681be
wip
piotrkwiecinski Feb 17, 2021
7fb3a97
wip
piotrkwiecinski Feb 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/bats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Script Tests"

on:
push:
branches: ["master"]
pull_request:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:

- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.2.1

- name: Check out code
uses: actions/checkout@v1

- name: Install dependencies
run: |
command -v update-ca-certificates > /dev/null || sudo apt-get -y update && sudo apt-get install -y ca-certificates

- name: Setup PHP, with composer
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
tools: composer:v1
- name: Test
shell: bash
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
run: |
bats --tap compose/tests/status.bats

- name: Test 2
shell: bash
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
run: |
echo '${{ secrets.COMPOSER_AUTH_JSON }}' > ~/.composer/auth.json
bats --tap compose/tests/download.bats
bats --tap compose/tests/bash.bats

- name: Test 3
shell: bash
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
run: |
bats --tap compose/tests/bash.bats
2 changes: 1 addition & 1 deletion compose/bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ bin/stop
docker-compose -f docker-compose.yml up -d
[ $? != 0 ] && echo "Failed to start Docker services" && exit

bin/setup-composer-auth
#bin/setup-composer-auth

bin/clinotty composer create-project --repository=https://repo.magento.com/ magento/project-"${EDITION}"-edition="${VERSION}" .
2 changes: 1 addition & 1 deletion compose/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- ./src/composer.json:/var/www/html/composer.json:cached
- ./src/composer.lock:/var/www/html/composer.lock:cached
- ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached
#- ./src/auth.json:/var/www/html/auth.json:cached
- ./src/auth.json:/var/www/html/auth.json:cached
#- ./src/m2-hotfixes:/var/www/html/m2-hotfixes:cached
#- ./src/patches:/var/www/html/patches:cached
#- ./src/var/log:/var/www/html/var/log:cached
Expand Down
11 changes: 11 additions & 0 deletions compose/tests/bash.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bats

load test_helpers/common.bash
load test_helpers/running_docker.bash

@test 'cli: bash is preset' {
run "$(magento_docker_base_path)"/bin/cli bash -c "echo 'hello world'"
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" =~ "hello world" ]]
}
43 changes: 43 additions & 0 deletions compose/tests/copytocontainer.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bats

load test_helpers/common.bash
load test_helpers/running_docker.bash

DUMMY_TEST_FILE_PATH="app/etc/test-file.txt"
DUMMY_TEST_INVALID_DIR="dev/invalid"
DUMMY_TEST_DIR="dev/test-dir"

setup() {
"$(magento_docker_base_path)"/bin/clinotty rm -f "${DUMMY_TEST_FILE_PATH}"
"$(magento_docker_base_path)"/bin/clinotty rm -rf "${DUMMY_TEST_DIR}"
}

@test 'copytocontainer: copy a single file to a nested directory' {
touch "$(magento_docker_base_path)/src/${DUMMY_TEST_FILE_PATH}"
run "$(magento_docker_base_path)"/bin/copytocontainer "${DUMMY_TEST_FILE_PATH}"
run "$(magento_docker_base_path)"/bin/clinotty ls -l "$(dirname "${DUMMY_TEST_FILE_PATH}")"
[ "${status}" -eq 0 ]
[[ "${lines[@]}" =~ 'test-file.txt' ]]
}

@test 'copytocontainer: copy a directory to a nested directory' {
skip
cd "$(magento_docker_base_path)"
mkdir -p src/${DUMMY_TEST_DIR}
touch src/${DUMMY_TEST_DIR}/file.1.txt
touch src/${DUMMY_TEST_DIR}/file.2.txt
run bin/copytocontainer ${DUMMY_TEST_DIR}
run bin/clinotty ls -l ${DUMMY_TEST_DIR}
echo "$output" >&3
[ "${status}" -eq 0 ]
[[ "${lines[1]} =~ 'file.1.txt' ]]
[[ "${lines[2]} =~ 'file.2.txt' ]]
}

@test 'copytocontainer: show help on no arguments' {
skip
cd "$(magento_docker_base_path)"
run bin/copytocontainer
[ "${status}" -eq 0 ]
[ "${output}" = "Please specify a directory or file to copy to container (ex. vendor, --all)" ]
}
14 changes: 14 additions & 0 deletions compose/tests/download.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bats

load test_helpers/common.bash

setup_file() {
cd "$(magento_docker_base_path)"
rm -rf src
}

@test 'download: download' {
run "$(magento_docker_base_path)"/bin/download 2.4.2
echo "$output"
[ "$status" -eq 0 ]
}
14 changes: 14 additions & 0 deletions compose/tests/status.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bats

load test_helpers/common.bash

setup_file() {
cd "$(magento_docker_base_path)"
}

@test 'status: show status' {
run "$(magento_docker_base_path)"/bin/status
echo "$output"
regex="(.*)Name(.*)Command(.*)State"
[[ ${lines[0]} =~ $regex ]]
}
4 changes: 4 additions & 0 deletions compose/tests/test_helpers/common.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
magento_docker_base_path() {
echo "${BATS_TEST_DIRNAME}/.."
}

17 changes: 17 additions & 0 deletions compose/tests/test_helpers/running_docker.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[ ! $(type -t magento_docker_base_path)"" == 'function' ]] && echo "Run only with common.bash"

setup_file() {
cd "$(magento_docker_base_path)" || exit 1
if [ ! -f src/composer.json ]; then
bin/download 2.4.1
if [ ! -f src/auth.json ]; then
cp ~/.composer/auth.json src/auth.json
fi
bin/setup "magento2.test"
fi
bin/start
}

teardown_file() {
cd "$(magento_docker_base_path)" && bin/stop
}