Skip to content

Fix flaky SqlDatabaseProjects test: give each project its own database #1259

Fix flaky SqlDatabaseProjects test: give each project its own database

Fix flaky SqlDatabaseProjects test: give each project its own database #1259

Workflow file for this run

name: Add Dogfooding Comment
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- 'main'
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to add dogfooding comment to'
required: true
type: number
jobs:
prepare-dogfood-comment:
if: ${{ github.repository_owner == 'CommunityToolkit' && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Write comment result artifact
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
mkdir -p "$RUNNER_TEMP/dogfood-comment"
jq -n \
--arg schema_version "dogfood-comment/v1" \
--arg event "pull_request" \
--arg head_sha "$PR_HEAD_SHA" \
--argjson pr_number "$PR_NUMBER" \
--arg run_id "$GITHUB_RUN_ID" \
'{schema_version:$schema_version,event:$event,head_sha:$head_sha,pr_number:$pr_number,run_id:$run_id}' \
> "$RUNNER_TEMP/dogfood-comment/result.json"
- name: Upload comment result artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dogfood-comment
path: ${{ runner.temp }}/dogfood-comment/result.json
if-no-files-found: error
retention-days: 3
add-dogfood-comment-manually:
if: ${{ github.repository_owner == 'CommunityToolkit' && github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add dogfooding comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const prNumber = context.payload.inputs.pr_number;
const bashScript = 'https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh';
const psScript = 'https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1';
// Unique marker to identify dogfooding comments
const dogfoodMarker = '<!-- dogfood-pr -->';
const comment = `${dogfoodMarker}
🚀 **Dogfood this PR with:**
> **⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.**
\`\`\`bash
curl -fsSL ${bashScript} | bash -s -- ${prNumber}
\`\`\`
Or
- Run remotely in PowerShell:
\`\`\`powershell
iex "& { $(irm ${psScript}) } ${prNumber}"
\`\`\``;
// Check for existing dogfooding comment
const comments = await github.rest.issues.listComments({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existingComment = comments.data.find(comment => comment.body.includes(dogfoodMarker));
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
comment_id: existingComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}