Skip to content

Refactor chat components to use dynamic API URLs moving apiurl to store #2090

Refactor chat components to use dynamic API URLs moving apiurl to store

Refactor chat components to use dynamic API URLs moving apiurl to store #2090

Workflow file for this run

name: Protofy CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
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: Install Python dependencies (venv)
run: sudo apt-get install -y python3-venv
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup yarn
run: npm install -g yarn
- name: Set up Node.js 20.4.x with yarn
uses: actions/setup-node@v4
with:
node-version: '20.4.x'
cache: 'yarn'
- name: Install NodeJS dependencies
run: yarn
- name: Modify requirements.txt with absolute paths
run: |
sed -i 's|../../packages/protopy|'"$GITHUB_WORKSPACE"'/packages/protopy|' requirements.txt
sed -i 's|../../packages/app|'"$GITHUB_WORKSPACE"'/packages/app|' requirements.txt
- name: Install Python dependencies
run: pip install -r requirements.txt
- 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 | 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.event_name != 'pull_request' && github.repository == 'Protofy-xyz/Protofy' }} # This job runs only if the trigger is not a pull request
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: |
${{ env.TEST_REPORT }}
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
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: |
${{ env.TEST_REPORT }}
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
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: |
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
footer: "Workflow: ${{ github.workflow }}"
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}