diff --git a/.github/workflows/beta-workflow.yml b/.github/workflows/beta-workflow.yml index e96ffe2..f989eb0 100644 --- a/.github/workflows/beta-workflow.yml +++ b/.github/workflows/beta-workflow.yml @@ -1,4 +1,4 @@ -## This workflow runs on pull requests into the beta branch. Direct pushes to beta are blocked. +# This workflow runs on pull requests into the beta branch. Direct pushes to beta are blocked. name: Beta Workflow @@ -9,6 +9,7 @@ on: jobs: beta-tests: + name: Test Beta Branch with Dart Matrix runs-on: ubuntu-latest strategy: @@ -25,10 +26,48 @@ jobs: dart-version: ${{ matrix.dart-version }} - name: Install Dependencies - run: dart pub get + run: | + echo "Installing dependencies for Dart ${{ matrix.dart-version }}..." + if ! dart pub get; then + echo "❌ Failed to install dependencies for Dart ${{ matrix.dart-version }}. Exiting..." + exit 1 + fi - name: Run Static Analysis - run: dart analyze + run: | + echo "Running static analysis for Dart ${{ matrix.dart-version }}..." + if ! dart analyze > analysis_report.txt 2> error_log.txt; then + echo "❌ Static analysis failed for Dart ${{ matrix.dart-version }}." + cat error_log.txt + exit 1 + else + echo "✅ Static analysis passed for Dart ${{ matrix.dart-version }}." + fi + + - name: Upload Analysis Report + if: always() + uses: actions/upload-artifact@v3 + with: + name: analysis-report-${{ matrix.dart-version }} + path: | + analysis_report.txt + error_log.txt + retention-days: 7 - name: Run Unit Tests - run: dart test + run: | + echo "Running unit tests for Dart ${{ matrix.dart-version }}..." + if ! dart test --reporter expanded; then + echo "❌ Unit tests failed for Dart ${{ matrix.dart-version }}. Exiting..." + exit 1 + else + echo "✅ Unit tests passed for Dart ${{ matrix.dart-version }}." + fi + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v3 + with: + name: test-results-${{ matrix.dart-version }} + path: .dart_tool/test/generated_reports + retention-days: 7 diff --git a/.github/workflows/contributor-workflow.yml b/.github/workflows/contributor-workflow.yml index d3605a6..7083253 100644 --- a/.github/workflows/contributor-workflow.yml +++ b/.github/workflows/contributor-workflow.yml @@ -1,5 +1,5 @@ -## This workflow analyzes the Dart Server SDK and a Go-feature-integration example project -## to identify issues and commits for resolution. +# This workflow analyzes the Dart Server SDK and a Go-feature-integration example project +# to identify issues and commits for resolution. name: Contributor Workflow @@ -44,7 +44,7 @@ jobs: echo "✅ Static analysis completed successfully. No critical errors found." fi - - name: Highlight Info, Warnings, and Errors + - name: Categorize and Count Analysis Results run: | echo "Categorizing analysis results..." cd dart-server-sdk-openfeature @@ -52,17 +52,33 @@ jobs: grep -i "warning" analysis_report.txt > warning_report.txt || echo "No warnings found." grep -i "error" analysis_report.txt > error_report.txt || echo "No errors found." + INFO_COUNT=$(wc -l < info_report.txt || echo 0) + WARNING_COUNT=$(wc -l < warning_report.txt || echo 0) + ERROR_COUNT=$(wc -l < error_report.txt || echo 0) + echo "Summary of analysis results:" - echo "Informational messages:" - cat info_report.txt || true - echo "" - echo "Warnings:" - cat warning_report.txt || true + echo "Informational messages: $INFO_COUNT" + echo "Warnings: $WARNING_COUNT" + echo "Errors: $ERROR_COUNT" echo "" - echo "Errors:" - cat error_report.txt || true - - name: Identify Specific Commits for Easy Resolution + if [[ $INFO_COUNT -gt 0 ]]; then + echo "Informational messages:" + cat info_report.txt + echo "" + fi + if [[ $WARNING_COUNT -gt 0 ]]; then + echo "Warnings:" + cat warning_report.txt + echo "" + fi + if [[ $ERROR_COUNT -gt 0 ]]; then + echo "Errors:" + cat error_report.txt + echo "" + fi + + - name: Identify Specific Commits for Issues run: | echo "Identifying specific commits for issues in the core SDK..." cd dart-server-sdk-openfeature @@ -125,7 +141,7 @@ jobs: echo "✅ Static analysis completed successfully. No critical errors found." fi - - name: Highlight Info, Warnings, and Errors + - name: Categorize and Count Analysis Results run: | echo "Categorizing analysis results..." cd dart-server-sdk-openfeature/examples/go-feature-integration @@ -133,17 +149,33 @@ jobs: grep -i "warning" analysis_report.txt > warning_report.txt || echo "No warnings found." grep -i "error" analysis_report.txt > error_report.txt || echo "No errors found." + INFO_COUNT=$(wc -l < info_report.txt || echo 0) + WARNING_COUNT=$(wc -l < warning_report.txt || echo 0) + ERROR_COUNT=$(wc -l < error_report.txt || echo 0) + echo "Summary of analysis results:" - echo "Informational messages:" - cat info_report.txt || true - echo "" - echo "Warnings:" - cat warning_report.txt || true + echo "Informational messages: $INFO_COUNT" + echo "Warnings: $WARNING_COUNT" + echo "Errors: $ERROR_COUNT" echo "" - echo "Errors:" - cat error_report.txt || true - - name: Identify Specific Commits for Easy Resolution + if [[ $INFO_COUNT -gt 0 ]]; then + echo "Informational messages:" + cat info_report.txt + echo "" + fi + if [[ $WARNING_COUNT -gt 0 ]]; then + echo "Warnings:" + cat warning_report.txt + echo "" + fi + if [[ $ERROR_COUNT -gt 0 ]]; then + echo "Errors:" + cat error_report.txt + echo "" + fi + + - name: Identify Specific Commits for Issues run: | echo "Identifying specific commits for issues in the Go-feature-integration example..." cd dart-server-sdk-openfeature/examples/go-feature-integration diff --git a/.github/workflows/main-workflow.yml b/.github/workflows/main-workflow.yml index 6dba227..c1115dd 100644 --- a/.github/workflows/main-workflow.yml +++ b/.github/workflows/main-workflow.yml @@ -1,4 +1,4 @@ -## This workflow runs on pull requests into the main branch. Direct pushes to main are blocked. +# This workflow runs on pull requests into the main branch. Direct pushes to main are blocked. name: Main Workflow @@ -9,11 +9,14 @@ on: jobs: main-tests: + name: Validate and Test Main Branch runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Dart uses: dart-lang/setup-dart@v1 @@ -21,22 +24,57 @@ jobs: dart-version: stable - name: Install Dependencies - run: dart pub get + run: | + echo "Installing dependencies..." + if ! dart pub get; then + echo "❌ Failed to install dependencies. Exiting..." + exit 1 + fi + + - name: Check Code Formatting + run: | + echo "Checking code formatting..." + if ! dart format --set-exit-if-changed .; then + echo "❌ Code formatting issues detected. Please format your code with 'dart format'." + exit 1 + fi - name: Run Static Analysis - run: dart analyze + run: | + echo "Running static analysis..." + if ! dart analyze; then + echo "❌ Static analysis failed. Please fix the issues above." + exit 1 + fi - name: Run Full Test Suite - run: dart test --coverage=coverage + run: | + echo "Running full test suite with coverage..." + if ! dart test --coverage=coverage; then + echo "❌ Tests failed. Please fix the errors above." + exit 1 + fi - name: Format Coverage Report - run: dart pub global activate coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info + run: | + echo "Formatting coverage report..." + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 with: file: coverage/lcov.info + - name: Upload Coverage Artifact + if: always() + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: coverage/lcov.info + - name: Deploy to Production - if: github.event.pull_request.merged - run: echo "Deploying to Production..." + if: github.event.pull_request.merged && github.ref == 'refs/heads/main' + run: | + echo "Deploying to Production..." + # Add your deployment commands here diff --git a/.github/workflows/parent-pipeline.yml b/.github/workflows/parent-pipeline.yml index 6027af4..48bef84 100644 --- a/.github/workflows/parent-pipeline.yml +++ b/.github/workflows/parent-pipeline.yml @@ -5,10 +5,10 @@ name: Parent Pipeline on: push: branches: - - '*' + - '*' # Matches any branch pull_request: branches: - - '*' + - '*' # Matches pull requests to any branch jobs: trigger-validation: @@ -17,6 +17,10 @@ jobs: determine-workflow: needs: trigger-validation runs-on: ubuntu-latest + outputs: + branch_name: ${{ steps.determine.outputs.branch }} + base_branch: ${{ steps.determine.outputs.base_branch }} + event_name: ${{ steps.determine.outputs.event }} steps: - name: Determine Branch and Event id: determine @@ -31,23 +35,41 @@ jobs: trigger-contributor-workflow: needs: [determine-workflow, trigger-validation] uses: ./.github/workflows/contributor-workflow.yml + with: + branch_name: ${{ needs.determine-workflow.outputs.branch_name }} + event_name: ${{ needs.determine-workflow.outputs.event_name }} if: | github.event_name == 'push' && - github.ref_name != 'main' && - github.ref_name != 'qa' && - github.ref_name != 'beta' + needs.determine-workflow.outputs.branch_name != 'main' && + needs.determine-workflow.outputs.branch_name != 'qa' && + needs.determine-workflow.outputs.branch_name != 'beta' trigger-qa-workflow: needs: [determine-workflow, trigger-validation] uses: ./.github/workflows/qa-workflow.yml - if: github.event_name == 'pull_request' && github.base_ref == 'qa' + with: + branch_name: ${{ needs.determine-workflow.outputs.branch_name }} + event_name: ${{ needs.determine-workflow.outputs.event_name }} + if: | + github.event_name == 'pull_request' && + needs.determine-workflow.outputs.base_branch == 'qa' trigger-beta-workflow: needs: [determine-workflow, trigger-validation] uses: ./.github/workflows/beta-workflow.yml - if: github.event_name == 'pull_request' && github.base_ref == 'beta' + with: + branch_name: ${{ needs.determine-workflow.outputs.branch_name }} + event_name: ${{ needs.determine-workflow.outputs.event_name }} + if: | + github.event_name == 'pull_request' && + needs.determine-workflow.outputs.base_branch == 'beta' trigger-main-workflow: needs: [determine-workflow, trigger-validation] uses: ./.github/workflows/main-workflow.yml - if: github.event_name == 'pull_request' && github.base_ref == 'main' + with: + branch_name: ${{ needs.determine-workflow.outputs.branch_name }} + event_name: ${{ needs.determine-workflow.outputs.event_name }} + if: | + github.event_name == 'pull_request' && + needs.determine-workflow.outputs.base_branch == 'main' diff --git a/.github/workflows/qa-workflow.yml b/.github/workflows/qa-workflow.yml index d052895..a37015b 100644 --- a/.github/workflows/qa-workflow.yml +++ b/.github/workflows/qa-workflow.yml @@ -1,4 +1,4 @@ -## This workflow runs on pull requests into the main qa. SDirect pushes to main are blocked. +# This workflow runs on pull requests into the qa branch. Direct pushes to qa are blocked. name: QA Workflow @@ -9,6 +9,7 @@ on: jobs: qa-tests: + name: Run QA Tests runs-on: ubuntu-latest steps: @@ -21,21 +22,92 @@ jobs: dart-version: stable - name: Install Dependencies - run: dart pub get + run: | + echo "Installing dependencies..." + if ! dart pub get; then + echo "❌ Failed to install dependencies. Exiting..." + exit 1 + fi - name: Run Static Analysis - run: dart analyze + run: | + echo "Running static analysis..." + if ! dart analyze lib/ > analysis_report.txt 2> error_log.txt; then + echo "❌ Static analysis failed. See error details below:" + cat error_log.txt + exit 1 + else + echo "✅ Static analysis completed successfully." + fi - - name: Run Unit Tests - run: dart test --coverage=coverage + - name: Upload Analysis Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: static-analysis-artifacts + path: | + analysis_report.txt + error_log.txt + retention-days: 7 + + - name: Run Unit Tests with Coverage + run: | + echo "Running unit tests with coverage..." + if ! dart test --coverage=coverage; then + echo "❌ Unit tests failed. Exiting..." + exit 1 + else + echo "✅ Unit tests completed successfully." + fi - name: Format Coverage Report - run: dart pub global activate coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info + run: | + echo "Formatting coverage report..." + if ! dart pub global activate coverage; then + echo "❌ Failed to activate the coverage package. Exiting..." + exit 1 + fi + if ! dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info; then + echo "❌ Failed to format the coverage report. Exiting..." + exit 1 + else + echo "✅ Coverage report formatted successfully." + fi + + - name: Upload Coverage Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: coverage-artifacts + path: coverage/lcov.info + retention-days: 7 - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 with: file: coverage/lcov.info - - name: Check Code Quality - run: dart pub global run dart_code_metrics:metrics analyze lib + - name: Run Code Quality Check + run: | + echo "Running code quality checks with dart_code_metrics..." + if ! dart pub global activate dart_code_metrics; then + echo "❌ Failed to activate dart_code_metrics. Exiting..." + exit 1 + fi + if ! dart pub global run dart_code_metrics:metrics analyze lib > quality_report.txt 2> quality_error_log.txt; then + echo "❌ Code quality check failed. See error details below:" + cat quality_error_log.txt + exit 1 + else + echo "✅ Code quality checks passed." + fi + + - name: Upload Quality Check Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: code-quality-artifacts + path: | + quality_report.txt + quality_error_log.txt + retention-days: 7 diff --git a/.github/workflows/validation-workflow.yml b/.github/workflows/validation-workflow.yml index 29f7e60..f1e1859 100644 --- a/.github/workflows/validation-workflow.yml +++ b/.github/workflows/validation-workflow.yml @@ -1,4 +1,4 @@ -## This workflow validates that branch and commit names are standardized for better workflow. +# This workflow validates that branch and commit names are standardized for better workflow. name: Validation Workflow @@ -14,13 +14,14 @@ jobs: validate-branch-name: runs-on: ubuntu-latest steps: - - name: Extract Branch Name + - name: Extract and Validate Branch Name run: | - echo "Branch name: ${{ github.ref_name }}" - BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///') - echo "Extracted branch name: $BRANCH_NAME" - - # Check branch naming convention + set -euo pipefail + echo "Validating branch name..." + + BRANCH_NAME="${{ github.ref_name }}" + echo "Branch name: $BRANCH_NAME" + if [[ "$BRANCH_NAME" =~ ^(qa|beta|main)$ ]]; then echo "✅ Branch name '$BRANCH_NAME' is valid for protected branches (qa, beta, main)." elif [[ "$BRANCH_NAME" =~ ^(feat|fix|hotfix|chore|test|refactor|release)/[a-z0-9_-]+$ ]]; then @@ -30,19 +31,23 @@ jobs: echo "Valid types: feat, fix, hotfix, chore, test, refactor, release, qa, beta, main" exit 1 fi - shell: bash validate-commit-messages: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Validate Commit Messages run: | - echo "Checking commit messages..." + set -euo pipefail + echo "Validating commit messages..." + REGEX="^(feat|fix|hotfix|chore|test|refactor|release)(\\([a-z0-9_-]+\\))?: .{1,72}$" - INVALID_COMMITS=$(git log --format=%s origin/main..HEAD | grep -vE "$REGEX" || true) + INVALID_COMMITS=$(git log --format=%s HEAD | grep -vE "$REGEX" || true) + if [[ -n "$INVALID_COMMITS" ]]; then echo "❌ The following commit messages do not follow the convention:" echo "$INVALID_COMMITS" @@ -56,4 +61,3 @@ jobs: else echo "✅ All commit messages follow the convention." fi - shell: bash