From 5dd94eca38bb0fb650e5f8078b32012c3645beb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 20 Sep 2024 15:39:15 +0200 Subject: [PATCH] Add test stage to pipeline --- .gitea/workflows/build_and_deploy.yml | 46 +++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/build_and_deploy.yml b/.gitea/workflows/build_and_deploy.yml index d761a52..d9f6451 100644 --- a/.gitea/workflows/build_and_deploy.yml +++ b/.gitea/workflows/build_and_deploy.yml @@ -13,7 +13,7 @@ on: jobs: - build_job: + build_server: name: Build Docker Container runs-on: bfb-cicd-latest steps: @@ -24,9 +24,49 @@ jobs: - run: cd "${{ gitea.workspace }}/scnserver" && make docker - run: cd "${{ gitea.workspace }}/scnserver" && make push-docker - deploy_job: + test_server: + name: Run Unit-Tests + runs-on: bfb-cicd-latest + steps: + + - name: Check out code + uses: actions/checkout@v3 + + - name: Get Commiter Info + id: commiter_info + run: | + echo "NAME=$( git log -n 1 --pretty=format:%an )" >> $GITHUB_OUTPUT + echo "MAIL=$( git log -n 1 --pretty=format:%ae )" >> $GITHUB_OUTPUT + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: '${{ gitea.workspace }}/go.mod' + cache: false + + - name: Print Go Version + run: go version + + - name: Run tests + run: cd "${{ gitea.workspace }}/scnserver" && make dgi && make swagger && make test + + - name: Send failure mail + if: failure() + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.fastmail.com + server_port: 465 + secure: true + username: ${{secrets.MAIL_USERNAME}} + password: ${{secrets.MAIL_PASSWORD}} + subject: Pipeline on '${{ gitea.repository }}' failed + to: ${{ steps.commiter_info.outputs.MAIL }} + from: Gitea Actions + body: "Go to https://gogs.blackforestbytes.com/${{ gitea.repository }}/actions" + + deploy_server: name: Deploy to Server - needs: [build_job] + needs: [build_server, test_server] runs-on: ubuntu-latest steps: - name: Execute deploy on remote (via ssh)