Add repo deleting #36
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
name: Golang Template Integration Tests | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- 'main' | |
paths: | |
- 'golang/**' | |
- '.github/workflows/golang-ci.yaml' | |
jobs: | |
prepare-template: | |
name: Prepare Cookiecutter Template | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install Cookiecutter | |
run: pip install cookiecutter | |
- name: Run Cookiecutter | |
run: cookiecutter --no-input -o $(pwd)/.data/ $(pwd)/golang/ | |
- name: Temporarily save cookiecutter output | |
uses: actions/upload-artifact@v2 | |
with: | |
name: golang-src | |
path: .data/MyGolangApp | |
retention-days: 1 | |
test-go-executable: | |
name: Test Executable | |
runs-on: ubuntu-22.04 | |
needs: prepare-template | |
steps: | |
- name: Setup Golang | |
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.0 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: Retrieve saved cookiecutter output | |
uses: actions/download-artifact@v2 | |
with: | |
name: golang-src | |
path: .data/MyGolangApp | |
- name: Download all Go modules | |
working-directory: .data/MyGolangApp | |
run: go get | |
- name: Run integration test | |
working-directory: .data/MyGolangApp | |
run: | | |
go build main.go | |
./main & | |
sleep 1 | |
curl --connect-timeout 10 http://0.0.0.0:8080 | |
test-image-functionality: | |
name: Test Image | |
runs-on: ubuntu-22.04 | |
needs: prepare-template | |
steps: | |
- name: Retrieve saved cookiecutter output | |
uses: actions/download-artifact@v2 | |
with: | |
name: golang-src | |
path: .data/MyGolangApp | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
context: .data/MyGolangApp | |
load: true | |
tags: app:test | |
- name: Test container structure | |
uses: plexsystems/container-structure-test-action@cc689017bbb16a3c98e6e87b0e07f92ad35a9df1 | |
with: | |
image: app:test | |
config: .data/MyGolangApp/container-structure-test.yaml | |
- name: Run integration test | |
working-directory: .data/MyGolangApp | |
run: | | |
docker run -p 8080:8080 app:test & | |
sleep 1 | |
response=$(curl --connect-timeout 10 http://0.0.0.0:8080) | |
needle="hello from MyGolangApp!" | |
if [[ $response != *"$needle"* ]]; then | |
echo "Unable to find needle \"$needle\" inside the following response:" | |
echo $response | |
exit 1 | |
fi | |