Protofy CI Daily tests #569
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: Protofy CI Daily tests | |
on: | |
schedule: | |
- cron: '0 8,20 * * *' # Runs at 8 AM, 20 PM UTC every day | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
test: | |
if: github.repository == 'Protofy-xyz/Protofy' | |
runs-on: self-hosted | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js 20.4.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.4.x' | |
- name: Setup yarn | |
run: npm install -g yarn | |
- name: Set up Node.js 20.4.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.4.x' | |
cache: 'yarn' | |
- name: Install NodeJS dependencies | |
run: yarn | |
- name: Prepare dev | |
run: | | |
echo 'Packaging project' | |
yarn prepare-dev | |
- name: Start project | |
run: | | |
echo 'Started project' | |
yarn dev-fast > /dev/null & | |
- name: Healthcheck services start | |
run: node .github/scripts/healthcheck-start.js | |
- name: Install tests dependencies | |
run: cd ./apps/next && yarn test:deps | |
- name: Run tests | |
run: | | |
set -o pipefail | |
yarn test:all:long | tee ${{ runner.temp }}/test_output.txt | |
- name: Get test report | |
if: always() # executed always even if job fails | |
run: node .github/scripts/retrieveTestsReport.js ${{ runner.temp }}/test_output.txt > ${{ runner.temp }}/testsReport.txt | |
- name: Show output report | |
run: cat ${{ runner.temp }}/testsReport.txt | |
- name: Upload result # upload saved result as artifact to be consumed at notify job | |
if: always() # executed always even if job fails | |
uses: actions/upload-artifact@v3 | |
with: | |
name: reports | |
path: ${{ runner.temp }}/testsReport.txt | |
notify: | |
runs-on: self-hosted | |
needs: test | |
if: always() && github.repository == 'Protofy-xyz/Protofy' # This ensures that the notify job runs whether the test job succeeds or fails | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js 20.4.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.4.x' | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
- name: '[healthcheck] "test" job status and testsReprot content' | |
run: | | |
echo "${{ needs.test.result }}" | |
cat reports/testsReport.txt | |
- name: Save report to environment variable | |
run: | | |
echo "TEST_REPORT<<EOF" >> $GITHUB_ENV | |
cat reports/testsReport.txt | sed 's/\x1b\[[0-9;]*m//g' >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Get shorten GitHub sha | |
run: echo "GITHUB_SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV | |
- name: Get skipped status to retrieve color and save it to environment variable | |
run: | | |
if grep -q "🚧 PASS" reports/testsReport.txt; then | |
echo "SKIPPED=True" >> $GITHUB_ENV | |
echo "TEST_COLOR=#ffa600" >> $GITHUB_ENV | |
echo "TEST_AVATAR_COLOR=orange" >> $GITHUB_ENV | |
else | |
echo "SKIPPED=False" >> $GITHUB_ENV | |
echo "TEST_COLOR=#00e065" >> $GITHUB_ENV | |
echo "TEST_AVATAR_COLOR=green" >> $GITHUB_ENV | |
fi | |
- name: Test Success | |
uses: rjstone/discord-webhook-notify@v1 | |
if: needs.test.result == 'success' | |
with: | |
severity: info | |
details: Test Succeeded! | |
username: ${{ github.event.pusher.name }} | |
color: ${{ env.TEST_COLOR }} | |
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_${{ env.TEST_AVATAR_COLOR}}.png | |
description: | | |
🚨🚨🚨Long Tests Report🚨🚨🚨 | |
${{ env.TEST_REPORT }} | |
footer: "Workflow: ${{ github.workflow }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
- name: Test Failure | |
uses: rjstone/discord-webhook-notify@v1 | |
if: needs.test.result == 'failure' | |
with: | |
severity: error | |
details: Test Failed! | |
username: ${{ github.event.pusher.name }} | |
color: '#f13932' | |
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_red.png | |
description: | | |
🚨🚨🚨Long Tests Report🚨🚨🚨 | |
${{ env.TEST_REPORT }} | |
footer: "Workflow: ${{ github.workflow }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
- name: Test Cancelled | |
uses: rjstone/discord-webhook-notify@v1 | |
if: needs.test.result == 'cancelled' | |
with: | |
severity: warn | |
details: Job Cancelled! | |
username: ${{ github.event.pusher.name }} | |
color: '#ffa600' | |
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_orange.png | |
description: | | |
🚨🚨🚨Long Tests Report🚨🚨🚨 | |
*Long Tests have beeen cancelled!* | |
footer: "Workflow: ${{ github.workflow }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} |