From 4d9645bf23b7125b55c0c80663dd96d142c2ddfb Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Wed, 27 Nov 2024 19:49:23 -0500 Subject: [PATCH] chore: update contributor, validation, and qa workflows Signed-off-by: Jeremy Andrews --- .github/workflows/contributor-workflow.yml | 155 ++++++++++++++++++++- .github/workflows/qa-workflow.yml | 41 ++++++ .github/workflows/validation-workflow.yml | 20 ++- 3 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/qa-workflow.yml diff --git a/.github/workflows/contributor-workflow.yml b/.github/workflows/contributor-workflow.yml index 57ef8bc..d3605a6 100644 --- a/.github/workflows/contributor-workflow.yml +++ b/.github/workflows/contributor-workflow.yml @@ -1,5 +1,5 @@ -## This workflow runs on push events to any branch except main, qa, or beta. -## Allows contributors to push changes to feature branches or other non-protected branches for lightweight checks. +## This workflow analyzes the Dart Server SDK and a Go-feature-integration example project +## to identify issues and commits for resolution. name: Contributor Workflow @@ -11,9 +11,9 @@ on: - beta jobs: - contributor-checks: + analyze-core: + name: Analyze Core Dart Server SDK runs-on: ubuntu-latest - steps: - name: Checkout Code uses: actions/checkout@v3 @@ -24,7 +24,150 @@ jobs: dart-version: stable - name: Install Dependencies - run: dart pub get + run: | + echo "Installing dependencies for core SDK..." + cd dart-server-sdk-openfeature + if ! dart pub get; then + echo "❌ Failed to install dependencies for the core SDK. Exiting..." + exit 1 + fi + + - name: Run Static Analysis + run: | + echo "Running static analysis for core SDK..." + cd dart-server-sdk-openfeature + if ! dart analyze lib/ > analysis_report.txt 2> error_log.txt; then + echo "❌ Static analysis failed with errors. See details below:" + cat error_log.txt + exit 1 + else + echo "✅ Static analysis completed successfully. No critical errors found." + fi + + - name: Highlight Info, Warnings, and Errors + run: | + echo "Categorizing analysis results..." + cd dart-server-sdk-openfeature + grep -i "info" analysis_report.txt > info_report.txt || echo "No informational messages found." + 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." + + echo "Summary of analysis results:" + echo "Informational messages:" + cat info_report.txt || true + echo "" + echo "Warnings:" + cat warning_report.txt || true + echo "" + echo "Errors:" + cat error_report.txt || true + + - name: Identify Specific Commits for Easy Resolution + run: | + echo "Identifying specific commits for issues in the core SDK..." + cd dart-server-sdk-openfeature + while IFS= read -r line; do + file=$(echo $line | awk -F ':' '{print $1}') + if [[ -n "$file" ]]; then + git_log=$(git log -n 1 --pretty=format:"%h by %an <%ae>" -- "$file") + echo "File: $file" + echo "Issue: $line" + echo "Commit: $git_log" + else + echo "No file information could be extracted for: $line" + fi + done < analysis_report.txt + + - name: Upload Analysis Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: core-sdk-analysis + path: | + dart-server-sdk-openfeature/analysis_report.txt + dart-server-sdk-openfeature/error_log.txt + dart-server-sdk-openfeature/info_report.txt + dart-server-sdk-openfeature/warning_report.txt + dart-server-sdk-openfeature/error_report.txt + retention-days: 1 + + analyze-go-integration: + name: Analyze Go Feature Integration Example + runs-on: ubuntu-latest + needs: analyze-core + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: stable + + - name: Install Dependencies + run: | + echo "Installing dependencies for Go-feature-integration example..." + cd dart-server-sdk-openfeature/examples/go-feature-integration + if ! go mod tidy; then + echo "❌ Failed to install dependencies for Go example. Exiting..." + exit 1 + fi - name: Run Static Analysis - run: dart analyze + run: | + echo "Running static analysis for Go-feature-integration example..." + cd dart-server-sdk-openfeature/examples/go-feature-integration + if ! go vet ./... > analysis_report.txt 2> error_log.txt; then + echo "❌ Static analysis failed with errors. See details below:" + cat error_log.txt + exit 1 + else + echo "✅ Static analysis completed successfully. No critical errors found." + fi + + - name: Highlight Info, Warnings, and Errors + run: | + echo "Categorizing analysis results..." + cd dart-server-sdk-openfeature/examples/go-feature-integration + grep -i "info" analysis_report.txt > info_report.txt || echo "No informational messages found." + 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." + + echo "Summary of analysis results:" + echo "Informational messages:" + cat info_report.txt || true + echo "" + echo "Warnings:" + cat warning_report.txt || true + echo "" + echo "Errors:" + cat error_report.txt || true + + - name: Identify Specific Commits for Easy Resolution + run: | + echo "Identifying specific commits for issues in the Go-feature-integration example..." + cd dart-server-sdk-openfeature/examples/go-feature-integration + while IFS= read -r line; do + file=$(echo $line | awk -F ':' '{print $1}') + if [[ -n "$file" ]]; then + git_log=$(git log -n 1 --pretty=format:"%h by %an <%ae>" -- "$file") + echo "File: $file" + echo "Issue: $line" + echo "Commit: $git_log" + else + echo "No file information could be extracted for: $line" + fi + done < analysis_report.txt + + - name: Upload Analysis Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: go-integration-analysis + path: | + dart-server-sdk-openfeature/examples/go-feature-integration/analysis_report.txt + dart-server-sdk-openfeature/examples/go-feature-integration/error_log.txt + dart-server-sdk-openfeature/examples/go-feature-integration/info_report.txt + dart-server-sdk-openfeature/examples/go-feature-integration/warning_report.txt + dart-server-sdk-openfeature/examples/go-feature-integration/error_report.txt + retention-days: 1 diff --git a/.github/workflows/qa-workflow.yml b/.github/workflows/qa-workflow.yml new file mode 100644 index 0000000..d052895 --- /dev/null +++ b/.github/workflows/qa-workflow.yml @@ -0,0 +1,41 @@ +## This workflow runs on pull requests into the main qa. SDirect pushes to main are blocked. + +name: QA Workflow + +on: + pull_request: + branches: + - qa + +jobs: + qa-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Dart + uses: dart-lang/setup-dart@v1 + with: + dart-version: stable + + - name: Install Dependencies + run: dart pub get + + - name: Run Static Analysis + run: dart analyze + + - name: Run Unit Tests + run: dart test --coverage=coverage + + - name: Format Coverage Report + run: 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: Check Code Quality + run: dart pub global run dart_code_metrics:metrics analyze lib diff --git a/.github/workflows/validation-workflow.yml b/.github/workflows/validation-workflow.yml index 74110c3..29f7e60 100644 --- a/.github/workflows/validation-workflow.yml +++ b/.github/workflows/validation-workflow.yml @@ -1,4 +1,4 @@ -## This workflow valides 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 @@ -19,9 +19,15 @@ jobs: echo "Branch name: ${{ github.ref_name }}" BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///') echo "Extracted branch name: $BRANCH_NAME" - if [[ ! "$BRANCH_NAME" =~ ^(feature|fix|hotfix|chore|test|refactor|release|qa|beta|main)/[a-z0-9_-]+$ ]]; then + + # Check branch naming convention + 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 + echo "✅ Branch name '$BRANCH_NAME' follows the naming convention." + else echo "❌ Branch name '$BRANCH_NAME' does not follow the naming convention: /" - echo "Valid types: feature, fix, hotfix, chore, test, refactor, release, qa, beta, main" + echo "Valid types: feat, fix, hotfix, chore, test, refactor, release, qa, beta, main" exit 1 fi shell: bash @@ -40,6 +46,14 @@ jobs: if [[ -n "$INVALID_COMMITS" ]]; then echo "❌ The following commit messages do not follow the convention:" echo "$INVALID_COMMITS" + echo "" + echo "Commit message format must follow:" + echo "(): " + echo "Examples:" + echo " feat(auth): add OAuth 2.0 support" + echo " fix(payment): resolve rounding error in total calculation" exit 1 + else + echo "✅ All commit messages follow the convention." fi shell: bash