Cuc 725 fix then website #681
Workflow file for this run
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: 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: [18, 20, 22] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Create .env file backend | |
run: | | |
echo "DATABASE_URI=${{secrets.DB_URI}}" > backend/.env | |
echo "EMAIL_AUTH=${{secrets.EMAIL_AUTH}}" >> backend/.env | |
echo "EMAIL_PW=${{secrets.EMAIL_PW}}" >> backend/.env | |
echo "EMAIL_PORT=${{secrets.EMAIL_PORT}}" >> backend/.env | |
echo "EMAIL_HOST=${{secrets.EMAIL_HOST}}" >> backend/.env | |
echo "FRONTEND_URL=${{secrets.FRONTEND_URL}}" >> backend/.env | |
echo "GITHUB_CLIENT_SECRET=${{secrets.G_CLIENT_SECRET}}" >> backend/.env | |
echo "GITHUB_CLIENT_ID=${{secrets.G_CLIENT_ID}}" >> backend/.env | |
echo "PASSPORT_GITHUB_LOCAL_PW_FIELD=${{secrets.PASSPORT_GITHUB_LOCAL_PW_FIELD}}" >> backend/.env | |
- name: Create .env file frontend | |
run: | | |
echo "API_SERVER=${{secrets.API_SERVER}}" > frontend/.env | |
echo "GITHUB_CLIENT_ID=${{secrets.G_CLIENT_ID}}" >> frontend/.env | |
echo "EMAIL_PW=${{secrets.EMAIL_PW}}" >> frontend/.env | |
echo "VERSION=SET" >> frontend/.env | |
- name: Build and start Docker stack | |
env: | |
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 | |
- 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 }} | |
- name: Wait for 1/2 minute | |
run: sleep 30 | |
# 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: | |
API_URL: localhost:8080/api/sanity/test/${{ secrets.SANITY_REPO_ID }}/${{ secrets.SANITY_GROUP_ID }} | |
run: | | |
curl -X POST -H 'Content-Type: application/json' -d '{"email": "${{ secrets.SEED_EMAIL }}", "password": "${{ secrets.SEED_PW }}", "stayLoggedIn": true, "repository": "Seed-Test", "source": "db"}' "$API_URL" > 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 | |
# 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 }} |