fix(dc-init): skip dev-control repo in batch update #193
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: Bash Linting | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| - develop | |
| paths: | |
| - '**.sh' | |
| - '.github/workflows/bash-lint.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| - develop | |
| paths: | |
| - '**.sh' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| shellcheck: | |
| name: ShellCheck Linting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install ShellCheck | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y shellcheck | |
| - name: Verify ShellCheck installation | |
| run: shellcheck --version | |
| - name: Find all shell scripts | |
| id: find_scripts | |
| run: | | |
| SCRIPTS=$(find . -type f -name "*.sh" ! -path "./.git/*" ! -path "./node_modules/*" ! -path "./vendor/*") | |
| echo "scripts<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$SCRIPTS" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| echo "Script count: $(echo "$SCRIPTS" | wc -l)" | |
| - name: Run ShellCheck on all shell scripts | |
| id: shellcheck | |
| continue-on-error: true | |
| run: | | |
| FAILED=0 | |
| while IFS= read -r script; do | |
| if [[ -n "$script" ]]; then | |
| echo "🔍 Linting: $script" | |
| if ! shellcheck -x "$script"; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| fi | |
| done <<< "${{ steps.find_scripts.outputs.scripts }}" | |
| if [[ $FAILED -gt 0 ]]; then | |
| echo "❌ $FAILED script(s) failed linting" | |
| exit 1 | |
| else | |
| echo "✅ All scripts passed linting" | |
| exit 0 | |
| fi | |
| - name: Summary report | |
| if: always() | |
| run: | | |
| echo "## Bash Linting Report" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "**Tool**: ShellCheck" >> "$GITHUB_STEP_SUMMARY" | |
| echo "**Status**: ${{ job.status }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "### Best Practices Applied" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- ✓ Use \`set -e\` for error handling" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- ✓ Quote variables to prevent word splitting" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- ✓ Use \`[[ ]]\` for conditionals" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- ✓ Add meaningful comments" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- ✓ Break scripts into functions" >> "$GITHUB_STEP_SUMMARY" | |
| bash-formatting: | |
| name: Bash Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Check for common issues | |
| continue-on-error: true | |
| run: | | |
| echo "🔍 Checking bash script quality..." | |
| ISSUES=0 | |
| # Find all shell scripts | |
| while IFS= read -r script; do | |
| if [[ -n "$script" ]]; then | |
| echo "" | |
| echo "📄 Checking: $script" | |
| # Check for set -e | |
| if ! grep -q "set -e" "$script"; then | |
| echo " ⚠️ Consider adding 'set -e' for error handling" | |
| fi | |
| # Check for proper shebang | |
| if ! head -n1 "$script" | grep -q "#!/usr/bin/env bash"; then | |
| echo " ⚠️ Should use '#!/usr/bin/env bash' shebang" | |
| fi | |
| # Check for unquoted variables | |
| if grep -E '\$[A-Za-z_]+[A-Za-z0-9_]*[^"]' "$script" | grep -v '^\s*#' > /dev/null; then | |
| echo " ⚠️ Found potentially unquoted variables" | |
| fi | |
| fi | |
| done < <(find . -type f -name "*.sh" ! -path "./.git/*" ! -path "./node_modules/*" ! -path "./vendor/*") | |
| test-scripts: | |
| name: Run Bash Script Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y git | |
| - name: Test bash scripts (basic syntax) | |
| continue-on-error: true | |
| run: | | |
| echo "🧪 Testing bash script syntax..." | |
| while IFS= read -r script; do | |
| if [[ -n "$script" ]]; then | |
| echo "Testing: $script" | |
| bash -n "$script" || echo " ❌ Syntax error in $script" | |
| fi | |
| done < <(find . -type f -name "*.sh" ! -path "./.git/*" ! -path "./node_modules/*" ! -path "./vendor/*") | |
| report: | |
| name: Linting Report | |
| runs-on: ubuntu-latest | |
| needs: [shellcheck, bash-formatting, test-scripts] | |
| if: always() | |
| steps: | |
| - name: Check workflow status | |
| run: | | |
| if [[ "${{ needs.shellcheck.result }}" == "failure" ]]; then | |
| echo "❌ ShellCheck failed - please fix linting errors" | |
| exit 1 | |
| fi | |
| echo "✅ All checks passed!" |