Skip to content

Commit 4dd0a50

Browse files
authored
Merge pull request #6 from d-oit/test-validation-branch
Test validation PR
2 parents 3342fec + aaebcba commit 4dd0a50

File tree

7 files changed

+165
-85
lines changed

7 files changed

+165
-85
lines changed

.github/workflows/auto-fix.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
auto-fix:
1414
name: Auto-fix Formatting and Clippy Issues
1515
runs-on: ubuntu-latest
16-
if: "!contains(github.event.head_commit.message, '[skip auto-fix]')"
16+
if: ${{ !contains(github.event.head_commit.message, '[skip auto-fix]') }}
1717

1818
steps:
1919
- uses: actions/checkout@v4
@@ -27,7 +27,7 @@ jobs:
2727
components: rustfmt, clippy
2828

2929
- name: Cache cargo registry
30-
uses: actions/cache@v3
30+
uses: actions/cache@v4
3131
with:
3232
path: |
3333
~/.cargo/registry
@@ -75,27 +75,33 @@ jobs:
7575
run: |
7676
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
7777
git config --local user.name "github-actions[bot]"
78-
78+
7979
# Check if there are changes to commit
8080
if ! git diff --quiet; then
8181
git add .
82-
82+
8383
# Create detailed commit message
84+
FORMAT_NEEDED="${FORMAT_NEEDED_VAR}"
85+
CLIPPY_NEEDED="${CLIPPY_NEEDED_VAR}"
8486
COMMIT_MSG="auto-fix: apply code quality fixes [skip auto-fix]"
85-
if [ "${{ steps.check.outputs.format_needed }}" = "true" ]; then
87+
if [ "$FORMAT_NEEDED" = "true" ]; then
8688
COMMIT_MSG="$COMMIT_MSG
8789
8890
- Apply cargo fmt formatting"
89-
fi
90-
if [ "${{ steps.check.outputs.clippy_needed }}" = "true" ]; then
91-
COMMIT_MSG="$COMMIT_MSG
91+
fi
92+
if [ "$CLIPPY_NEEDED" = "true" ]; then
93+
COMMIT_MSG="$COMMIT_MSG
94+
9295
- Apply clippy suggestions"
9396
fi
94-
97+
9598
git commit -m "$COMMIT_MSG"
9699
git push
97-
100+
98101
echo "✅ Code quality fixes applied and pushed!"
99102
else
100103
echo "ℹ️ No changes were made by the auto-fix tools."
101-
fi
104+
fi
105+
env:
106+
FORMAT_NEEDED_VAR: ${{ steps.check.outputs.format_needed }}
107+
CLIPPY_NEEDED_VAR: ${{ steps.check.outputs.clippy_needed }}

.github/workflows/ci.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,46 @@ jobs:
2828
- uses: actions/checkout@v4
2929

3030
- name: Install Rust
31-
uses: dtolnay/rust-toolchain@master
31+
uses: dtolnay/rust-toolchain@stable
3232
with:
3333
toolchain: ${{ matrix.rust }}
3434
components: rustfmt, clippy
3535

3636
- name: Cache cargo registry
37-
uses: actions/cache@v3
37+
uses: actions/cache@v4
3838
with:
3939
path: |
4040
~/.cargo/registry
4141
~/.cargo/git
4242
target
4343
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
44-
44+
4545
- name: Check formatting
4646
run: cargo fmt --all -- --check
4747
continue-on-error: true
4848
id: fmt-check
49-
49+
5050
- name: Formatting feedback
5151
if: steps.fmt-check.outcome == 'failure'
5252
run: |
53-
echo "Code formatting issues detected!"
53+
echo "::warning::Code formatting issues detected!"
5454
echo "Please run 'cargo fmt --all' to fix formatting."
5555
echo "Or add this to your pre-commit hook:"
5656
echo " cargo fmt --all"
57-
exit 1
58-
57+
5958
- name: Run clippy
6059
run: cargo clippy --all-targets --all-features -- -D warnings
61-
continue-on-error: true
60+
continue-on-error: true
6261
id: clippy-check
63-
62+
6463
- name: Clippy feedback
6564
if: steps.clippy-check.outcome == 'failure'
6665
run: |
67-
echo "Clippy issues detected!"
66+
echo "::warning::Clippy issues detected!"
6867
echo "Please run 'cargo clippy --all-targets --all-features --fix --allow-dirty' to fix issues."
6968
echo "Or add this to your development workflow:"
7069
echo " cargo clippy --fix --allow-dirty"
7170
echo "Or run './scripts/fix-code-quality.sh' to auto-fix both formatting and clippy issues."
72-
exit 1
7371
7472
- name: Build
7573
run: cargo build --verbose
@@ -93,15 +91,24 @@ jobs:
9391

9492
- name: Install cargo-llvm-cov
9593
uses: taiki-e/install-action@cargo-llvm-cov
96-
94+
95+
- name: Cache cargo registry
96+
uses: actions/cache@v4
97+
with:
98+
path: |
99+
~/.cargo/registry
100+
~/.cargo/git
101+
target
102+
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
103+
97104
- name: Generate code coverage
98-
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
105+
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
106+
99107
- name: Upload coverage report
100108
uses: actions/upload-artifact@v4
101109
with:
102110
name: coverage-report
103111
path: lcov.info
104-
105112

106113
security:
107114
name: Security Audit
@@ -119,6 +126,9 @@ jobs:
119126
name: Code Review Agent
120127
runs-on: ubuntu-latest
121128
if: github.event_name == 'pull_request'
129+
permissions:
130+
pull-requests: write
131+
contents: read
122132
steps:
123133
- uses: actions/checkout@v4
124134

