diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000..ae35fad --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,21 @@ +name: Integration Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Build test harness + run: make buildtest + + - name: Run tests + run: make test diff --git a/Makefile b/Makefile index 1e0959f..2d5c75b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) export DOCKER_BUILD_FLAGS = COPYRIGHT_SOFTWARE_DESCRIPTION := A secure Bastion host implemented as Docker Container running Alpine Linux with Google Authenticator & DUO MFA support -.PHONY: test +.PHONY: test buildtest include $(shell curl --silent -O "https://raw.githubusercontent.com/cloudposse/build-harness/master/templates/Makefile.build-harness"; echo Makefile.build-harness) @@ -29,5 +29,9 @@ run: reset -e SLACK_ENABLED=true \ $(DOCKER_IMAGE_NAME) +buildtest: + cd test > /dev/null; ./build.sh + + test: - pushd test > /dev/null; ./test.sh; popd > /dev/null + cd test > /dev/null; ./test.sh diff --git a/README.md b/README.md index 45881b1..9c3bda1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# bastion [![Latest Release](https://img.shields.io/github/release/cloudposse/bastion.svg)](https://github.com/cloudposse/bastion/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) +# bastion [![Latest Release](https://img.shields.io/github/release/cloudposse/bastion.svg)](https://github.com/cloudposse/bastion/releases/latest) [![Build & Test Status](https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) [![README Header][readme_header_img]][readme_header_link] diff --git a/README.yaml b/README.yaml index 172dc05..90ecd94 100644 --- a/README.yaml +++ b/README.yaml @@ -21,6 +21,9 @@ badges: - name: "Latest Release" image: "https://img.shields.io/github/release/cloudposse/bastion.svg" url: "https://github.com/cloudposse/bastion/releases/latest" + - name: "Build & Test Status" + image: "https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml/badge.svg" + url: "https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml" - name: "Slack Community" image: "https://slack.cloudposse.com/badge.svg" url: "https://slack.cloudposse.com" diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 0000000..5da145a --- /dev/null +++ b/test/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export TERM=linux + +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + +docker -v +docker-compose -v + +docker compose build diff --git a/test/test.sh b/test/test.sh index a78fe5a..f047981 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,5 +1,7 @@ #!/bin/bash +export TERM=linux + red=`tput setaf 1` green=`tput setaf 2` reset=`tput sgr0` @@ -9,10 +11,10 @@ rm -rf fixtures/auth/ida_rsa* ssh-keygen -q -f fixtures/auth/ida_rsa -N "" chmod 600 fixtures/auth/ida_rsa -docker-compose down -docker-compose up --build bastion -d -docker-compose exec bastion /scripts/setup.sh -docker-compose run --build test /scripts/google_auth_test.sh +docker compose down +docker compose up -d --build bastion +docker compose exec bastion /scripts/setup.sh +docker compose run --build test /scripts/google_auth_test.sh retVal=$? @@ -24,10 +26,9 @@ else fi -docker-compose exec bastion ls /var/log/sudo-io/00/00/01/ +docker compose exec bastion ls /var/log/sudo-io/00/00/01/ retVal=$? - if [ $retVal -ne 0 ]; then echo "${red}* sudosh Audit Failed - no logs created!${reset}" exit $retVal @@ -36,7 +37,7 @@ else fi -docker-compose exec bastion curl https://hooks.slack.com +docker compose exec bastion curl https://hooks.slack.com retVal=$? @@ -47,7 +48,7 @@ else echo "${green}* Slack API Connection Test Succeeded${reset}" fi -export SSHRC_KILL_OUTPUT=`docker-compose run --build test /scripts/sshrc_kill_test.sh` +export SSHRC_KILL_OUTPUT=`docker compose run --build test /scripts/sshrc_kill_test.sh` if [[ "$SSHRC_KILL_OUTPUT" == *"this output should never print"* ]]; then echo "${red}* Failure to quit after non-zero exit code in sshrc${reset}"