refactor(ci): standardize workflows and add retry mechanisms and centralized config #72
Workflow file for this run
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: C++ TUI CI | |
| on: | |
| pull_request: | |
| paths: | |
| - 'cpp-tui/**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format | |
| - name: Run clang-format check | |
| working-directory: cpp-tui/taskscpp | |
| run: | | |
| make format | |
| if ! git diff --exit-code; then | |
| echo "❌ Code style issues found. Run 'make format' to fix." | |
| exit 1 | |
| fi | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake clang build-essential | |
| - name: Create .env file | |
| run: | | |
| echo "DITTO_APP_ID=${{ secrets.DITTO_APP_ID }}" > .env | |
| echo "DITTO_PLAYGROUND_TOKEN=${{ secrets.DITTO_PLAYGROUND_TOKEN }}" >> .env | |
| echo "DITTO_AUTH_URL=${{ secrets.DITTO_AUTH_URL }}" >> .env | |
| echo "DITTO_WEBSOCKET_URL=${{ secrets.DITTO_WEBSOCKET_URL }}" >> .env | |
| - name: Download and setup Ditto C++ SDK | |
| working-directory: cpp-tui/taskscpp | |
| run: make download-sdk | |
| - name: Build application | |
| working-directory: cpp-tui/taskscpp | |
| run: | | |
| awk -f scripts/generate_env.awk ../../.env > src/env.h | |
| make build | |
| integration-test: | |
| name: Integration Test | |
| runs-on: ubuntu-latest | |
| needs: [lint, build] | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake clang build-essential | |
| - name: Create .env file | |
| run: | | |
| echo "DITTO_APP_ID=${{ secrets.DITTO_APP_ID }}" > .env | |
| echo "DITTO_PLAYGROUND_TOKEN=${{ secrets.DITTO_PLAYGROUND_TOKEN }}" >> .env | |
| echo "DITTO_AUTH_URL=${{ secrets.DITTO_AUTH_URL }}" >> .env | |
| echo "DITTO_WEBSOCKET_URL=${{ secrets.DITTO_WEBSOCKET_URL }}" >> .env | |
| - name: Seed test document to Ditto Cloud | |
| id: seed | |
| uses: ./.github/actions/seed-ditto-document | |
| with: | |
| ditto-api-key: ${{ secrets.DITTO_API_KEY }} | |
| ditto-api-url: ${{ secrets.DITTO_API_URL }} | |
| app-name: 'cpp-tui' | |
| - name: Download and setup Ditto C++ SDK | |
| working-directory: cpp-tui/taskscpp | |
| run: make download-sdk | |
| - name: Build and run integration test | |
| working-directory: cpp-tui/taskscpp | |
| env: | |
| DITTO_CLOUD_TASK_TITLE: ${{ steps.seed.outputs.document-title }} | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| GITHUB_RUN_NUMBER: ${{ github.run_number }} | |
| run: | | |
| awk -f scripts/generate_env.awk ../../.env > src/env.h | |
| mkdir -p build | |
| g++ -std=c++17 -I./src -I./sdk -I./third_party/cxxopts/include \ | |
| tests/integration_test.cpp \ | |
| src/task.cpp src/tasks_peer.cpp src/tasks_log.cpp \ | |
| -L./sdk -lditto -ldl -lrt -pthread \ | |
| -o build/integration_test | |
| ./build/integration_test | |
| summary: | |
| name: CI Report | |
| runs-on: ubuntu-latest | |
| needs: [lint, build, integration-test] | |
| if: always() | |
| steps: | |
| - name: Report Results | |
| run: | | |
| echo "## 🔧 C++ TUI CI" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Overall status | |
| if [[ "${{ needs.lint.result }}" == "success" && \ | |
| "${{ needs.build.result }}" == "success" && \ | |
| "${{ needs.integration-test.result }}" == "success" ]]; then | |
| echo "**Overall Status:** ✅ All checks passed" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "**Overall Status:** ❌ Failed" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Lint | ${{ needs.lint.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Build | ${{ needs.build.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Integration Test | ${{ needs.integration-test.result == 'success' && '✅ Passed' || (needs.integration-test.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY |