Skip to content

Commit

Permalink
Move to ado
Browse files Browse the repository at this point in the history
  • Loading branch information
Karim Eldegwy committed Apr 16, 2024
1 parent 7fa8063 commit 210c1c5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 35 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/check-multi-package-addition-removal.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
set -o pipefail

# Initialize the variable
echo "MULTI_PACKAGE_ADD_REMOVE_DETECTED=false" >> $GITHUB_ENV

# Setup RPM tools
source "$(git rev-parse --show-toplevel)"/toolkit/scripts/rpmops.sh

# Define directories to watch
SPEC_DIRS=("SPECS" "SPECS-EXTENDED")

# Initialize the variable to false
multi_package_add_remove_detected=false

# Fetch the latest state of the base branch
git fetch origin $GITHUB_BASE_REF

Expand All @@ -32,7 +32,7 @@ check_multi_package_add_remove() {
for package in "${!package_counts[@]}"; do
if [ "${package_counts[$package]}" -gt 1 ]; then
echo "Multi-package add/remove of .spec file detected: $package in $DIR"
echo "MULTI_PACKAGE_ADD_REMOVE_DETECTED=true" >> $GITHUB_ENV
multi_package_add_remove_detected=true
fi
done
}
Expand All @@ -47,4 +47,7 @@ for spec_dir in "${SPEC_DIRS[@]}"; do
# Check for duplicates in the directory
check_multi_package_add_remove "$dir_path"
done
done
done

# Print true or false based on detection of duplicates
echo $multi_package_add_remove_detected
70 changes: 40 additions & 30 deletions .github/workflows/check-multi-package.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Check Multi-package
trigger: none

on:
pull_request:
branches:
- karimeldegwy/*
paths:
- 'SPECS/**'
- 'SPECS-EXTENDED/**'
pr:
branches:
include:
- 1.0-dev
- main
- 3.0-dev
- karimeldegwy/**

permissions: 'write-all'
paths:
include:
- SPECS/**
- SPECS-EXTENDED/**

variables:
- group: "Agent pools (DEV)"

resources:
repositories:
- repository: CBL-Mariner-Pipelines
type: git
name: mariner/CBL-Mariner-Pipelines

jobs:
detect-changes:
runs-on: ubuntu-latest
- job: 'MultiPackageCheck'
pool:
name: "$(DEV_AMD64_Ubuntu_Managed)"
type: linux
isCustom: true
timeoutInMinutes: 15
displayName: 'Add reviewer if multi-package addition/removal detected'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensures history for all branches is available

- name: Check Multi-package addition/removal
run: |
.github/workflows/check-multi-package-addition-removal.sh
- script: |
echo "Checking for multi-package addition/removal"
result=$(./.github/workflows/check-multi-package-addition-removal.sh)
echo "##vso[task.setvariable variable=MULTI_PACKAGE_ADD_REMOVE_DETECTED;isOutput=true]$result"
displayName: 'Check Multi-package Addition/Removal'
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_BASE_REF: $(System.PullRequest.TargetBranch)
GITHUB_WORKSPACE: $(Build.SourcesDirectory)
name: checkMultiPackage
- name: Add Reviewer if Duplicates Found
if: env.MULTI_PACKAGE_ADD_REMOVE_DETECTED == 'true'
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/microsoft/azurelinux/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
-d '{"team_reviewers": ["cbl-mariner-multi-package-reviewers"]}'
- template: pipelines/multi-package/AddMultiPackTeamAsReviewer.yml@CBL-Mariner-Pipelines
condition: and(succeeded(), eq(dependencies.MultiPackageCheck.outputs['checkMultiPackage.MULTI_PACKAGE_ADD_REMOVE_DETECTED'], 'true'))
parameters:
prID: $(System.PullRequest.PullRequestId)

0 comments on commit 210c1c5

Please sign in to comment.