From ad1d5d50b1e83b61c7e6b8fe2cb8811f9547a00d Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 29 Apr 2022 22:21:30 +0100 Subject: [PATCH] Auto container test (#8) * Add test workflow * Add test workflow * Add descriptions to test workflow * Add manual trigger to test * Remove YAML delimiters from test.yml * Update syntax to ignore main * Fix test file name * Publish test report * Fix container-structure-test race condition * Fix container-structure-test download * Reconfigure tests --- .github/workflows/test.yml | 51 ++++++++++++++++++++++++++++++++++++++ structure_tests.yml | 19 ++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 structure_tests.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0865f7a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +name: Test +on: + workflow_dispatch: + push: + branches-ignore: + - main + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build container image + run: docker build . --file Dockerfile --tag hesk:test-${{ github.sha }} + + - name: Install container-structure-test + run: | + curl -L https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 -o container-structure-test && chmod +x container-structure-test + + + - name: Run structure tests + run: | + ./container-structure-test test --image "hesk:test-${{ github.sha }}" --config "structure_tests.yml" --output "junit" --test-report "test-report.xml" + + - name: Publish test report + uses: mikepenz/action-junit-report@v3.0.3 + if: always() + with: + report_paths: 'test-report.xml' + commit: ${{ github.sha }} + fail_on_failure: true + check_name: Test Report + + - name: Spin up container + run: docker run -d -p 127.0.0.1:8080:80 --name hesk_test hesk:test-${{ github.sha }} + + - name: Wait for container to be ready + run: sleep 10s + shell: bash + + - name: Check if install wizard is available + run: curl http://127.0.0.1:8080/install/ + continue-on-error: false + + - name: Tear down + if: always() + run: | + docker rm -f hesk_test + docker rmi -f hesk:test-${{ github.sha }} diff --git a/structure_tests.yml b/structure_tests.yml new file mode 100644 index 0000000..6757725 --- /dev/null +++ b/structure_tests.yml @@ -0,0 +1,19 @@ +schemaVersion: '2.0.0' + +fileExistenceTests: + - name: 'Check HESK folder' + path: '/srv' + shouldExist: true + - name: 'Check Apache config exists' + path: '/etc/apache2/sites-enabled/000-default.conf' + shouldExist: true + +# Failng - need to figure out why +# fileContentTests: +# - name: 'Check Apache config has contents' +# path: '/etc/apache2/sites-enabled/000-default.conf' +# expectedContents: ['.*VirtualHost.*'] + +metadataTest: + exposedPorts: ["80"] + # user: "www-data"