Skip to content

Commit d26988f

Browse files
authored
Merge branch 'microsoft:main' into ghc-custom-instructions
2 parents ce9bd4b + f8de0f8 commit d26988f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1749
-844
lines changed

.azdo/pipelines/azure-dev.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Set this to the mainline branch you are using
33
trigger:
44
- main
5-
- master
6-
- feature/azd-semantickernel
75

86
# Azure Pipelines workflow to deploy to Azure using azd
97
# To configure required secrets and service connection for connecting to Azure, simply run `azd pipeline config --provider azdo`

.devcontainer/setupEnv.sh

100644100755
File mode changed.

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
22
max-line-length = 88
33
extend-ignore = E501
4-
exclude = .venv, frontend
4+
exclude = .venv, frontend, src/backend/tests
55
ignore = E203, W503, G004, G200, E402

.github/dependabot.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
version: 2
55
updates:
6-
# GitHub Actions dependencies
6+
# GitHub Actions dependencies (grouped)
77
- package-ecosystem: "github-actions"
88
directory: "/"
99
schedule:
@@ -12,7 +12,12 @@ updates:
1212
prefix: "build"
1313
target-branch: "dependabotchanges"
1414
open-pull-requests-limit: 10
15+
groups:
16+
all-actions:
17+
patterns:
18+
- "*"
1519

20+
# Python pip dependencies (grouped)
1621
- package-ecosystem: "pip"
1722
directory: "/src/backend"
1823
schedule:
@@ -21,6 +26,10 @@ updates:
2126
prefix: "build"
2227
target-branch: "dependabotchanges"
2328
open-pull-requests-limit: 10
29+
groups:
30+
python-deps:
31+
patterns:
32+
- "*"
2433

2534
- package-ecosystem: "pip"
2635
directory: "/src/frontend"
@@ -29,4 +38,8 @@ updates:
2938
commit-message:
3039
prefix: "build"
3140
target-branch: "dependabotchanges"
32-
open-pull-requests-limit: 10
41+
open-pull-requests-limit: 10
42+
groups:
43+
python-deps:
44+
patterns:
45+
- "*"

.github/workflows/azure-dev.yml

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Azure Template Validation
22
on:
33
push:
44
branches:
5-
- dev
65
- main
7-
- feature/azd-semantickernel
86
workflow_dispatch:
97

108
permissions:
@@ -15,69 +13,19 @@ permissions:
1513
jobs:
1614
template_validation_job:
1715
runs-on: ubuntu-latest
18-
name: Template validation
16+
name: template validation
1917
steps:
20-
# Step 1: Checkout the code from your repository
21-
- name: Checkout code
22-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
2319

24-
# Step 2: Set up Python
25-
- name: Set up Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: "3.9"
29-
30-
# Step 3: Create and populate the virtual environment
31-
- name: Create virtual environment and install dependencies
32-
run: |
33-
python -m venv .venv
34-
source .venv/bin/activate
35-
python -m pip install --upgrade pip
36-
pip install azure-mgmt-resource azure-identity azure-core azure-mgmt-subscription azure-cli-core
37-
# Install any other dependencies that might be needed
38-
pip freeze > requirements-installed.txt
39-
echo "Virtual environment created with these packages:"
40-
cat requirements-installed.txt
41-
42-
# Step 4: Create azd directory if it doesn't exist
43-
- name: Create azd directory
44-
run: |
45-
mkdir -p ./.azd || true
46-
touch ./.azd/.env || true
47-
48-
# Step 5: Validate the Azure template
49-
- name: Validate Azure Template
50-
uses: microsoft/[email protected]
20+
- uses: microsoft/template-validation-action@Latest
5121
id: validation
5222
env:
53-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
54-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
55-
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
56-
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
57-
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
23+
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
24+
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
25+
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
26+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
27+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
5828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5929

60-
# Step 6: Debug output in case of failure
61-
- name: Debug on failure
62-
if: failure()
63-
run: |
64-
echo "Validation failed. Checking environment:"
65-
ls -la
66-
if [ -d ".venv" ]; then
67-
echo ".venv directory exists"
68-
ls -la .venv/bin/
69-
else
70-
echo ".venv directory does not exist"
71-
fi
72-
if [ -d "tva_*" ]; then
73-
echo "TVA directory exists:"
74-
find . -name "tva_*" -type d
75-
ls -la $(find . -name "tva_*" -type d)
76-
else
77-
echo "No TVA directory found"
78-
fi
79-
80-
# Step 7: Print the result of the validation
81-
- name: Print result
82-
if: success()
30+
- name: print result
8331
run: cat ${{ steps.validation.outputs.resultFile }}

.github/workflows/docker-build-and-push.yml

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
- dev
1919
- demo
2020
- hotfix
21-
workflow_dispatch:
21+
workflow_dispatch:
2222

