Ai integration prototype #891
This file contains hidden or 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: Start Docker Stack | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| jobs: | |
| start-docker-stack: | |
| name: (Node.js ${{ matrix.node-version }}) - Start Docker Stack | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20, 22, 24] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and start Docker stack | |
| env: | |
| # Backend Variables | |
| DB_URI_FROM_WORKFLOW: ${{ secrets.DB_URI_TEST }} | |
| EMAIL_AUTH_FROM_WORKFLOW: ${{ secrets.EMAIL_AUTH }} | |
| EMAIL_PW_FROM_WORKFLOW: ${{ secrets.EMAIL_PW }} | |
| EMAIL_PORT_FROM_WORKFLOW: ${{ secrets.EMAIL_PORT }} | |
| EMAIL_HOST_FROM_WORKFLOW: ${{ secrets.EMAIL_HOST }} | |
| FRONTEND_URL_FROM_WORKFLOW: ${{ secrets.FRONTEND_URL }} | |
| G_CLIENT_SECRET_FROM_WORKFLOW: ${{ secrets.G_CLIENT_SECRET }} | |
| PASSPORT_GITHUB_LOCAL_PW_FIELD_FROM_WORKFLOW: ${{ secrets.PASSPORT_GITHUB_LOCAL_PW_FIELD }} | |
| # Frontend Variables | |
| API_SERVER_FROM_WORKFLOW: ${{ secrets.API_SERVER }} | |
| G_CLIENT_ID_FROM_WORKFLOW: ${{ secrets.G_CLIENT_ID }} | |
| VERSION_FROM_WORKFLOW: "SET" | |
| # Build-Argument | |
| NODE_VERSION: ${{ matrix.node-version }} | |
| run: | | |
| docker compose -f docker-test.yml build \ | |
| --build-arg NODE_VERSION=$NODE_VERSION | |
| docker compose -f docker-test.yml up -d --wait | |
| - name: Send failure notification | |
| if: ${{ failure() }} | |
| uses: ./actions/fullReport | |
| with: | |
| prnumber: ${{ github.event.pull_request.number }} | |
| originBranch: ${{ github.event.pull_request.head.ref }} | |
| destinationBranch: ${{ github.event.pull_request.base.ref }} | |
| requestor: ${{ github.event.pull_request.user.login }} | |
| date: ${{ github.event.pull_request.created_at }} | |
| description: ${{ github.event.pull_request.body }} | |
| dockerStatus: "failed" | |
| workflowLink: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI_TEST }} | |
| # Execute npm test in the backend container | |
| - name: Run npm test backend | |
| run: | | |
| docker exec Seed-backend npm test > testResultsBackend.txt 2>&1 | |
| continue-on-error: true | |
| - name: Clean up the result backend | |
| run: | | |
| awk '/Test Suites:/{flag=1; print; next} /Ran all test suites\./{flag=0} flag' testResultsBackend.txt > cleanResultsBackend.txt | |
| echo "" >> cleanResultsBackend.txt | |
| printf "$(cat cleanResultsBackend.txt)" > cleanResultsBackend.txt | |
| - name: Get passed, failed and total backend | |
| run: | | |
| passed=$(awk '/Tests:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsBackend.txt) | |
| failed=$(awk '/Tests:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsBackend.txt) | |
| echo "passedTests=${passed}" >> "${GITHUB_OUTPUT}" | |
| echo "failedTests=${failed}" >> "${GITHUB_OUTPUT}" | |
| passedSuites=$(awk '/Suites:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsBackend.txt) | |
| failedSuites=$(awk '/Suites:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsBackend.txt) | |
| echo "passedSuites=${passedSuites}" >> ${GITHUB_OUTPUT} | |
| echo "failedSuites=${failedSuites}" >> ${GITHUB_OUTPUT} | |
| bottomText=$(awk '/Snapshots:/{flag=1;print}/^$/{flag=0}flag' cleanResultsBackend.txt | tr -d '\n') | |
| echo "bottomText=${bottomText}" >> ${GITHUB_OUTPUT} | |
| id: passed-total-backend | |
| - name: Upload Artifact Backend | |
| if: ${{ !env.ACT }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-backend-${{ matrix.node-version }} | |
| path: testResultsBackend.txt | |
| # Execute npm test in the frontend container | |
| - name: Run npm test frontend | |
| run: | | |
| docker exec Seed-frontend npm test > testResultsFrontend.txt 2>&1 | |
| continue-on-error: true | |
| - name: Clean up the result frontend | |
| run: | | |
| awk '/Test Suites:/{flag=1; print; next} /Ran all test suites\./{flag=0} flag' testResultsFrontend.txt > cleanResultsFrontend.txt | |
| echo "" >> cleanResultsFrontend.txt | |
| printf "$(cat cleanResultsFrontend.txt)" > cleanResultsFrontend.txt | |
| - name: Get passed and total frontend | |
| run: | | |
| passed=$(awk '/Tests:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsFrontend.txt) | |
| failed=$(awk '/Tests:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsFrontend.txt) | |
| echo "passedTests=${passed}" >> "${GITHUB_OUTPUT}" | |
| echo "failedTests=${failed}" >> "${GITHUB_OUTPUT}" | |
| passedSuites=$(awk '/Suites:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsFrontend.txt) | |
| failedSuites=$(awk '/Suites:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' cleanResultsFrontend.txt) | |
| echo "passedSuites=${passedSuites}" >> ${GITHUB_OUTPUT} | |
| echo "failedSuites=${failedSuites}" >> ${GITHUB_OUTPUT} | |
| bottomText=$(awk '/Snapshots:/{flag=1;print}/^$/{flag=0}flag' cleanResultsFrontend.txt | tr -d '\n') | |
| echo "bottomText=${bottomText}" >> ${GITHUB_OUTPUT} | |
| id: passed-total-frontend | |
| - name: Upload Artifact Frontend | |
| if: ${{ !env.ACT }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-frontend-${{ matrix.node-version }} | |
| path: testResultsFrontend.txt | |
| # SANITY CHECK | |
| - name: Send sanity POST request and store response | |
| env: | |
| # Lade die Secrets sicher in die Umgebung | |
| SEED_EMAIL: ${{ secrets.SEED_EMAIL }} | |
| SEED_PW: ${{ secrets.SEED_PW }} | |
| SANITY_REPO_ID: ${{ secrets.SANITY_REPO_ID }} | |
| SANITY_GROUP_ID: ${{ secrets.SANITY_GROUP_ID }} | |
| run: | | |
| docker exec \ | |
| -e SEED_EMAIL \ | |
| -e SEED_PW \ | |
| -e SANITY_REPO_ID \ | |
| -e SANITY_GROUP_ID \ | |
| Seed-backend /bin/sh -c 'curl -X POST -H "Content-Type: application/json" -d "{\"email\": \"$SEED_EMAIL\", \"password\": \"$SEED_PW\", \"stayLoggedIn\": true, \"repository\": \"Seed-Test\", \"source\": \"db\"}" http://localhost:8080/api/sanity/test/$SANITY_REPO_ID/$SANITY_GROUP_ID' > sanityReport.txt | |
| - name: print sanity | |
| run: | | |
| echo $(cat sanityReport.txt) | |
| - name: Get passed and total sanity | |
| run: | | |
| passed=$(awk '/Steps:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' sanityReport.txt) | |
| failed=$(awk '/Steps:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' sanityReport.txt) | |
| skipped=$(awk '/Steps:/ { match($0, /[0-9]+ skipped/); print substr($0, RSTART, RLENGTH-8) }' sanityReport.txt) | |
| echo "passedSteps=${passed}" >> "${GITHUB_OUTPUT}" | |
| echo "failedSteps=${failed}" >> "${GITHUB_OUTPUT}" | |
| echo "skippedSteps=${skipped}" >> "${GITHUB_OUTPUT}" | |
| passedScenarios=$(awk '/Scenarios:/ { match($0, /[0-9]+ passed/); print substr($0, RSTART, RLENGTH-7) }' sanityReport.txt) | |
| failedScenarios=$(awk '/Scenarios:/ { match($0, /[0-9]+ failed/); print substr($0, RSTART, RLENGTH-7) }' sanityReport.txt) | |
| echo "passedScenarios=${passedScenarios}" >> ${GITHUB_OUTPUT} | |
| echo "failedScenarios=${failedScenarios}" >> ${GITHUB_OUTPUT} | |
| bottomText=bottomText=$(awk '/Snapshots:/{flag=1;next}/^$/{flag=0}flag' sanityReport.txt | tr -d '\n') | |
| echo "bottomText=${bottomText}" >> ${GITHUB_OUTPUT} | |
| id: passed-total-sanity | |
| - name: Upload Artifact Sanity | |
| if: ${{ !env.ACT }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sanity-report-${{ matrix.node-version }} | |
| path: | | |
| sanityReport.txt | |
| - name: Show backend container logs | |
| run: docker logs Seed-backend | |
| if: ${{ failure() }} | |
| # SEND FULL REPORT | |
| - name: Send Teams Message | |
| uses: ./actions/fullReport | |
| with: | |
| prnumber: ${{ github.event.pull_request.number }} | |
| prlink: ${{ github.event.pull_request.html_url }} | |
| originBranch: ${{ github.event.pull_request.head.ref }} | |
| destinationBranch: ${{ github.event.pull_request.base.ref }} | |
| requestor: ${{ github.event.pull_request.user.login }} | |
| date: ${{ github.event.pull_request.created_at }} | |
| description: ${{ github.event.pull_request.body }} | |
| dockerStatus: "success" | |
| frontendSuitsPassed: ${{ steps.passed-total-frontend.outputs.passedSuites }} | |
| frontendSuitsFailed: ${{ steps.passed-total-frontend.outputs.failedSuites }} | |
| frontendTestsPassed: ${{ steps.passed-total-frontend.outputs.passedTests }} | |
| frontendTestsFailed: ${{ steps.passed-total-frontend.outputs.failedTests }} | |
| frontendBottomText: ${{ steps.passed-total-frontend.outputs.bottomText }} | |
| backendSuitsPassed: ${{ steps.passed-total-backend.outputs.passedSuites }} | |
| backendSuitsFailed: ${{ steps.passed-total-backend.outputs.failedSuites }} | |
| backendTestsPassed: ${{ steps.passed-total-backend.outputs.passedTests }} | |
| backendTestsFailed: ${{ steps.passed-total-backend.outputs.failedTests }} | |
| backendBottomText: ${{ steps.passed-total-backend.outputs.bottomText }} | |
| sanityScenariosPassed: ${{ steps.passed-total-sanity.outputs.passedScenarios }} | |
| sanityScenariosFailed: ${{ steps.passed-total-sanity.outputs.failedScenarios }} | |
| sanityStepsPassed: ${{ steps.passed-total-sanity.outputs.passedSteps }} | |
| sanityStepsFailed: ${{ steps.passed-total-sanity.outputs.failedSteps }} | |
| sanityStepsSkipped: ${{ steps.passed-total-sanity.outputs.skippedSteps }} | |
| workflowLink: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI_TEST }} |