-
Notifications
You must be signed in to change notification settings - Fork 43
👷 DOP-5399 adds Osiris Coverage GHA #638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
199efe7
👷 DOP-5399 adds Osiris Coverage GHA
caesarbell 6e595a7
🎨 DOP-5399 points to the correct branhc
caesarbell 2cbc4ee
🎨 DOP-5399 points to the correct branch
caesarbell 35aed1a
🔧 DOP-5399 updates to point to the working branch
caesarbell 9ff88ac
🔧 DOP-5399 temp set the required threshold
caesarbell 932ed33
🔧 DOP-5399 uses actions/checkout method and removed dup cloning approach
caesarbell 5e4457c
🔧 DOP-5399 removes the workflow_dispatch event from the yaml config
caesarbell 6733cdf
🔧 Value and add-netlify-links ignores ast files and osiris action use…
caesarbell de41ed0
🔧 DOP-5399 ignores ast files
caesarbell ea395d1
✨ DOP-5399 remove the osiris.toml file along with removing all test b…
caesarbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Coverage Check for Osiris Generated AST files | ||
on: | ||
pull_request: | ||
paths: | ||
- '**/*.ast' # Only trigger if .ast files are changed | ||
branches: | ||
- main | ||
- DOP-5399-CB | ||
workflow_dispatch: | ||
rayangler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
caesarbell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
check-coverage: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
site_coverage_list: ${{ steps.set_coverage.outputs.site_coverage_list }} | ||
coverage_below_threshold: ${{ steps.set_coverage.outputs.coverage_below_threshold }} | ||
|
||
steps: | ||
- name: Checkout Repos | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Wget | ||
run: sudo apt-get update && sudo apt-get install -y wget | ||
|
||
- name: Clone Docs Java | ||
run: git clone --branch DOP-5399-CB https://github.com/mongodb/docs-java.git cloned-docs-java-repo | ||
rayangler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Clone Osiris | ||
run: git clone https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/10gen/osiris.git cloned-osiris-repo | ||
rayangler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Run Coverage Check | ||
id: run_coverage | ||
run: | | ||
cd cloned-osiris-repo | ||
npm ci | ||
COVERAGE_OUTPUT=$(npm run dev -- -c "$GITHUB_WORKSPACE/cloned-docs-java-repo" -v --sp 95) | ||
|
||
REQUIRED_COVERAGE=90.0 | ||
|
||
# Extract all Average Coverage values below the threshold | ||
SITE_COVERAGE_LIST=$(echo "$COVERAGE_OUTPUT" | awk -v threshold=$REQUIRED_COVERAGE ' | ||
/Average Coverage:/ { | ||
coverage = $3 + 0; | ||
if (coverage < threshold) { | ||
low_coverage_detected = 1; | ||
last_coverage = coverage; | ||
} else { | ||
low_coverage_detected = 0; | ||
} | ||
} | ||
/Finished processing site "/ { | ||
if (low_coverage_detected) { | ||
site = $4; | ||
gsub(/"/, "", site); # Extract site name | ||
print site ":" last_coverage; # Store as site:coverage | ||
} | ||
} | ||
' | paste -sd ',' - ) | ||
|
||
# Print detected values | ||
echo "Detected Coverage Below Threshold: $SITE_COVERAGE_LIST" | ||
|
||
echo "Required Coverage: $REQUIRED_COVERAGE" | ||
|
||
# Check if SITE_COVERAGE_LIST is empty or not | ||
if [ -n "$SITE_COVERAGE_LIST" ]; then | ||
echo "Test coverage is below the required threshold ($REQUIRED_COVERAGE%)." | ||
echo "coverage_below_threshold=true" >> $GITHUB_ENV | ||
echo "SITE_COVERAGE_LIST=$SITE_COVERAGE_LIST" >> $GITHUB_ENV | ||
else | ||
echo "Test coverage meets the required threshold." | ||
echo "coverage_below_threshold=false" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Set Workflow Outputs | ||
id: set_coverage | ||
run: | | ||
echo "coverage_below_threshold=${coverage_below_threshold}" >> $GITHUB_OUTPUT | ||
echo "site_coverage_list=${SITE_COVERAGE_LIST}" >> $GITHUB_OUTPUT | ||
|
||
send-slack-notification: | ||
runs-on: ubuntu-latest | ||
needs: check-coverage | ||
if: needs.check-coverage.outputs.coverage_below_threshold == 'true' | ||
rayangler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
steps: | ||
- name: Send Slack Notification | ||
env: | ||
SITE_COVERAGE_LIST: ${{ needs.check-coverage.outputs.site_coverage_list }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
REPOSITORY: ${{ github.repository }} | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
PR_SHA: ${{ github.event.pull_request.head.sha }} | ||
run: | | ||
TEXT_MESSAGE="⚠️ *Test Coverage Alert* ⚠️\n\nThe test coverage is below the required threshold of 90%.\n\n*Sites with Low Coverage:* \n" | ||
|
||
IFS=',' read -r -a SITE_COVERAGE_ARRAY <<< "$SITE_COVERAGE_LIST" | ||
|
||
for item in "${SITE_COVERAGE_ARRAY[@]}"; do | ||
site_name="${item%%:*}" | ||
coverage_value="${item##*:}" | ||
TEXT_MESSAGE+="• ${site_name}: ${coverage_value}%\n" | ||
done | ||
|
||
TEXT_MESSAGE+="\n*Repository:* <https://github.com/$REPOSITORY|$REPOSITORY>\n" | ||
TEXT_MESSAGE+="*PR Title:* $PR_TITLE\n" | ||
TEXT_MESSAGE+="*PR Number:* #$PR_NUMBER\n" | ||
TEXT_MESSAGE+="*PR URL:* <$PR_URL|View PR>\n" | ||
TEXT_MESSAGE+="*Commit SHA:* \`$PR_SHA\`\n\n" | ||
TEXT_MESSAGE+="Please review the test coverage and take action if necessary." | ||
|
||
curl -v -X POST -H 'Content-type: application/json' \ | ||
--data '{"text": "'"$TEXT_MESSAGE"'"}' \ | ||
$SLACK_WEBHOOK_URL |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,7 @@ giza.log | |
.vscode* | ||
*.swp | ||
*.code-workspace | ||
|
||
# GitHub Actions | ||
.secrets | ||
event.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[[sites]] | ||
name = "java-sync" | ||
url = "https://mongodb.github.io/mongo-java-driver/5.2/apidocs/mongodb-driver-sync/index.html" | ||
site_type = "java" | ||
source_dir = "source" | ||
output = "api-documentation/java-sync" | ||
|
||
[sites.href_mapping] | ||
"*//mongodb.github.io/mongo-java-driver/*/apidocs/mongodb-driver-sync/" = "/api-documentation/java-sync/" | ||
|
||
[[sites]] | ||
name = "core" | ||
url = "https://mongodb.github.io/mongo-java-driver/5.2/apidocs/mongodb-driver-core/index.html" | ||
site_type = "java" | ||
source_dir = "source" | ||
output = "api-documentation/core" | ||
|
||
[sites.href_mapping] | ||
"*//mongodb.github.io/mongo-java-driver/*/apidocs/mongodb-driver-core/" = "/api-documentation/core/" | ||
|
||
[[sites]] | ||
name = "scala" | ||
url = "https://mongodb.github.io/mongo-java-driver/5.1/apidocs/mongo-scala-driver/index.html" | ||
site_type = "scala" | ||
source_dir = "source" | ||
output = "api-documentation/scala" | ||
|
||
[sites.href_mapping] | ||
"*//mongodb.github.io/mongo-java-driver/*/apidocs/mongo-scala-driver/" = "/api-documentation/scala/" | ||
|
||
[[sites]] | ||
name = "kotlin" | ||
url = "https://mongodb.github.io/mongo-java-driver/5.3/apidocs/mongodb-driver-kotlin-sync/index.html" | ||
site_type = "kotlin" | ||
source_dir = "source" | ||
output = "api-documentation/kotlin" | ||
|
||
[sites.href_mapping] | ||
"*//mongodb.github.io/mongo-java-driver/*/apidocs/mongodb-driver-kotlin-sync/" = "/api-documentation/kotlin/" | ||
rayangler marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.