2323
jobs:
2424
build-and-push:
@@ -32,14 +32,24 @@ jobs:
3232
uses: docker/setup-buildx-action@v1
3333

3434
- name: Log in to Azure Container Registry
35-
if: ${{ (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix') }}
35+
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
3636
uses: azure/docker-login@v2
3737
with:
38-
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
38+
login-server: ${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}
3939
username: ${{ secrets.ACR_USERNAME }}
4040
password: ${{ secrets.ACR_PASSWORD }}
4141

42-
- name: Set Docker image tag
42+
- name: Get current date
43+
id: date
44+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
45+
46+
- name: Get registry
47+
id: registry
48+
run: |
49+
echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io'}}" >> $GITHUB_OUTPUT
50+
51+
- name: Determine Tag Name Based on Branch
52+
id: determine_tag
4353
run: |
4454
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
4555
echo "TAG=latest" >> $GITHUB_ENV
@@ -52,24 +62,30 @@ jobs:
5262
else
5363
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
5464
fi
55-
56-
- name: Build and push Docker images optionally
65+
66+
- name: Set Historical Tag
5767
run: |
58-
cd src/backend
59-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
60-
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
61-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
62-
echo "Backend image built and pushed successfully."
63-
else
64-
echo "Skipping Docker push for backend with tag: ${{ env.TAG }}"
65-
fi
66-
cd ../frontend
67-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
68-
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
69-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
70-
echo "Frontend image built and pushed successfully."
71-
else
72-
echo "Skipping Docker push for frontend with tag: ${{ env.TAG }}"
73-
fi
68+
DATE_TAG=$(date +'%Y-%m-%d')
69+
RUN_ID=${{ github.run_number }}
70+
# Create historical tag using TAG, DATE_TAG, and RUN_ID
71+
echo "HISTORICAL_TAG=${{ env.TAG }}_${DATE_TAG}_${RUN_ID}" >> $GITHUB_ENV
7472
75-
73+
- name: Build and optionally push Backend Docker image
74+
uses: docker/build-push-action@v6
75+
with:
76+
context: ./src/backend
77+
file: ./src/backend/Dockerfile
78+
push: ${{ env.TAG != 'pullrequest-ignore' }}
79+
tags: |
80+
${{ steps.registry.outputs.ext_registry }}/macaebackend:${{ env.TAG }}
81+
${{ steps.registry.outputs.ext_registry }}/macaebackend:${{ env.HISTORICAL_TAG }}
82+
83+
- name: Build and optionally push Frontend Docker image
84+
uses: docker/build-push-action@v6
85+
with:
86+
context: ./src/frontend
87+
file: ./src/frontend/Dockerfile
88+
push: ${{ env.TAG != 'pullrequest-ignore' }}
89+
tags: |
90+
${{ steps.registry.outputs.ext_registry }}/macaefrontend:${{ env.TAG }}
91+
${{ steps.registry.outputs.ext_registry }}/macaefrontend:${{ env.HISTORICAL_TAG }}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# ------------------------------------------------------------------------------
2+
# Scheduled Dependabot PRs Auto-Merge Workflow
3+
#
4+
# Purpose:
5+
# - Automatically detect, rebase (if needed), and merge Dependabot PRs targeting
6+
# the `dependabotchanges` branch, supporting different merge strategies.
7+
#
8+
# Features:
9+
# ✅ Filters PRs authored by Dependabot and targets the specific base branch
10+
# ✅ Rebases PRs with conflicts and auto-resolves using "prefer-theirs" strategy
11+
# ✅ Attempts all three merge strategies: merge, squash, rebase (first success wins)
12+
# ✅ Handles errors gracefully, logs clearly
13+
#
14+
# Triggers:
15+
# - Scheduled daily run (midnight UTC)
16+
# - Manual trigger (via GitHub UI)
17+
#
18+
# Required Permissions:
19+
# - contents: write
20+
# - pull-requests: write
21+
# ------------------------------------------------------------------------------
22+
23+
name: Scheduled Dependabot PRs Auto-Merge
24+
25+
on:
26+
schedule:
27+
- cron: '0 0 * * *' # Runs once a day at midnight UTC
28+
workflow_dispatch:
29+
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
34+
jobs:
35+
merge-dependabot:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
- name: Install GitHub CLI
42+
run: |
43+
sudo apt update
44+
sudo apt install -y gh
45+
- name: Fetch & Filter Dependabot PRs
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
echo "🔍 Fetching all Dependabot PRs targeting 'dependabotchanges'..."
50+
> matched_prs.txt
51+
pr_batch=$(gh pr list --state open --json number,title,author,baseRefName,url \
52+
--jq '.[] | "\(.number)|\(.title)|\(.author.login)|\(.baseRefName)|\(.url)"')
53+
while IFS='|' read -r number title author base url; do
54+
author=$(echo "$author" | xargs)
55+
base=$(echo "$base" | xargs)
56+
if [[ "$author" == "app/dependabot" && "$base" == "dependabotchanges" ]]; then
57+
echo "$url" >> matched_prs.txt
58+
echo "✅ Matched PR #$number - $title"
59+
else
60+
echo "❌ Skipped PR #$number - $title (Author: $author, Base: $base)"
61+
fi
62+
done <<< "$pr_batch"
63+
echo "👉 Matched PRs:"
64+
cat matched_prs.txt || echo "None"
65+
- name: Rebase PR if Conflicts Exist
66+
if: success()
67+
env:
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run: |
70+
if [[ ! -s matched_prs.txt ]]; then
71+
echo "⚠️ No matching PRs to process."
72+
exit 0
73+
fi
74+
while IFS= read -r pr_url; do
75+
pr_number=$(basename "$pr_url")
76+
echo "🔁 Checking PR #$pr_number for conflicts..."
77+
mergeable=$(gh pr view "$pr_number" --json mergeable --jq '.mergeable')
78+
if [[ "$mergeable" == "CONFLICTING" ]]; then
79+
echo "⚠️ Merge conflicts detected. Performing manual rebase for PR #$pr_number..."
80+
head_branch=$(gh pr view "$pr_number" --json headRefName --jq '.headRefName')
81+
base_branch=$(gh pr view "$pr_number" --json baseRefName --jq '.baseRefName')
82+
git fetch origin "$base_branch":"$base_branch"
83+
git fetch origin "$head_branch":"$head_branch"
84+
git checkout "$head_branch"
85+
git config user.name "github-actions"
86+
git config user.email "[email protected]"
87+
# Attempt rebase with 'theirs' strategy
88+
if git rebase --strategy=recursive -X theirs "$base_branch"; then
89+
echo "✅ Rebase successful. Pushing..."
90+
git push origin "$head_branch" --force
91+
else
92+
echo "❌ Rebase failed. Aborting..."
93+
git rebase --abort || true
94+
fi
95+
else
96+
echo "✅ PR #$pr_number is mergeable. Skipping rebase."
97+
fi
98+
done < matched_prs.txt
99+
100+
- name: Auto-Merge PRs using available strategy
101+
if: success()
102+
env:
103+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
run: |
105+
if [[ ! -s matched_prs.txt ]]; then
106+
echo "⚠️ No matching PRs to process."
107+
exit 0
108+
fi
109+
while IFS= read -r pr_url; do
110+
pr_number=$(basename "$pr_url")
111+
echo "🔍 Checking mergeability for PR #$pr_number"
112+
attempt=0
113+
max_attempts=8
114+
mergeable=""
115+
sleep 5 # Let GitHub calculate mergeable status
116+
while [[ $attempt -lt $max_attempts ]]; do
117+
mergeable=$(gh pr view "$pr_number" --json mergeable --jq '.mergeable' 2>/dev/null || echo "UNKNOWN")
118+
echo "🔁 Attempt $((attempt+1))/$max_attempts: mergeable=$mergeable"
119+
if [[ "$mergeable" == "MERGEABLE" ]]; then
120+
success=0
121+
for strategy in rebase squash merge; do
122+
echo "🚀 Trying to auto-merge PR #$pr_number using '$strategy' strategy..."
123+
set -x
124+
merge_output=$(gh pr merge --auto --"$strategy" "$pr_url" 2>&1)
125+
merge_status=$?
126+
set +x
127+
echo "$merge_output"
128+
if [[ $merge_status -eq 0 ]]; then
129+
echo "✅ Auto-merge succeeded using '$strategy'."
130+
success=1
131+
break
132+
else
133+
echo "❌ Auto-merge failed using '$strategy'. Trying next strategy..."
134+
fi
135+
done
136+
if [[ $success -eq 0 ]]; then
137+
echo "❌ All merge strategies failed for PR #$pr_number"
138+
fi
139+
break
140+
elif [[ "$mergeable" == "CONFLICTING" ]]; then
141+
echo "❌ Cannot merge due to conflicts. Skipping PR #$pr_number"
142+
break
143+
else
144+
echo "🕒 Waiting for GitHub to determine mergeable status..."
145+
sleep 15
146+
fi
147+
((attempt++))
148+
done
149+
if [[ "$mergeable" != "MERGEABLE" && "$mergeable" != "CONFLICTING" ]]; then
150+
echo "❌ Mergeability undetermined after $max_attempts attempts. Skipping PR #$pr_number"
151+
fi
152+
done < matched_prs.txt || echo "⚠️ Completed loop with some errors, but continuing gracefully."

0 commit comments

Comments
 (0)