@@ -132,6 +142,8 @@ jobs:
132142

133143
- name: Comment on PR if issues found
134144
if: failure()
135-
run: gh pr comment ${{ github.event.pull_request.number }} --body "Code review agent detected issues. Please address the clippy warnings."
145+
run: |
146+
gh pr comment $PR_NUMBER --body "Code review agent detected issues. Please address the clippy warnings."
136147
env:
137-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/docs.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Deploy Docs
33
on:
44
push:
55
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
68
workflow_dispatch:
79

810
permissions:
@@ -17,19 +19,20 @@ concurrency:
1719
jobs:
1820
build:
1921
runs-on: ubuntu-latest
22+
if: github.event_name != 'pull_request'
2023
steps:
2124
- uses: actions/checkout@v4
2225

2326
- name: Install Rust
2427
uses: dtolnay/rust-toolchain@stable
2528

2629
- name: Cache cargo registry
27-
uses: actions/cache@v3
30+
uses: actions/cache@v4
2831
with:
2932
path: |
3033
~/.cargo/registry
3134
~/.cargo/git
32-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
35+
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
3336

3437
- name: Build Documentation
3538
run: cargo doc --no-deps --workspace --document-private-items
@@ -57,7 +60,7 @@ jobs:
5760
uses: actions/configure-pages@v4
5861

5962
- name: Upload artifact
60-
uses: actions/upload-pages-artifact@v3
63+
uses: actions/upload-pages-artifact@v4
6164
with:
6265
path: ./target/doc
6366

@@ -67,6 +70,7 @@ jobs:
6770
url: ${{ steps.deployment.outputs.page_url }}
6871
runs-on: ubuntu-latest
6972
needs: build
73+
if: github.event_name != 'pull_request'
7074
steps:
7175
- name: Deploy to GitHub Pages
7276
id: deployment
@@ -76,6 +80,9 @@ jobs:
7680
name: Docs Agent
7781
runs-on: ubuntu-latest
7882
if: github.event_name == 'pull_request'
83+
permissions:
84+
pull-requests: write
85+
contents: read
7986
steps:
8087
- uses: actions/checkout@v4
8188

@@ -87,6 +94,8 @@ jobs:
8794

8895
- name: Comment on PR if docs issues
8996
if: failure()
90-
run: gh pr comment ${{ github.event.pull_request.number }} --body "Docs agent detected issues in documentation generation."
97+
run: |
98+
gh pr comment $PR_NUMBER --body "Docs agent detected issues in documentation generation."
9199
env:
92100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/monitor.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Monitor Workflows
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Daily at midnight UTC
6+
workflow_dispatch: # Allow manual trigger for testing
7+
8+
jobs:
9+
monitor:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
contents: read
14+
actions: read
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: List recent workflow runs
20+
run: |
21+
# Calculate date 24 hours ago in ISO 8601 format
22+
since=$(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ)
23+
echo "Fetching runs since: $since"
24+
25+
# Fetch recent runs with retry logic to handle rate limits
26+
max_retries=3
27+
retry_count=0
28+
while [ $retry_count -lt $max_retries ]; do
29+
if gh run list --created ">=$since" --limit 1000 --json number,status,conclusion,workflowName,createdAt,updatedAt > runs.json 2>/dev/null; then
30+
break
31+
else
32+
retry_count=$((retry_count + 1))
33+
echo "Retry $retry_count/$max_retries due to potential rate limit or error"
34+
sleep 60
35+
fi
36+
done
37+
38+
if [ $retry_count -eq $max_retries ]; then
39+
echo "Failed to fetch runs after $max_retries retries"
40+
exit 1
41+
fi
42+
43+
- name: Check for failures in monitored workflows
44+
run: |
45+
# Define monitored workflows (without .yml extension)
46+
workflows=("auto-fix" "CI" "docs" "release" "pages")
47+
48+
failures=()
49+
50+
for wf in "${workflows[@]}"; do
51+
# Find failed runs for this workflow
52+
failed_runs=$(jq -r ".[] | select(.workflowName == \"$wf\" and .conclusion == \"failure\") | \"Run #\\(.number) (\\(.createdAt))\"" runs.json 2>/dev/null || echo "")
53+
54+
if [ -n "$failed_runs" ] && [ "$failed_runs" != "null" ]; then
55+
failures+=("$wf workflow failures:")
56+
while IFS= read -r run; do
57+
failures+=(" - $run")
58+
done <<< "$failed_runs"
59+
failures+=("") # Empty line for separation
60+
fi
61+
done
62+
63+
if [ ${#failures[@]} -gt 0 ]; then
64+
echo "Failures detected:"
65+
printf '%s\n' "${failures[@]}"
66+
67+
# Prepare notification content
68+
title="Workflow Failures Detected - $(date -u +%Y-%m-%d)"
69+
body="The following workflows have failed in the last 24 hours:\n\n$(printf '%s\n' "${failures[@]}")\n\nPlease investigate the failed runs in the Actions tab."
70+
71+
# Check for existing open issue with similar title
72+
existing_issue=$(gh issue list --label "workflow-failure" --state open --json number,title --limit 10 | jq -r ".[] | select(.title | startswith(\"Workflow Failures Detected\")) | .number" | head -1)
73+
74+
if [ -z "$existing_issue" ]; then
75+
echo "Creating new issue for workflow failures"
76+
gh issue create --title "$title" --body "$body" --label "workflow-failure,bug"
77+
else
78+
echo "Commenting on existing issue #$existing_issue"
79+
gh issue comment "$existing_issue" --body "New failures detected:\n\n$body"
80+
fi
81+
else
82+
echo "No workflow failures detected in the last 24 hours."
83+
fi

0 commit comments

Comments
 (0)