Holding: Add balance eval script added #60
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: π CI Pipeline for Monorepo | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
services: ${{ steps.filter.outputs.services }} | |
steps: | |
- name: π₯ Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: π Detect Changed Microservices | |
id: filter | |
run: | | |
changed_services=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^backend/' | cut -d'/' -f2 | sort -u | jq -R . | jq -s -c .) | |
echo "Detected changes in: $changed_services" | |
# Ensure valid JSON | |
if [[ -z "$changed_services" || "$changed_services" == "[]" ]]; then | |
services_json="[]" | |
else | |
services_json="$changed_services" | |
fi | |
echo "services=$services_json" >> "$GITHUB_OUTPUT" | |
build: | |
needs: detect-changes | |
runs-on: ubuntu-latest | |
environment: opinex | |
if: needs.detect-changes.outputs.services != '[]' | |
steps: | |
- name: π₯ Checkout Code | |
uses: actions/checkout@v3 | |
- name: βοΈ Set up Node.js Environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "22" | |
- name: βοΈ Set up Python Environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: π¦ Install Node.js Dependencies | |
run: | | |
npm install -g turbo | |
npm install | |
- name: π§ Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - --version 2.1.1 | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
export PATH="$HOME/.local/bin:$PATH" | |
- name: Install Event Service Dependencies | |
run: | | |
cd backend/event | |
poetry install --no-root | |
- name: β Docker Network creations | |
run: | | |
docker network ls | grep main_network || docker network create main_network | |
- name: π Run docker Resources (DB, cache, pubsub) | |
run: | | |
cd docker | |
cd cache | |
docker compose up -d | |
cd .. | |
cd DBS | |
docker compose up -d | |
cd .. | |
cd pubsub | |
docker compose up -d | |
echo " π Docker common resources running" | |
sleep 10 | |
- name: β Verify Running Containers | |
run: | | |
docker compose -f 'docker/cache/docker-compose.yaml' ps | |
docker compose -f 'docker/DBS/docker-compose.yaml' ps | |
docker compose -f 'docker/pubsub/docker-compose.yaml' ps | |
- name: π Debug Logs on Failure | |
if: failure() | |
run: | | |
docker compose -f 'docker/cache/docker-compose.yaml' logs --tail=100 | |
docker compose -f 'docker/DBS/docker-compose.yaml' logs --tail=100 | |
docker compose -f 'docker/pubsub/docker-compose.yaml' logs --tail=100 | |
- name: β‘ Start Turbo Dev Mode | |
run: | | |
turbo build | |
nohup turbo dev > turbo.log 2>&1 & | |
echo "Turbo Dev started with PID: $!" | |
- name: β³ Wait Until All Servers are Up | |
run: | | |
cd scripts/ | |
chmod +x checkservice.sh | |
./checkservice.sh | |
- name: π¬ Run Tests in /packages/test | |
run: | | |
cd packages/test | |
npm run test | |
- name: π Stop Turbo Dev | |
run: | | |
pkill -f "turbo dev" || echo "Turbo Dev process not running" | |
# - name: π§Ή Cleanup Resources | |
# run: | | |
# docker compose -f 'docker/docker-compose.resources.yaml' down -v | |
# - name: ποΈ Build Images | |
# run: | | |
# cd scripts/ | |
# chmod +x build_images.sh | |
# ./build_images.sh | |
# - name: π³ Configure Docker Images + Resources | |
# run: | | |
# docker compose -f 'docker/docker-compose.yaml' up -d --build --wait | |
# - name: β Verify Running Containers | |
# run: docker compose -f 'docker/docker-compose.yaml' ps | |
# - name: π Debug Logs on Failure | |
# if: failure() | |
# run: docker compose -f 'docker/docker-compose.yaml' logs --tail=100 | |
# - name: β³ Wait Until All Servers are Up (Docker) | |
# run: | | |
# cd scripts/ | |
# chmod +x checkservice.sh | |
# ./checkservice.sh | |
# - name: π¬ Run Tests in /packages/test | |
# run: | | |
# cd packages/test | |
# npm run test | |
# - name: π Convert JSON to Space-Separated List | |
# id: format_services | |
# run: | | |
# services_list=$(echo '${{ needs.detect-changes.outputs.services }}' | jq -r '.[]' | tr '\n' ' ') | |
# echo "services_list=$services_list" >> "$GITHUB_ENV" | |
# - name: π Login to Docker Hub | |
# uses: docker/login-action@v2 | |
# with: | |
# username: ${{ secrets.DOCKER_USERNAME }} | |
# password: ${{ secrets.DOCKER_PASSWORD }} | |
# - name: π·οΈ Tag Images | |
# run: | | |
# cd scripts/ | |
# chmod +x tag_images.sh | |
# ./tag_images.sh ${{ secrets.DOCKER_USERNAME }} ${{ github.sha }} $services_list |