From bcf287ed310a4e21e464f6f919db0cc5913d62f6 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 22 Jul 2024 18:05:57 -0400 Subject: [PATCH 01/38] TEMP: Modify Maintainers.txt for testing --- Maintainers.txt | 531 +----------------------------------------------- 1 file changed, 6 insertions(+), 525 deletions(-) diff --git a/Maintainers.txt b/Maintainers.txt index d22929b85b97..9161cde83c13 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -134,543 +134,24 @@ R: Liming Gao [lgao4] EDK II Packages: ---------------- -ArmPkg -F: ArmPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/ArmPkg -M: Leif Lindholm [leiflindholm] -M: Ard Biesheuvel [ardbiesheuvel] -R: Sami Mujawar [samimujawar] - -ArmPlatformPkg -F: ArmPlatformPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/ArmPlatformPkg -M: Leif Lindholm [leiflindholm] -M: Ard Biesheuvel [ardbiesheuvel] - -ArmVirtPkg -F: ArmVirtPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/ArmVirtPkg -M: Ard Biesheuvel [ardbiesheuvel] -R: Leif Lindholm [leiflindholm] -R: Sami Mujawar [samimujawar] -R: Gerd Hoffmann [kraxel] - -BaseTools -F: BaseTools/ -W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools -M: Rebecca Cran [bcran] -M: Liming Gao [lgao4] -R: Bob Feng [BobCF] -R: Yuwei Chen [YuweiChen1110] - -BaseTools: Plugins -F: BaseTools/Plugin/ -M: Sean Brogan [spbrogan] -M: Joey Vagedes [javagedes] -R: Michael D Kinney [mdkinney] -R: Liming Gao [lgao4] - CryptoPkg F: CryptoPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/CryptoPkg -M: Jiewen Yao [jyao1] -M: Yi Li [liyi77] -R: Wenxing Hou [Wenxing-hou] - -DynamicTablesPkg -F: DynamicTablesPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/DynamicTablesPkg -M: Sami Mujawar [samimujawar] -M: Pierre Gondois [pierregondois] - -EmbeddedPkg -F: EmbeddedPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/EmbeddedPkg -M: Leif Lindholm [leiflindholm] -M: Ard Biesheuvel [ardbiesheuvel] -M: Abner Chang [changab] - -EmulatorPkg -F: EmulatorPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg -M: Andrew Fish [ajfish] -M: Ray Ni [niruiyu] -S: Maintained - -EmulatorPkg: Redfish-related modules -F: EmulatorPkg/*Redfish* -M: Abner Chang [changab] -M: Nickle Wang [nicklela] - -FatPkg -F: FatPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/Edk2-fat-driver -M: Ray Ni [niruiyu] -T: svn - https://svn.code.sf.net/p/edk2-fatdriver2/code/trunk/EnhancedFat -T: git - https://github.com/tianocore/edk2-FatPkg.git - -FmpDevicePkg -F: FmpDevicePkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/FmpDevicePkg -M: Liming Gao [lgao4] -M: Michael D Kinney [mdkinney] -R: Wei6 Xu [xuweiintel] - -IntelFsp2Pkg -F: IntelFsp2Pkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg -M: Chasel Chiu [ChaselChiu] -M: Nate DeSimone [nate-desimone] -M: Duggapu Chinni B [cbduggap] -R: Star Zeng [lzeng14] -R: Ted Kuo [tedkuo1] -R: Ashraf Ali S [AshrafAliS] -R: Susovan Mohapatra [susovanmohapatra] - -IntelFsp2WrapperPkg -F: IntelFsp2WrapperPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2WrapperPkg -M: Chasel Chiu [ChaselChiu] -M: Nate DeSimone [nate-desimone] -M: Duggapu Chinni B [cbduggap] -M: Chen Gang C [chengangc] -R: Star Zeng [lzeng14] -R: Ted Kuo [tedkuo1] -R: Ashraf Ali S [AshrafAliS] -R: Susovan Mohapatra [susovanmohapatra] +M: Project Mu UEFI Bot [uefibot] +M: Project Mu Bot [ProjectMuBot] +R: Michael Kubacki [makubacki] MdeModulePkg F: MdeModulePkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/MdeModulePkg -M: Liming Gao [lgao4] - -MdeModulePkg: ACPI modules -F: MdeModulePkg/Include/*Acpi*.h -F: MdeModulePkg/Universal/Acpi/ -R: Zhiguang Liu [LiuZhiguang001] -R: Dandan Bi [dandanbi] -R: Liming Gao [lgao4] - -MdeModulePkg: BDS modules -F: MdeModulePkg/*BootManager*/ -F: MdeModulePkg/Include/Library/UefiBootManagerLib.h -F: MdeModulePkg/Universal/BdsDxe/ -F: MdeModulePkg/Universal/DevicePathDxe/ -F: MdeModulePkg/Universal/DriverHealthManagerDxe/ -F: MdeModulePkg/Universal/LoadFileOnFv2/ -F: MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.* -R: Zhichao Gao [ZhichaoGao] -R: Ray Ni [niruiyu] - -MdeModulePkg: Console and Graphics modules -F: MdeModulePkg/*Logo*/ -F: MdeModulePkg/Include/*Logo*.h -F: MdeModulePkg/Include/Guid/ConnectConInEvent.h -F: MdeModulePkg/Include/Guid/Console*.h -F: MdeModulePkg/Include/Guid/StandardErrorDevice.h -F: MdeModulePkg/Include/Guid/TtyTerm.h -F: MdeModulePkg/Include/Library/BmpSupportLib.h -F: MdeModulePkg/Include/Library/FrameBufferBltLib.h -F: MdeModulePkg/Library/BaseBmpSupportLib/ -F: MdeModulePkg/Library/FrameBufferBltLib/ -F: MdeModulePkg/Universal/Console/ -R: Zhichao Gao [ZhichaoGao] - -MdeModulePkg: Core services (PEI, DXE and Runtime) modules -F: MdeModulePkg/*Mem*/ -F: MdeModulePkg/*SectionExtract*/ -F: MdeModulePkg/*StatusCode*/ -F: MdeModulePkg/Application/DumpDynPcd/ -F: MdeModulePkg/Core/Dxe/ -F: MdeModulePkg/Core/DxeIplPeim/ -F: MdeModulePkg/Core/RuntimeDxe/ -F: MdeModulePkg/Include/*Mem*.h -F: MdeModulePkg/Include/*Pcd*.h -F: MdeModulePkg/Include/*Perf*.h -F: MdeModulePkg/Include/*StatusCode*.h -F: MdeModulePkg/Include/Guid/Crc32GuidedSectionExtraction.h -F: MdeModulePkg/Include/Guid/EventExitBootServiceFailed.h -F: MdeModulePkg/Include/Guid/IdleLoopEvent.h -F: MdeModulePkg/Include/Guid/LoadModuleAtFixedAddress.h -F: MdeModulePkg/Include/Guid/LzmaDecompress.h -F: MdeModulePkg/Include/Library/SecurityManagementLib.h -F: MdeModulePkg/Library/*Decompress*/ -F: MdeModulePkg/Library/*Perf*/ -F: MdeModulePkg/Library/DxeSecurityManagementLib/ -F: MdeModulePkg/Universal/PCD/ -F: MdeModulePkg/Universal/PlatformDriOverrideDxe/ -F: MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c -R: Liming Gao [lgao4] - -MdeModulePkg: Device and Peripheral modules -F: MdeModulePkg/*PciHostBridge*/ -F: MdeModulePkg/Bus/ -F: MdeModulePkg/Include/*Ata*.h -F: MdeModulePkg/Include/*IoMmu*.h -F: MdeModulePkg/Include/*NonDiscoverableDevice*.h -F: MdeModulePkg/Include/*NvmExpress*.h -F: MdeModulePkg/Include/*SdMmc*.h -F: MdeModulePkg/Include/*Ufs*.h -F: MdeModulePkg/Include/*Usb*.h -F: MdeModulePkg/Include/Guid/RecoveryDevice.h -F: MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h -F: MdeModulePkg/Include/Library/PciHostBridgeLib.h -F: MdeModulePkg/Include/Ppi/StorageSecurityCommand.h -F: MdeModulePkg/Include/Protocol/Ps2Policy.h -F: MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/ -F: MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/ -R: Ray Ni [niruiyu] - -MdeModulePkg: Disk modules -F: MdeModulePkg/Universal/Disk/ -R: Ray Ni [niruiyu] -R: Zhichao Gao [ZhichaoGao] - -MdeModulePkg: Firmware Update modules -F: MdeModulePkg/*Capsule*/ -F: MdeModulePkg/Include/*Capsule*.h -F: MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h -F: MdeModulePkg/Include/Library/FmpAuthenticationLib.h -F: MdeModulePkg/Include/Protocol/EsrtManagement.h -F: MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h -F: MdeModulePkg/Library/DisplayUpdateProgressLib*/ -F: MdeModulePkg/Library/FmpAuthenticationLibNull/ -F: MdeModulePkg/Universal/Esrt*/ -R: Liming Gao [lgao4] - -MdeModulePkg: HII and UI modules -F: MdeModulePkg/*FileExplorer*/ -F: MdeModulePkg/*Hii*/ -F: MdeModulePkg/*Ui*/ -F: MdeModulePkg/Application/BootManagerMenuApp/ -F: MdeModulePkg/Include/*FileExplorer*.h -F: MdeModulePkg/Include/*FormBrowser*.h -F: MdeModulePkg/Include/*Hii*.h -F: MdeModulePkg/Include/Library/CustomizedDisplayLib.h -F: MdeModulePkg/Include/Protocol/DisplayProtocol.h -F: MdeModulePkg/Library/CustomizedDisplayLib/ -F: MdeModulePkg/Universal/DisplayEngineDxe/ -F: MdeModulePkg/Universal/DriverSampleDxe/ -F: MdeModulePkg/Universal/SetupBrowserDxe/ -R: Dandan Bi [dandanbi] - -MdeModulePkg: Management Mode (MM, SMM) modules -F: MdeModulePkg/*Smi*/ -F: MdeModulePkg/*Smm*/ -F: MdeModulePkg/Include/*Smi*.h -F: MdeModulePkg/Include/*Smm*.h -R: Jiaxin Wu [jiaxinwu] -R: Ray Ni [niruiyu] - -MdeModulePkg: Pei Core -F: MdeModulePkg/Core/Pei/ -R: Liming Gao [lgao4] - -MdeModulePkg: Reset modules -F: MdeModulePkg/*Reset*/ -F: MdeModulePkg/Include/*Reset*.h -R: Zhichao Gao [ZhichaoGao] - -MdeModulePkg: Serial modules -F: MdeModulePkg/*Serial*/ -F: MdeModulePkg/Include/*SerialPort*.h -R: Zhichao Gao [ZhichaoGao] - -MdeModulePkg: SMBIOS modules -F: MdeModulePkg/Universal/Smbios*/ -R: Zhiguang Liu [LiuZhiguang001] -R: Dandan Bi [dandanbi] -R: Star Zeng [lzeng14] -R: Zhichao Gao [ZhichaoGao] - -MdeModulePkg: UEFI Variable modules -F: MdeModulePkg/*Var*/ -F: MdeModulePkg/Include/*/*FaultTolerantWrite*.h -F: MdeModulePkg/Include/*/*Var*.h -F: MdeModulePkg/Include/Guid/SystemNvDataGuid.h -F: MdeModulePkg/Include/Protocol/SwapAddressRange.h -F: MdeModulePkg/Universal/FaultTolerantWrite*/ -R: Liming Gao [lgao4] - -MdeModulePkg: Universal Payload definitions -F: MdeModulePkg/Include/UniversalPayload/ -R: Zhiguang Liu [LiuZhiguang001] -R: Gua Guo [gguo11837463] - -MdeModulePkg: Trace Hub debug message related library instance -F: MdeModulePkg/Library/TraceHubDebugSysTLib/ -F: MdeModulePkg/Include/Guid/TraceHubDebugInfoHob.h -M: Gua Guo [gguo11837463] -M: Prakashan Krishnadas Veliyathuparambil [kprakas2] -R: K N Karthik [karthikkabbigere1] - -MdeModulePkg: USB Network modules -F: MdeModulePkg/Bus/Usb/UsbNetwork -F: MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h -M: Richard Ho [richardho] -R: Rebecca Cran [bcran] - -MdeModulePkg: Manageability modules -F: MdeModulePkg/Include/*Ipmi*.* -F: MdeModulePkg/Library/*Ipmi*.* -M: Abner Chang [changab] -R: Abdul Lateef Attar [abdattar] -R: Nickle Wang [nicklela] - -MdeModulePkg: SPI driver stack -F: MdeModulePkg/Bus/Spi/ -M: Abner Chang [changab] -R: Brit Chesley [BritChesley] - -MdePkg -F: MdePkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg -M: Michael D Kinney [mdkinney] -M: Liming Gao [lgao4] -R: Zhiguang Liu [LiuZhiguang001] - -MdePkg: Trace Hub debug message related library instance -F: MdePkg/Library/TraceHubDebugSysTLibNull/ -F: MdePkg/Library/MipiSysTLib/ -F: MdePkg/Include/Library/TraceHubDebugSysTLib.h -F: MdePkg/Include/Library/MipiSysTLib.h -M: Gua Guo [gguo11837463] -M: Prakashan Krishnadas Veliyathuparambil [kprakas2] -R: Chan Laura [lauracha] -R: K N Karthik [karthikkabbigere1] - -MdePkg: FDT related library instance -F: MdePkg/Library/BaseFdtLib/FdtLib.c -F: MdePkg/Include/Library/FdtLib.h -M: Benny Lin [Benny3345678] -R: Gua Guo [gguo11837463] -R: Chasel Chiu [ChaselChiu] -R: James Lu [jameslu8] - -MdePkg: Manageability industryStandard standard C header files -F: MdePkg/Include/IndustryStandard/*Ipmi*.h -F: MdePkg/Include/IndustryStandard/*Mctp*.h -F: MdePkg/Include/IndustryStandard/*Pldm*.h -M: Abner Chang [changab] -R: Abdul Lateef Attar [abdattar] -R: Nickle Wang [nicklela] - -MdePkg: SPI related C header files -F: MdePkg/Include/Protocol/Spi*.h -F: MdePkg/Include/IndustryStandard/SpiNorFlashJedecSfdp.h -M: Abner Chang [changab] -R: Brit Chesley [BritChesley] - -MdePkg: ARM/AARCH64 standard interfaces -F: MdePkg/Include/Library/ArmLib.h -M: Leif Lindholm [leiflindholm] -M: Ard Biesheuvel [ardbiesheuvel] -R: Sami Mujawar [samimujawar] - -NetworkPkg -F: NetworkPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg -R: Saloni Kasbekar [SaloniKasbekar] -R: Zachary Clark-williams [Zclarkwilliams] - -OvmfPkg -F: OvmfPkg/ -W: http://www.tianocore.org/ovmf/ -M: Ard Biesheuvel [ardbiesheuvel] -M: Jiewen Yao [jyao1] -R: Gerd Hoffmann [kraxel] -S: Maintained - -OvmfPkg: bhyve-related modules -F: OvmfPkg/Bhyve/ -F: OvmfPkg/Include/IndustryStandard/Bhyve.h -F: OvmfPkg/Include/Library/BhyveFwCtlLib.h -F: OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c -F: OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf -F: OvmfPkg/Library/BhyveFwCtlLib/ -F: OvmfPkg/Library/PciHostBridgeLibScan/ -F: OvmfPkg/Library/PlatformBootManagerLibBhyve/ -F: OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c -F: OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf -R: Rebecca Cran [bcran] -R: Corvin Köhne [corvink] - -OvmfPkg: cloudhv-related modules -F: OvmfPkg/CloudHv/ -F: OvmfPkg/Include/IndustryStandard/CloudHv.h -R: Jianyong Wu [jongwu] -R: Anatol Belski [weltling] - -OvmfPkg: microvm-related modules -F: OvmfPkg/Microvm/ -F: OvmfPkg/Include/IndustryStandard/Microvm.h -F: OvmfPkg/Library/ResetSystemLib/*Microvm.* -R: Gerd Hoffmann [kraxel] - -OvmfPkg: Confidential Computing -F: OvmfPkg/AmdSev/ -F: OvmfPkg/AmdSevDxe/ -F: OvmfPkg/Include/Guid/ConfidentialComputingSecret.h -F: OvmfPkg/Include/Library/MemEncryptSevLib.h -F: OvmfPkg/IoMmuDxe/CcIoMmu.* -F: OvmfPkg/Library/BaseMemEncryptSevLib/ -F: OvmfPkg/Library/CcExitLib/ -F: OvmfPkg/PlatformPei/AmdSev.c -F: OvmfPkg/ResetVector/ -F: OvmfPkg/Sec/ -R: Erdem Aktas [ruleof2] -R: Jiewen Yao [jyao1] -R: Min Xu [mxu9] -R: Tom Lendacky [tlendacky] -R: Michael Roth [mdroth] - -OvmfPkg: FDT related modules -F: OvmfPkg/Fdt -R: Leif Lindholm [leiflindholm] -R: Gerd Hoffmann [kraxel] -R: Abner Chang [changab] - -OvmfPkg: LsiScsi driver -F: OvmfPkg/LsiScsiDxe/ -R: Gary Lin [lcp] - -OvmfPkg: MptScsi and PVSCSI driver -F: OvmfPkg/MptScsiDxe/ -F: OvmfPkg/PvScsiDxe/ -R: Aaron Young [ajyoung-oracle] - -OvmfPkg: TCG- and TPM2-related modules -F: OvmfPkg/Include/IndustryStandard/QemuTpm.h -F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c -F: OvmfPkg/Library/Tcg2PhysicalPresenceLib*/ -F: OvmfPkg/PlatformPei/ClearCache.c -F: OvmfPkg/Tcg/ -R: Marc-André Lureau [elmarco] - -OvmfPkg: Xen-related modules -F: OvmfPkg/Include/Guid/XenBusRootDevice.h -F: OvmfPkg/Include/Guid/XenInfo.h -F: OvmfPkg/Include/IndustryStandard/Xen/ -F: OvmfPkg/Include/Library/XenHypercallLib.h -F: OvmfPkg/Include/Library/XenIoMmioLib.h -F: OvmfPkg/Include/Library/XenPlatformLib.h -F: OvmfPkg/Include/Protocol/XenBus.h -F: OvmfPkg/Include/Protocol/XenIo.h -F: OvmfPkg/Library/PciHostBridgeLibScan/ -F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c -F: OvmfPkg/Library/XenConsoleSerialPortLib/ -F: OvmfPkg/Library/XenHypercallLib/ -F: OvmfPkg/Library/XenIoMmioLib/ -F: OvmfPkg/Library/XenPlatformLib/ -F: OvmfPkg/Library/XenRealTimeClockLib/ -F: OvmfPkg/OvmfXen.* -F: OvmfPkg/OvmfXenElfHeaderGenerator.c -F: OvmfPkg/SmbiosPlatformDxe/*Xen* -F: OvmfPkg/XenAcpiPlatformDxe/ -F: OvmfPkg/XenBusDxe/ -F: OvmfPkg/XenIoPciDxe/ -F: OvmfPkg/XenIoPvhDxe/ -F: OvmfPkg/XenPlatformPei/ -F: OvmfPkg/XenPvBlkDxe/ -F: OvmfPkg/XenResetVector/ -R: Anthony Perard [tperard] - -OvmfPkg: RISC-V Qemu Virt Platform -F: OvmfPkg/RiscVVirt -M: Sunil V L [vlsunil] -R: Andrei Warkentin [andreiw] - -OvmfPkg: LOONGARCH Qemu Virt Platform -F: OvmfPkg/LoongArchVirt -M: Chao Li [kilaterlee] -M: Bibo Mao [bibo-mao] -R: Xianglai Li [lixianglai] - -PcAtChipsetPkg -F: PcAtChipsetPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/PcAtChipsetPkg -M: Ray Ni [niruiyu] +M: Project Mu UEFI Bot [uefibot] PrmPkg F: PrmPkg/ M: Michael Kubacki [makubacki] -M: Nate DeSimone [nate-desimone] - -PrmPkg: ACPI related modules -R: Ankit Sinha [ankit13s] - -RedfishPkg: Redfish related modules -F: RedfishPkg/ -M: Abner Chang [changab] -M: Nickle Wang [nicklela] -R: Igor Kulchytskyy [igorkulchytskyy] - -SecurityPkg -F: SecurityPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/SecurityPkg -M: Jiewen Yao [jyao1] - -SecurityPkg: Secure boot related modules -F: SecurityPkg/Library/DxeImageVerificationLib/ -F: SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/ -F: SecurityPkg/Library/AuthVariableLib/ -R: Min Xu [mxu9] - -SecurityPkg: Tcg related modules -F: SecurityPkg/Tcg/ -R: Rahul Kumar [rahul1-kumar] - -ShellPkg -F: ShellPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/ShellPkg -M: Zhichao Gao [ZhichaoGao] - -SignedCapsulePkg -F: SignedCapsulePkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/SignedCapsulePkg - -SourceLevelDebugPkg -F: SourceLevelDebugPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/SourceLevelDebugPkg - -StandaloneMmPkg -F: StandaloneMmPkg/ -M: Ard Biesheuvel [ardbiesheuvel] -M: Sami Mujawar [samimujawar] -M: Ray Ni [niruiyu] -R: Jiaxin Wu [jiaxinwu] UefiCpuPkg F: UefiCpuPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg -M: Ray Ni [niruiyu] -R: Rahul Kumar [rahul1-kumar] -R: Gerd Hoffmann [kraxel] -R: Jiaxin Wu [jiaxinwu] - -UefiCpuPkg: Sec related modules -F: UefiCpuPkg/SecCore/ -F: UefiCpuPkg/ResetVector/ -R: Catharine West [catharine-intl] - -UefiCpuPkg: AMD related files -F: UefiCpuPkg/Library/MmSaveStateLib/*Amd*.* -F: UefiCpuPkg/Library/SmmCpuFeaturesLib/*Amd*.* -M: Abdul Lateef Attar [abdattar] -R: Abner Chang [changab] - -UefiPayloadPkg -F: UefiPayloadPkg/ -W: https://github.com/tianocore/tianocore.github.io/wiki/UefiPayloadPkg -M: Guo Dong [gdong1] -M: Sean Rhodes [Sean-StarLabs] -M: James Lu [jameslu8] -R: Gua Guo [gguo11837463] -S: Maintained - -UnitTestFrameworkPkg -F: UnitTestFrameworkPkg/ -M: Michael D Kinney [mdkinney] -M: Michael Kubacki [makubacki] -R: Sean Brogan [spbrogan] -S: Maintained +M: Project Mu UEFI Bot [uefibot] +R: Project Mu Bot [ProjectMuBot] From c32dca1badfce8d9d9746af53f2eb7ad2ab83c4e Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 00:08:04 -0400 Subject: [PATCH 02/38] Allow reviewer addition in this org --- .github/workflows/request-reviews.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 4f43d5612221..671f11e2f840 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -23,7 +23,7 @@ jobs: auto-request-review: name: Add Pull Request Reviewers # Do not run on draft PRs and only run on PRs in the tianocore organization - if: ${{ github.event.pull_request.draft == false && github.repository_owner == 'tianocore' }} + if: ${{ github.event.pull_request.draft == false && github.repository_owner == 'makubacki' }} runs-on: ubuntu-latest permissions: From d4e8ba13c00ddf2982c4559d5d577790c7180997 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 00:14:47 -0400 Subject: [PATCH 03/38] Use pull_request_target --- .github/workflows/request-reviews.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 671f11e2f840..d2588d06559a 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -11,7 +11,7 @@ name: Add Pull Request Reviewers on: - pull_request: + pull_request_target: branches: - master types: [opened, ready_for_review, reopened, synchronize] From c83ab47038dc7b61ac65ac10124e875f75c651d4 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:05:27 -0400 Subject: [PATCH 04/38] Changes for getting PR branch SHA --- .github/scripts/GitHub.py | 45 ++++++++++++++++++++++++--- .github/workflows/request-reviews.yml | 6 +++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index cd6bea5205f7..e3a7168338da 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -40,15 +40,18 @@ def leave_pr_comment( def get_reviewers_for_current_branch( - workspace_path: str, maintainer_file_path: str, target_branch: str = "master" + workspace_path: str, + maintainer_file_path: str, + range_start="master", + range_end: str = "HEAD", ) -> List[str]: """Get the reviewers for the current branch. Args: workspace_path (str): The workspace path. maintainer_file_path (str): The maintainer file path. - target_branch (str, optional): The name of the target branch that the - current HEAD will merge to. Defaults to "master". + range_start (str, optional): The range start ref. Defaults to "master". + range_end (str, optional): The range end ref. Defaults to "HEAD". Returns: List[str]: A list of GitHub usernames. @@ -57,7 +60,7 @@ def get_reviewers_for_current_branch( commit_stream_buffer = StringIO() cmd_ret = RunCmd( "git", - f"log --format=format:%H {target_branch}..HEAD", + f"log --format=format:%H {range_start}..{range_end}", workingdir=workspace_path, outstream=commit_stream_buffer, logging_level=logging.INFO, @@ -104,6 +107,40 @@ def get_reviewers_for_current_branch( return reviewers +def get_pr_head_sha(token: str, owner: str, repo: str, pr_number: str) -> str: + """Returns the commit SHA of given PR branch HEAD. + + Args: + token (str): The GitHub token to use for authentication. + owner (str): The GitHub owner (organization) name. + repo (str): The GitHub repository name (e.g. 'edk2'). + pr_number (str): The pull request number. + + Returns: + str: The commit SHA of the PR branch HEAD. An empty string is returned + if the request fails. + """ + url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" + headers = { + "Authorization": f"Bearer {token}", + "Accept": "application/vnd.github.v3+json", + } + response = requests.get(url, headers=headers) + try: + response.raise_for_status() + except requests.exceptions.HTTPError: + print( + f"::error title=HTTP Error!::Error getting PR Commit Info: {response.reason}" + ) + return "" + + commit_sha = response.json()["head"]["sha"] + + print(f"::debug title=PR {pr_number} Commit SHA::{commit_sha}") + + return commit_sha + + def download_gh_file(github_url: str, local_path: str, token=None): """Downloads a file from GitHub. diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index d2588d06559a..b91c08545173 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -63,7 +63,11 @@ jobs: WORKSPACE_PATH = os.environ['WORKSPACE_PATH'] GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ['GET_MAINTAINER_REL_PATH']) - reviewers = GitHub.get_reviewers_for_current_branch(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, f"origin/{os.environ['TARGET_BRANCH']}") + pr_branch_commit = GitHub.get_pr_head_sha(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER']) + if not pr_branch_commit: + sys.exit(1) + + reviewers = GitHub.get_reviewers_for_current_branch(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, f"origin/{os.environ['TARGET_BRANCH']}", pr_branch_commit) if not reviewers: print("::notice title=No Reviewers Found!::No reviewers found for this PR.") sys.exit(1) From cc5e115c470f8aca21e5978ace9852f38ba5a779 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:15:43 -0400 Subject: [PATCH 05/38] GitHub.py: Use merge commit SHA --- .github/scripts/GitHub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index e3a7168338da..1158018f7b87 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -134,7 +134,7 @@ def get_pr_head_sha(token: str, owner: str, repo: str, pr_number: str) -> str: ) return "" - commit_sha = response.json()["head"]["sha"] + commit_sha = response.json()["merge_commit_sha"] print(f"::debug title=PR {pr_number} Commit SHA::{commit_sha}") From c5cad6ca6ed2c684102eb889a99bca87d5419982 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:43:50 -0400 Subject: [PATCH 06/38] Merge commit updates --- .github/scripts/GitHub.py | 45 +++++++++++++++++---------- .github/workflows/request-reviews.yml | 23 ++++++++++++-- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 1158018f7b87..f9d3880fdfe0 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -39,7 +39,7 @@ def leave_pr_comment( response.raise_for_status() -def get_reviewers_for_current_branch( +def get_reviewers_for_range( workspace_path: str, maintainer_file_path: str, range_start="master", @@ -47,6 +47,9 @@ def get_reviewers_for_current_branch( ) -> List[str]: """Get the reviewers for the current branch. + To get the reviewers for a single commit, set `range_start` and + `range_end` to the commit SHA. + Args: workspace_path (str): The workspace path. maintainer_file_path (str): The maintainer file path. @@ -57,22 +60,26 @@ def get_reviewers_for_current_branch( List[str]: A list of GitHub usernames. """ - commit_stream_buffer = StringIO() - cmd_ret = RunCmd( - "git", - f"log --format=format:%H {range_start}..{range_end}", - workingdir=workspace_path, - outstream=commit_stream_buffer, - logging_level=logging.INFO, - ) - if cmd_ret != 0: - print( - f"::error title=Commit Lookup Error!::Error getting branch commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}" + if range_start == range_end: + commits = [range_start] + else: + commit_stream_buffer = StringIO() + cmd_ret = RunCmd( + "git", + f"log --format=format:%H {range_start}..{range_end}", + workingdir=workspace_path, + outstream=commit_stream_buffer, + logging_level=logging.INFO, ) - return [] + if cmd_ret != 0: + print( + f"::error title=Commit Lookup Error!::Error getting branch commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}" + ) + return [] + commits = commit_stream_buffer.getvalue().splitlines() raw_reviewers = [] - for commit_sha in commit_stream_buffer.getvalue().splitlines(): + for commit_sha in commits: reviewer_stream_buffer = StringIO() cmd_ret = RunPythonScript( maintainer_file_path, @@ -107,8 +114,12 @@ def get_reviewers_for_current_branch( return reviewers -def get_pr_head_sha(token: str, owner: str, repo: str, pr_number: str) -> str: - """Returns the commit SHA of given PR branch HEAD. +def get_pr_sha(token: str, owner: str, repo: str, pr_number: str) -> str: + """Returns the commit SHA of given PR branch. + + This returns the SHA of the merge commit that GitHub creates from a + PR branch. This commit contains all of the files in the PR branch in + a single commit. Args: token (str): The GitHub token to use for authentication. @@ -117,7 +128,7 @@ def get_pr_head_sha(token: str, owner: str, repo: str, pr_number: str) -> str: pr_number (str): The pull request number. Returns: - str: The commit SHA of the PR branch HEAD. An empty string is returned + str: The commit SHA of the PR branch. An empty string is returned if the request fails. """ url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index b91c08545173..cd0c4c472047 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -55,19 +55,36 @@ jobs: TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} WORKSPACE_PATH: ${{ github.workspace }} run: | + import logging import os import sys sys.path.append(os.path.join(os.environ['WORKSPACE_PATH'], ".github")) + from edk2toollib.utility_functions import RunCmd + from io import StringIO from scripts import GitHub WORKSPACE_PATH = os.environ['WORKSPACE_PATH'] GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ['GET_MAINTAINER_REL_PATH']) - pr_branch_commit = GitHub.get_pr_head_sha(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER']) - if not pr_branch_commit: + pr_commit_sha = GitHub.get_pr_sha(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER']) + if not pr_commit_sha: sys.exit(1) - reviewers = GitHub.get_reviewers_for_current_branch(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, f"origin/{os.environ['TARGET_BRANCH']}", pr_branch_commit) + out_stream_buffer = StringIO() + cmd_ret = RunCmd( + "git", + f"fetch {pr_commit_sha}", + workingdir=workspace_path, + outstream=out_stream_buffer, + logging_level=logging.INFO, + ) + if cmd_ret != 0: + print( + f"::error title=Commit Fetch Error!::Error fetching PR commit: [{cmd_ret}]: {out_stream_buffer.getvalue()}" + ) + sys.exit(1) + + reviewers = GitHub.get_reviewers_for_range(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha) if not reviewers: print("::notice title=No Reviewers Found!::No reviewers found for this PR.") sys.exit(1) From cd771fab9c394e429d136931f1048471f7e05910 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:48:37 -0400 Subject: [PATCH 07/38] Update workspace path --- .github/workflows/request-reviews.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index cd0c4c472047..a1cab7e60c27 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -74,7 +74,7 @@ jobs: cmd_ret = RunCmd( "git", f"fetch {pr_commit_sha}", - workingdir=workspace_path, + workingdir=WORKSPACE_PATH, outstream=out_stream_buffer, logging_level=logging.INFO, ) From 92bf58274c0d3caf682d67bf1d9d9b1cbbfcab22 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:50:45 -0400 Subject: [PATCH 08/38] Add remote to fetch --- .github/workflows/request-reviews.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index a1cab7e60c27..0d2b3e13c38d 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -73,7 +73,7 @@ jobs: out_stream_buffer = StringIO() cmd_ret = RunCmd( "git", - f"fetch {pr_commit_sha}", + f"fetch origin {pr_commit_sha}", workingdir=WORKSPACE_PATH, outstream=out_stream_buffer, logging_level=logging.INFO, From 539f1ae97daade74f54a3c2faf468250be0f9ef6 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:54:51 -0400 Subject: [PATCH 09/38] Add consolidated commit dbg msg --- .github/workflows/request-reviews.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 0d2b3e13c38d..ac55fbfe53cf 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -70,6 +70,8 @@ jobs: if not pr_commit_sha: sys.exit(1) + print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") + out_stream_buffer = StringIO() cmd_ret = RunCmd( "git", From 3eeca1942e00d6b820879ef5f6807eef3036ee1f Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:59:12 -0400 Subject: [PATCH 10/38] Add another test reviewer --- Maintainers.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Maintainers.txt b/Maintainers.txt index 9161cde83c13..59b1d48f1997 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -155,3 +155,4 @@ F: UefiCpuPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg M: Project Mu UEFI Bot [uefibot] R: Project Mu Bot [ProjectMuBot] +R: Sean Brogan [spbrogan] From 995c4ad9918d0e739779a70769379ae2fcf12acb Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 13:17:06 -0400 Subject: [PATCH 11/38] Remove non-collaborator user --- Maintainers.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Maintainers.txt b/Maintainers.txt index 59b1d48f1997..9161cde83c13 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -155,4 +155,3 @@ F: UefiCpuPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg M: Project Mu UEFI Bot [uefibot] R: Project Mu Bot [ProjectMuBot] -R: Sean Brogan [spbrogan] From 8e9824199d0d73384b03bfb7554996aeeee54364 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 14:52:33 -0400 Subject: [PATCH 12/38] Switch to PyGithub --- .github/scripts/GitHub.py | 212 +++++++++++++++----------- .github/workflows/request-reviews.yml | 14 +- 2 files changed, 128 insertions(+), 98 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index f9d3880fdfe0..53bbfec94b78 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -11,12 +11,48 @@ from collections import OrderedDict from edk2toollib.utility_functions import RunCmd, RunPythonScript +from github import Auth, Github, GithubException from io import StringIO from typing import List + """GitHub API helper functions.""" +def _authenticate(token: str): + """Authenticate to GitHub using a token. + + Args: + token (str): The GitHub token to use for authentication. + + Returns: + Github: A GitHub instance. + """ + auth = Auth.Token(token) + return Github(auth=auth) + + +def _get_pr(token: str, owner: str, repo: str, pr_number: str): + """Get the PR object from GitHub. + + Args: + token (str): The GitHub token to use for authentication. + owner (str): The GitHub owner (organization) name. + repo (str): The GitHub repository name (e.g. 'edk2'). + pr_number (str): The pull request number. + + Returns: + PullRequest: The PullRequest object. + """ + try: + g = _authenticate(token) + return g.get_repo(f"{owner}/{repo}").get_pull(pr_number) + except GithubException as ge: + print(f"::error title=Error Getting PR {pr_number} Info!::" + f"{ge.data['message']}") + return None + + def leave_pr_comment( token: str, owner: str, repo: str, pr_number: str, comment_body: str ): @@ -29,14 +65,12 @@ def leave_pr_comment( pr_number (str): The pull request number. comment_body (str): The comment text. Markdown is supported. """ - url = f"https://api.github.com/repos/{owner}/{repo}/issues/{pr_number}/comments" - headers = { - "Authorization": f"Bearer {token}", - "Accept": "application/vnd.github.v3+json", - } - data = {"body": comment_body} - response = requests.post(url, json=data, headers=headers) - response.raise_for_status() + if pr := _get_pr(token, owner, repo, pr_number): + try: + pr.create_issue_comment(comment_body) + except GithubException as ge: + print(f"::error title=Error Commenting on PR {pr_number}!::" + f"{ge.data['message']}") def get_reviewers_for_range( @@ -47,8 +81,11 @@ def get_reviewers_for_range( ) -> List[str]: """Get the reviewers for the current branch. - To get the reviewers for a single commit, set `range_start` and - `range_end` to the commit SHA. + !!! note + This function accepts a range of commits and returns the reviewers + for that set of commits as a single list of GitHub usernames. To get + the reviewers for a single commit, set `range_start` and `range_end` + to the commit SHA. Args: workspace_path (str): The workspace path. @@ -59,7 +96,6 @@ def get_reviewers_for_range( Returns: List[str]: A list of GitHub usernames. """ - if range_start == range_end: commits = [range_start] else: @@ -69,12 +105,11 @@ def get_reviewers_for_range( f"log --format=format:%H {range_start}..{range_end}", workingdir=workspace_path, outstream=commit_stream_buffer, - logging_level=logging.INFO, - ) + logging_level=logging.INFO,) if cmd_ret != 0: print( - f"::error title=Commit Lookup Error!::Error getting branch commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}" - ) + f"::error title=Commit Lookup Error!::Error getting branch " + f"commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}") return [] commits = commit_stream_buffer.getvalue().splitlines() @@ -86,12 +121,12 @@ def get_reviewers_for_range( f"-g {commit_sha}", workingdir=workspace_path, outstream=reviewer_stream_buffer, - logging_level=logging.INFO, - ) + logging_level=logging.INFO) if cmd_ret != 0: print( - f"::error title=Reviewer Lookup Error!::Error calling GetMaintainer.py: [{cmd_ret}]: {reviewer_stream_buffer.getvalue()}" - ) + f"::error title=Reviewer Lookup Error!::Error calling " + f"GetMaintainer.py: [{cmd_ret}]: " + f"{reviewer_stream_buffer.getvalue()}") return [] commit_reviewers = reviewer_stream_buffer.getvalue() @@ -102,8 +137,8 @@ def get_reviewers_for_range( return [] print( - f"::debug title=Commit {commit_sha[:7]} Reviewer(s)::{', '.join(matches)}" - ) + f"::debug title=Commit {commit_sha[:7]} " + f"Reviewer(s)::{', '.join(matches)}") raw_reviewers.extend(matches) @@ -141,46 +176,25 @@ def get_pr_sha(token: str, owner: str, repo: str, pr_number: str) -> str: response.raise_for_status() except requests.exceptions.HTTPError: print( - f"::error title=HTTP Error!::Error getting PR Commit Info: {response.reason}" - ) + f"::error title=HTTP Error!::Error getting PR Commit Info: " + f"{response.reason}") return "" commit_sha = response.json()["merge_commit_sha"] - print(f"::debug title=PR {pr_number} Commit SHA::{commit_sha}") - - return commit_sha + print(f"::notice title=PR {pr_number} Old Merge Commit SHA::{commit_sha}") + pr = _get_pr(token, owner, repo, pr_number) + if pr: + merge_commit_sha = pr.merge_commit_sha + print(f"::notice title=PR {pr_number} New Merge Commit SHA::{merge_commit_sha}") -def download_gh_file(github_url: str, local_path: str, token=None): - """Downloads a file from GitHub. - - Args: - github_url (str): The GitHub raw file URL. - local_path (str): A local path to write the file contents to. - token (_type_, optional): A GitHub authentication token. - Only needed for a private repo. Defaults to None. - """ - headers = {} - if token: - headers["Authorization"] = f"Bearer {token}" - - try: - response = requests.get(github_url, headers=headers) - response.raise_for_status() - except requests.exceptions.HTTPError: - print( - f"::error title=HTTP Error!::Error downloading {github_url}: {response.reason}" - ) - return - - with open(local_path, "w", encoding="utf-8") as file: - file.write(response.text) + return commit_sha def add_reviewers_to_pr( token: str, owner: str, repo: str, pr_number: str, user_names: List[str] -): +) -> List[str]: """Adds the set of GitHub usernames as reviewers to the PR. Args: @@ -189,47 +203,59 @@ def add_reviewers_to_pr( repo (str): The GitHub repository name (e.g. 'edk2'). pr_number (str): The pull request number. user_names (List[str]): List of GitHub usernames to add as reviewers. - """ - headers = { - "Authorization": f"Bearer {token}", - "Accept": "application/vnd.github.v3+json", - } - pr_author_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" - url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}/requested_reviewers" - response = requests.get(pr_author_url, headers=headers) - if response.status_code != 200: - print(f"::error title=HTTP Error!::Error getting PR author: {response.reason}") - return - pr_author = response.json().get("user").get("login").strip() - while pr_author in user_names: - user_names.remove(pr_author) - data = {"reviewers": user_names} - response = requests.post(url, json=data, headers=headers) + Returns: + List[str]: A list of GitHub usernames that were successfully added as + reviewers to the PR. This list will exclude any reviewers + from the list provided if they are not relevant to the PR. + """ try: - response.raise_for_status() - except requests.exceptions.HTTPError: - if ( - response.status_code == 422 - and "Reviews may only be requested from collaborators" - in response.json().get("message") - ): - print( - f"::error title=User is not a Collaborator!::{response.json().get('message')}" - ) - leave_pr_comment( - token, - owner, - repo, - pr_number, - f"⚠ **WARNING: Cannot add reviewers**: A user specified as a " - f"reviewer for this PR is not a collaborator " - f"of the edk2 repository. Please add them as a collaborator to the " - f"repository and re-request the review.\n\n" - f"Users requested:\n{', '.join(user_names)}", - ) - elif response.status_code == 422: - print( - "::error title=Invalid Request!::The request is invalid. " - "Verify the API request string." - ) + g = _authenticate(token) + pr = g.get_repo(f"{owner}/{repo}").get_pull(pr_number) + except GithubException as ge: + print(f"::error title=Error Getting PR {pr_number} Info!::" + f"{ge.data['message']}") + return + + # The pull request author cannot be a reviewer. + pr_author = pr.user.login.strip() + + # The current reviewers of the PR do not need to be requested again. + current_pr_reviewers = pr.get_review_requests()[0] + + # A user can only be added if they are a collaborator of the repository. + repo_collaborators = [c.login.strip() for c in repo.get_collaborators()] + non_collaborators = [u for u in user_names if u not in repo_collaborators] + + excluded_pr_reviewers = [pr_author] + current_pr_reviewers + non_collaborators + new_pr_reviewers = [u for u in user_names if u not in excluded_pr_reviewers] + + # Notify the admins of the repository if non-collaborators are requested. + if non_collaborators: + repo_admins = repo.get_collaborators(permission='admin') + + print( + f"::warning title=Non-Collaborator Reviewers Found!::" + f"{', '.join(non_collaborators)}") + + leave_pr_comment( + token, + owner, + repo, + pr_number, + f"⚠ **WARNING: Cannot add some reviewers**: A user " + f"specified as a reviewer for this PR is not a collaborator " + f"of the edk2 repository. Please add them as a collaborator to " + f"the repository so they can be requested in the future.\n\n" + f"Non-collaborators requested:\n{', '.join(non_collaborators)}" + f"\n\nAttn Admins:\n\n" + f"{'\n'.join([f"- @{a.login}" for a in repo_admins])}") + + # Add any new reviewers to the PR if needed. + if new_pr_reviewers: + print(f"::debug title=Adding New PR Reviewers::" + f"{', '.join(new_pr_reviewers)}") + + pr.create_review_request(reviewers=new_pr_reviewers) + + return new_pr_reviewers diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index ac55fbfe53cf..e580086fb9e1 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -43,7 +43,7 @@ jobs: python-version: '3.x' - name: Install PIP Modules - run: pip install edk2-pytool-library edk2-pytool-extensions requests + run: pip install edk2-pytool-library edk2-pytool-extensions PyGithub requests - name: Add Reviewers to Pull Request shell: python @@ -88,9 +88,13 @@ jobs: reviewers = GitHub.get_reviewers_for_range(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha) if not reviewers: - print("::notice title=No Reviewers Found!::No reviewers found for this PR.") - sys.exit(1) + print("::notice title=No New Reviewers Found!::No reviewers found for this PR.") + sys.exit(0) - print(f"::notice title=Reviewer List::Reviewers found for PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}") + print(f"::notice title=Preliminary Reviewer List::Total reviewer candidates for PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}") - GitHub.add_reviewers_to_pr(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER'], reviewers) + new_reviewers = GitHub.add_reviewers_to_pr(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER'], reviewers) + if new_reviewers: + print(f"::notice title=New Reviewers Added::New reviewers requested for PR {os.environ['PR_NUMBER']}:\n{', '.join(new_reviewers)}") + else: + print("::notice title=No New Reviewers Added!::No reviewers were found that should be newly requested.") From 50c86e42330e19d205c9877b194ceafe2f3a3627 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 15:18:13 -0400 Subject: [PATCH 13/38] PIP caching and other minor updates --- .github/scripts/GitHub.py | 22 ++++------ .github/scripts/requirements.txt | 14 ++++++ .github/workflows/request-reviews.yml | 61 +++++++++++++++++++++------ 3 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 .github/scripts/requirements.txt diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 53bbfec94b78..7c5f49fca304 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -32,14 +32,14 @@ def _authenticate(token: str): return Github(auth=auth) -def _get_pr(token: str, owner: str, repo: str, pr_number: str): +def _get_pr(token: str, owner: str, repo: str, pr_number: int): """Get the PR object from GitHub. Args: token (str): The GitHub token to use for authentication. owner (str): The GitHub owner (organization) name. repo (str): The GitHub repository name (e.g. 'edk2'). - pr_number (str): The pull request number. + pr_number (int): The pull request number. Returns: PullRequest: The PullRequest object. @@ -54,7 +54,7 @@ def _get_pr(token: str, owner: str, repo: str, pr_number: str): def leave_pr_comment( - token: str, owner: str, repo: str, pr_number: str, comment_body: str + token: str, owner: str, repo: str, pr_number: int, comment_body: str ): """Leaves a comment on a PR. @@ -62,7 +62,7 @@ def leave_pr_comment( token (str): The GitHub token to use for authentication. owner (str): The GitHub owner (organization) name. repo (str): The GitHub repository name (e.g. 'edk2'). - pr_number (str): The pull request number. + pr_number (int): The pull request number. comment_body (str): The comment text. Markdown is supported. """ if pr := _get_pr(token, owner, repo, pr_number): @@ -149,7 +149,7 @@ def get_reviewers_for_range( return reviewers -def get_pr_sha(token: str, owner: str, repo: str, pr_number: str) -> str: +def get_pr_sha(token: str, owner: str, repo: str, pr_number: int) -> str: """Returns the commit SHA of given PR branch. This returns the SHA of the merge commit that GitHub creates from a @@ -160,7 +160,7 @@ def get_pr_sha(token: str, owner: str, repo: str, pr_number: str) -> str: token (str): The GitHub token to use for authentication. owner (str): The GitHub owner (organization) name. repo (str): The GitHub repository name (e.g. 'edk2'). - pr_number (str): The pull request number. + pr_number (int): The pull request number. Returns: str: The commit SHA of the PR branch. An empty string is returned @@ -193,7 +193,7 @@ def get_pr_sha(token: str, owner: str, repo: str, pr_number: str) -> str: def add_reviewers_to_pr( - token: str, owner: str, repo: str, pr_number: str, user_names: List[str] + token: str, owner: str, repo: str, pr_number: int, user_names: List[str] ) -> List[str]: """Adds the set of GitHub usernames as reviewers to the PR. @@ -209,13 +209,7 @@ def add_reviewers_to_pr( reviewers to the PR. This list will exclude any reviewers from the list provided if they are not relevant to the PR. """ - try: - g = _authenticate(token) - pr = g.get_repo(f"{owner}/{repo}").get_pull(pr_number) - except GithubException as ge: - print(f"::error title=Error Getting PR {pr_number} Info!::" - f"{ge.data['message']}") - return + pr = _get_pr(token, owner, repo, pr_number) # The pull request author cannot be a reviewer. pr_author = pr.user.login.strip() diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt new file mode 100644 index 000000000000..a19a04bd81cc --- /dev/null +++ b/.github/scripts/requirements.txt @@ -0,0 +1,14 @@ +## @file +# GitHub Helpers Python PIP requirements file +# +# This file provides the list of python components used in GitHub scripts in this repository. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +edk2-pytool-library==0.* +edk2-pytool-extensions==0.* +PyGithub==2.* +requests==2.* diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index e580086fb9e1..95f77af940f2 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -42,8 +42,15 @@ jobs: with: python-version: '3.x' + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + cache: 'pip' + cache-dependency-path: '.github/scripts/requirements.txt' + - name: Install PIP Modules - run: pip install edk2-pytool-library edk2-pytool-extensions PyGithub requests + run: pip install -r .github/scripts/requirements.txt --upgrade - name: Add Reviewers to Pull Request shell: python @@ -58,19 +65,30 @@ jobs: import logging import os import sys - sys.path.append(os.path.join(os.environ['WORKSPACE_PATH'], ".github")) + + sys.path.append(os.path.join(os.environ["WORKSPACE_PATH"], ".github")) from edk2toollib.utility_functions import RunCmd from io import StringIO from scripts import GitHub - WORKSPACE_PATH = os.environ['WORKSPACE_PATH'] - GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ['GET_MAINTAINER_REL_PATH']) + WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] + GET_MAINTAINER_LOCAL_PATH = os.path.join( + WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"] + ) - pr_commit_sha = GitHub.get_pr_sha(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER']) + pr_commit_sha = GitHub.get_pr_sha( + os.environ["GH_TOKEN"], + os.environ["ORG_NAME"], + os.environ["REPO_NAME"], + int(os.environ["PR_NUMBER"]), + ) if not pr_commit_sha: sys.exit(1) - print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") + print( + f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: " + f"{pr_commit_sha}" + ) out_stream_buffer = StringIO() cmd_ret = RunCmd( @@ -82,19 +100,38 @@ jobs: ) if cmd_ret != 0: print( - f"::error title=Commit Fetch Error!::Error fetching PR commit: [{cmd_ret}]: {out_stream_buffer.getvalue()}" + f"::error title=Commit Fetch Error!::Error fetching PR commit: " + f"[{cmd_ret}]: {out_stream_buffer.getvalue()}" ) sys.exit(1) - reviewers = GitHub.get_reviewers_for_range(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha) + reviewers = GitHub.get_reviewers_for_range( + WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha + ) if not reviewers: print("::notice title=No New Reviewers Found!::No reviewers found for this PR.") sys.exit(0) - print(f"::notice title=Preliminary Reviewer List::Total reviewer candidates for PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}") + print( + f"::notice title=Preliminary Reviewer List::Total reviewer candidates for " + f"PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}" + ) - new_reviewers = GitHub.add_reviewers_to_pr(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], os.environ['PR_NUMBER'], reviewers) + new_reviewers = GitHub.add_reviewers_to_pr( + os.environ["GH_TOKEN"], + os.environ["ORG_NAME"], + os.environ["REPO_NAME"], + int(os.environ["PR_NUMBER"]), + reviewers, + ) if new_reviewers: - print(f"::notice title=New Reviewers Added::New reviewers requested for PR {os.environ['PR_NUMBER']}:\n{', '.join(new_reviewers)}") + print( + f"::notice title=New Reviewers Added::New reviewers requested for PR " + f"{os.environ['PR_NUMBER']}:\n{', '.join(new_reviewers)}" + ) else: - print("::notice title=No New Reviewers Added!::No reviewers were found that should be newly requested.") + print( + "::notice title=No New Reviewers Added!::No reviewers were found that " + "should be newly requested." + ) + From a0218a48d2263963ccf1eeda053cf9eecc70c640 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 15:31:03 -0400 Subject: [PATCH 14/38] Update GH repo object --- .github/scripts/GitHub.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 7c5f49fca304..110f07c45561 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -209,7 +209,14 @@ def add_reviewers_to_pr( reviewers to the PR. This list will exclude any reviewers from the list provided if they are not relevant to the PR. """ - pr = _get_pr(token, owner, repo, pr_number) + try: + g = _authenticate(token) + repo_gh = g.get_repo(f"{owner}/{repo}") + pr = repo_gh.get_pull(pr_number) + except GithubException as ge: + print(f"::error title=Error Getting PR {pr_number} Info!::" + f"{ge.data['message']}") + return None # The pull request author cannot be a reviewer. pr_author = pr.user.login.strip() @@ -218,7 +225,7 @@ def add_reviewers_to_pr( current_pr_reviewers = pr.get_review_requests()[0] # A user can only be added if they are a collaborator of the repository. - repo_collaborators = [c.login.strip() for c in repo.get_collaborators()] + repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators()] non_collaborators = [u for u in user_names if u not in repo_collaborators] excluded_pr_reviewers = [pr_author] + current_pr_reviewers + non_collaborators @@ -226,7 +233,7 @@ def add_reviewers_to_pr( # Notify the admins of the repository if non-collaborators are requested. if non_collaborators: - repo_admins = repo.get_collaborators(permission='admin') + repo_admins = repo_gh.get_collaborators(permission='admin') print( f"::warning title=Non-Collaborator Reviewers Found!::" From 3b703b0e7348a3a2f6cc61314be159e26e1684bd Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 15:38:24 -0400 Subject: [PATCH 15/38] Convert PaginatedList to normal list --- .github/scripts/GitHub.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 110f07c45561..de09cc773643 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -209,6 +209,11 @@ def add_reviewers_to_pr( reviewers to the PR. This list will exclude any reviewers from the list provided if they are not relevant to the PR. """ + if not user_names: + print("::debug title=No PR Reviewers Requested!::" + "The list of PR reviewers is empty so not adding any reviewers.") + return [] + try: g = _authenticate(token) repo_gh = g.get_repo(f"{owner}/{repo}") @@ -222,7 +227,7 @@ def add_reviewers_to_pr( pr_author = pr.user.login.strip() # The current reviewers of the PR do not need to be requested again. - current_pr_reviewers = pr.get_review_requests()[0] + current_pr_reviewers = [r for r in pr.get_review_requests()[0]] # A user can only be added if they are a collaborator of the repository. repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators()] From c6242d309a1030ada0816b773cf2d445fc06cd54 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 15:45:51 -0400 Subject: [PATCH 16/38] Replace merge commit SHA fetch with PyGithub --- .github/scripts/GitHub.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index de09cc773643..a30c1d9ecdc1 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -166,30 +166,12 @@ def get_pr_sha(token: str, owner: str, repo: str, pr_number: int) -> str: str: The commit SHA of the PR branch. An empty string is returned if the request fails. """ - url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" - headers = { - "Authorization": f"Bearer {token}", - "Accept": "application/vnd.github.v3+json", - } - response = requests.get(url, headers=headers) - try: - response.raise_for_status() - except requests.exceptions.HTTPError: - print( - f"::error title=HTTP Error!::Error getting PR Commit Info: " - f"{response.reason}") - return "" - - commit_sha = response.json()["merge_commit_sha"] - - print(f"::notice title=PR {pr_number} Old Merge Commit SHA::{commit_sha}") - - pr = _get_pr(token, owner, repo, pr_number) - if pr: + if pr := _get_pr(token, owner, repo, pr_number): merge_commit_sha = pr.merge_commit_sha - print(f"::notice title=PR {pr_number} New Merge Commit SHA::{merge_commit_sha}") + print(f"::debug title=PR {pr_number} Merge Commit SHA::{merge_commit_sha}") + return merge_commit_sha - return commit_sha + return "" def add_reviewers_to_pr( From a0500f3a1818dc4357468d45b0857330776a0ef7 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 15:58:20 -0400 Subject: [PATCH 17/38] Get login from more lists --- .github/scripts/GitHub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index a30c1d9ecdc1..a2dc1a386e11 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -209,7 +209,7 @@ def add_reviewers_to_pr( pr_author = pr.user.login.strip() # The current reviewers of the PR do not need to be requested again. - current_pr_reviewers = [r for r in pr.get_review_requests()[0]] + current_pr_reviewers = [r.login.strip() for r in pr.get_review_requests()[0]] # A user can only be added if they are a collaborator of the repository. repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators()] @@ -220,7 +220,7 @@ def add_reviewers_to_pr( # Notify the admins of the repository if non-collaborators are requested. if non_collaborators: - repo_admins = repo_gh.get_collaborators(permission='admin') + repo_admins = [a.login for a in repo_gh.get_collaborators(permission='admin')] print( f"::warning title=Non-Collaborator Reviewers Found!::" From 8eacfc5f096e25fa426d6e4f8b046e9433ee298c Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 16:05:51 -0400 Subject: [PATCH 18/38] Keep notice messages on a single line --- .github/workflows/request-reviews.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 95f77af940f2..586f338cbe20 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -72,9 +72,7 @@ jobs: from scripts import GitHub WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] - GET_MAINTAINER_LOCAL_PATH = os.path.join( - WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"] - ) + GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"]) pr_commit_sha = GitHub.get_pr_sha( os.environ["GH_TOKEN"], @@ -85,10 +83,7 @@ jobs: if not pr_commit_sha: sys.exit(1) - print( - f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: " - f"{pr_commit_sha}" - ) + print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") out_stream_buffer = StringIO() cmd_ret = RunCmd( @@ -114,7 +109,7 @@ jobs: print( f"::notice title=Preliminary Reviewer List::Total reviewer candidates for " - f"PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}" + f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}" ) new_reviewers = GitHub.add_reviewers_to_pr( @@ -127,7 +122,7 @@ jobs: if new_reviewers: print( f"::notice title=New Reviewers Added::New reviewers requested for PR " - f"{os.environ['PR_NUMBER']}:\n{', '.join(new_reviewers)}" + f"{os.environ['PR_NUMBER']}: {', '.join(new_reviewers)}" ) else: print( From 20a5d94f54dd0a860cab5a8e6c3216b66c44fb13 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 16:23:17 -0400 Subject: [PATCH 19/38] Test minimal repo checkout --- .github/workflows/request-reviews.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 586f338cbe20..2be0494150fa 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -35,14 +35,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 + sparse-checkout: | + .github - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install Python + - name: Setup Python uses: actions/setup-python@v5 with: python-version: '3.x' @@ -74,6 +71,7 @@ jobs: WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"]) + # Step 1: Get the GitHub created PR commit SHA (contains all changes in a single commit) pr_commit_sha = GitHub.get_pr_sha( os.environ["GH_TOKEN"], os.environ["ORG_NAME"], @@ -85,10 +83,11 @@ jobs: print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") + # Step 2: Fetch only the PR commit to get the files changed in the PR out_stream_buffer = StringIO() cmd_ret = RunCmd( "git", - f"fetch origin {pr_commit_sha}", + f"fetch origin --depth=1 {pr_commit_sha}", workingdir=WORKSPACE_PATH, outstream=out_stream_buffer, logging_level=logging.INFO, From db8e599729763d3a0829a5ba3bafbd35983a5969 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 16:28:53 -0400 Subject: [PATCH 20/38] Also checkout BaseTools/Scripts --- .github/workflows/request-reviews.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 2be0494150fa..c2403dfb4e20 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -38,6 +38,7 @@ jobs: fetch-depth: 1 sparse-checkout: | .github + BaseTools/Scripts - name: Setup Python uses: actions/setup-python@v5 From c87b48b7c24c3d8d36c102fc57a849a5f9ee541c Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 16:31:23 -0400 Subject: [PATCH 21/38] Adjust no new reviewers notice message --- .github/workflows/request-reviews.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index c2403dfb4e20..b3b1f21dd289 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -126,7 +126,7 @@ jobs: ) else: print( - "::notice title=No New Reviewers Added!::No reviewers were found that " + "::notice title=No New Reviewers Added::No reviewers were found that " "should be newly requested." ) From 0bbf7f3e944e53c4df772413457c53273813f04c Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 16:58:37 -0400 Subject: [PATCH 22/38] Use GitPython --- .github/scripts/requirements.txt | 1 + .github/workflows/request-reviews.yml | 24 ++++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt index a19a04bd81cc..9fa375c1fa28 100644 --- a/.github/scripts/requirements.txt +++ b/.github/scripts/requirements.txt @@ -10,5 +10,6 @@ edk2-pytool-library==0.* edk2-pytool-extensions==0.* +GitPython==3.* PyGithub==2.* requests==2.* diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index b3b1f21dd289..7d1d18e50376 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -39,6 +39,7 @@ jobs: sparse-checkout: | .github BaseTools/Scripts + Maintainers.txt - name: Setup Python uses: actions/setup-python@v5 @@ -60,13 +61,11 @@ jobs: TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} WORKSPACE_PATH: ${{ github.workspace }} run: | - import logging + import git import os import sys sys.path.append(os.path.join(os.environ["WORKSPACE_PATH"], ".github")) - from edk2toollib.utility_functions import RunCmd - from io import StringIO from scripts import GitHub WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] @@ -85,21 +84,9 @@ jobs: print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") # Step 2: Fetch only the PR commit to get the files changed in the PR - out_stream_buffer = StringIO() - cmd_ret = RunCmd( - "git", - f"fetch origin --depth=1 {pr_commit_sha}", - workingdir=WORKSPACE_PATH, - outstream=out_stream_buffer, - logging_level=logging.INFO, - ) - if cmd_ret != 0: - print( - f"::error title=Commit Fetch Error!::Error fetching PR commit: " - f"[{cmd_ret}]: {out_stream_buffer.getvalue()}" - ) - sys.exit(1) + git.Repo(WORKSPACE_PATH).remotes.origin.fetch(pr_commit_sha, depth=1) + # Step 3: Get the list of reviewers for the PR reviewers = GitHub.get_reviewers_for_range( WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha ) @@ -112,6 +99,8 @@ jobs: f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}" ) + # Step 4: Add the reviewers to the PR + # Note the final requested reviewer list in the workflow run for reference new_reviewers = GitHub.add_reviewers_to_pr( os.environ["GH_TOKEN"], os.environ["ORG_NAME"], @@ -129,4 +118,3 @@ jobs: "::notice title=No New Reviewers Added::No reviewers were found that " "should be newly requested." ) - From 55e0d05af0cbe1f9bfc3815e9839d6d571c12ecd Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:14:05 -0400 Subject: [PATCH 23/38] Use GitPython in GitHub.py --- .github/scripts/GitHub.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index a2dc1a386e11..c8d40c403dbd 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -5,12 +5,12 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # +import git import logging import re -import requests from collections import OrderedDict -from edk2toollib.utility_functions import RunCmd, RunPythonScript +from edk2toollib.utility_functions import RunPythonScript from github import Auth, Github, GithubException from io import StringIO from typing import List @@ -76,7 +76,7 @@ def leave_pr_comment( def get_reviewers_for_range( workspace_path: str, maintainer_file_path: str, - range_start="master", + range_start: str = "master", range_end: str = "HEAD", ) -> List[str]: """Get the reviewers for the current branch. @@ -99,19 +99,8 @@ def get_reviewers_for_range( if range_start == range_end: commits = [range_start] else: - commit_stream_buffer = StringIO() - cmd_ret = RunCmd( - "git", - f"log --format=format:%H {range_start}..{range_end}", - workingdir=workspace_path, - outstream=commit_stream_buffer, - logging_level=logging.INFO,) - if cmd_ret != 0: - print( - f"::error title=Commit Lookup Error!::Error getting branch " - f"commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}") - return [] - commits = commit_stream_buffer.getvalue().splitlines() + commits = [c.hexsha for c in git.Repo(workspace_path) + .iter_commits(f"{range_start}..{range_end}")] raw_reviewers = [] for commit_sha in commits: From 56fbe25d5ae0a05afa7ff910c27ba945b9f32049 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 25 Jul 2024 01:59:12 -0400 Subject: [PATCH 24/38] Add another test reviewer --- Maintainers.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Maintainers.txt b/Maintainers.txt index 9161cde83c13..59b1d48f1997 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -155,3 +155,4 @@ F: UefiCpuPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg M: Project Mu UEFI Bot [uefibot] R: Project Mu Bot [ProjectMuBot] +R: Sean Brogan [spbrogan] From ee1e98db4f78ad01a42375bef2d9e46ab35f421b Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:24:05 -0400 Subject: [PATCH 25/38] Update admin search --- .github/scripts/GitHub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index c8d40c403dbd..817e76412f96 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -226,7 +226,7 @@ def add_reviewers_to_pr( f"the repository so they can be requested in the future.\n\n" f"Non-collaborators requested:\n{', '.join(non_collaborators)}" f"\n\nAttn Admins:\n\n" - f"{'\n'.join([f"- @{a.login}" for a in repo_admins])}") + f"{'\n'.join([f'- @{a}' for a in repo_admins])}") # Add any new reviewers to the PR if needed. if new_pr_reviewers: From 1a26127b185d75a6c8145cdfeced6267b7549c01 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:26:28 -0400 Subject: [PATCH 26/38] Adjust GitHub.py formatting slightly --- .github/scripts/GitHub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 817e76412f96..33bd7862fb47 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -224,7 +224,7 @@ def add_reviewers_to_pr( f"specified as a reviewer for this PR is not a collaborator " f"of the edk2 repository. Please add them as a collaborator to " f"the repository so they can be requested in the future.\n\n" - f"Non-collaborators requested:\n{', '.join(non_collaborators)}" + f"Non-collaborators requested:\n {', '.join(non_collaborators)}" f"\n\nAttn Admins:\n\n" f"{'\n'.join([f'- @{a}' for a in repo_admins])}") From 2a13fc394a78c7237225c33c3d61fc8949861ce2 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:40:52 -0400 Subject: [PATCH 27/38] Prevent non-collab dup comments --- .github/scripts/GitHub.py | 94 ++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 33bd7862fb47..a1d5d0d89f21 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -48,8 +48,10 @@ def _get_pr(token: str, owner: str, repo: str, pr_number: int): g = _authenticate(token) return g.get_repo(f"{owner}/{repo}").get_pull(pr_number) except GithubException as ge: - print(f"::error title=Error Getting PR {pr_number} Info!::" - f"{ge.data['message']}") + print( + f"::error title=Error Getting PR {pr_number} Info!::" + f"{ge.data['message']}" + ) return None @@ -69,8 +71,10 @@ def leave_pr_comment( try: pr.create_issue_comment(comment_body) except GithubException as ge: - print(f"::error title=Error Commenting on PR {pr_number}!::" - f"{ge.data['message']}") + print( + f"::error title=Error Commenting on PR {pr_number}!::" + f"{ge.data['message']}" + ) def get_reviewers_for_range( @@ -99,8 +103,12 @@ def get_reviewers_for_range( if range_start == range_end: commits = [range_start] else: - commits = [c.hexsha for c in git.Repo(workspace_path) - .iter_commits(f"{range_start}..{range_end}")] + commits = [ + c.hexsha + for c in git.Repo(workspace_path).iter_commits( + f"{range_start}..{range_end}" + ) + ] raw_reviewers = [] for commit_sha in commits: @@ -110,12 +118,14 @@ def get_reviewers_for_range( f"-g {commit_sha}", workingdir=workspace_path, outstream=reviewer_stream_buffer, - logging_level=logging.INFO) + logging_level=logging.INFO, + ) if cmd_ret != 0: print( f"::error title=Reviewer Lookup Error!::Error calling " f"GetMaintainer.py: [{cmd_ret}]: " - f"{reviewer_stream_buffer.getvalue()}") + f"{reviewer_stream_buffer.getvalue()}" + ) return [] commit_reviewers = reviewer_stream_buffer.getvalue() @@ -127,7 +137,8 @@ def get_reviewers_for_range( print( f"::debug title=Commit {commit_sha[:7]} " - f"Reviewer(s)::{', '.join(matches)}") + f"Reviewer(s)::{', '.join(matches)}" + ) raw_reviewers.extend(matches) @@ -181,8 +192,10 @@ def add_reviewers_to_pr( from the list provided if they are not relevant to the PR. """ if not user_names: - print("::debug title=No PR Reviewers Requested!::" - "The list of PR reviewers is empty so not adding any reviewers.") + print( + "::debug title=No PR Reviewers Requested!::" + "The list of PR reviewers is empty so not adding any reviewers." + ) return [] try: @@ -190,8 +203,10 @@ def add_reviewers_to_pr( repo_gh = g.get_repo(f"{owner}/{repo}") pr = repo_gh.get_pull(pr_number) except GithubException as ge: - print(f"::error title=Error Getting PR {pr_number} Info!::" - f"{ge.data['message']}") + print( + f"::error title=Error Getting PR {pr_number} Info!::" + f"{ge.data['message']}" + ) return None # The pull request author cannot be a reviewer. @@ -209,29 +224,44 @@ def add_reviewers_to_pr( # Notify the admins of the repository if non-collaborators are requested. if non_collaborators: - repo_admins = [a.login for a in repo_gh.get_collaborators(permission='admin')] + for comment in pr.get_issue_comments(): + # If a comment has already been made for these non-collaborators, + # do not make another comment. + if ( + comment.user.login == "github-actions[bot]" + and "WARNING: Cannot add some reviewers" in comment.body + and all(u in comment.body for u in non_collaborators) + ): + break + else: + repo_admins = [ + a.login for a in repo_gh.get_collaborators(permission="admin") + ] - print( - f"::warning title=Non-Collaborator Reviewers Found!::" - f"{', '.join(non_collaborators)}") - - leave_pr_comment( - token, - owner, - repo, - pr_number, - f"⚠ **WARNING: Cannot add some reviewers**: A user " - f"specified as a reviewer for this PR is not a collaborator " - f"of the edk2 repository. Please add them as a collaborator to " - f"the repository so they can be requested in the future.\n\n" - f"Non-collaborators requested:\n {', '.join(non_collaborators)}" - f"\n\nAttn Admins:\n\n" - f"{'\n'.join([f'- @{a}' for a in repo_admins])}") + print( + f"::warning title=Non-Collaborator Reviewers Found!::" + f"{', '.join(non_collaborators)}" + ) + + leave_pr_comment( + token, + owner, + repo, + pr_number, + f"⚠ **WARNING: Cannot add some reviewers**: A user " + f"specified as a reviewer for this PR is not a collaborator " + f"of the repository. Please add them as a collaborator to " + f"the repository so they can be requested in the future.\n\n" + f"Non-collaborators requested:\n" + f" {', '.join(non_collaborators)}\n\nAttn Admins:\n\n" + f"{'\n'.join([f'- @{a}' for a in repo_admins])}", + ) # Add any new reviewers to the PR if needed. if new_pr_reviewers: - print(f"::debug title=Adding New PR Reviewers::" - f"{', '.join(new_pr_reviewers)}") + print( + f"::debug title=Adding New PR Reviewers::" f"{', '.join(new_pr_reviewers)}" + ) pr.create_review_request(reviewers=new_pr_reviewers) From ee12191cbab8d3de22d749bbfc9dac373831d527 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:44:23 -0400 Subject: [PATCH 28/38] Add another non-collab to UefiCpuPkg --- Maintainers.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Maintainers.txt b/Maintainers.txt index 59b1d48f1997..ae6415b329ad 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -156,3 +156,4 @@ W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg M: Project Mu UEFI Bot [uefibot] R: Project Mu Bot [ProjectMuBot] R: Sean Brogan [spbrogan] +R: Joey Vagedes [javagedes] From 0e5eddfea267b58334554a7fe0cddd9f5fd92f61 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 17:50:37 -0400 Subject: [PATCH 29/38] Show workflow UI message even on no comment --- .github/scripts/GitHub.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index a1d5d0d89f21..3b919a2dbcc6 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -224,6 +224,11 @@ def add_reviewers_to_pr( # Notify the admins of the repository if non-collaborators are requested. if non_collaborators: + print( + f"::warning title=Non-Collaborator Reviewers Found!::" + f"{', '.join(non_collaborators)}" + ) + for comment in pr.get_issue_comments(): # If a comment has already been made for these non-collaborators, # do not make another comment. @@ -238,11 +243,6 @@ def add_reviewers_to_pr( a.login for a in repo_gh.get_collaborators(permission="admin") ] - print( - f"::warning title=Non-Collaborator Reviewers Found!::" - f"{', '.join(non_collaborators)}" - ) - leave_pr_comment( token, owner, From 4542d7d956dcd2e14b06ee45232793dfe02bc7ae Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 18:25:48 -0400 Subject: [PATCH 30/38] Add exclusion --- .github/scripts/GitHub.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 3b919a2dbcc6..ae86c6c12f5e 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -212,8 +212,14 @@ def add_reviewers_to_pr( # The pull request author cannot be a reviewer. pr_author = pr.user.login.strip() - # The current reviewers of the PR do not need to be requested again. - current_pr_reviewers = [r.login.strip() for r in pr.get_review_requests()[0]] + # The current PR reviewers do not need to be requested again. + current_pr_requested_reviewers = [ + r.login.strip() for r in pr.get_review_requests()[0] + ] + current_pr_reviewed_reviewers = [r.user.login.strip() for r in pr.get_reviews()] + current_pr_reviewers = list( + set(current_pr_requested_reviewers + current_pr_reviewed_reviewers) + ) # A user can only be added if they are a collaborator of the repository. repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators()] From 58a8fad37eac7df0b9f46303e81bca5eef1ec96f Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 28 Jul 2024 19:30:24 -0400 Subject: [PATCH 31/38] Remove requests from requirements.txt --- .github/scripts/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt index 9fa375c1fa28..9102ca158f48 100644 --- a/.github/scripts/requirements.txt +++ b/.github/scripts/requirements.txt @@ -12,4 +12,3 @@ edk2-pytool-library==0.* edk2-pytool-extensions==0.* GitPython==3.* PyGithub==2.* -requests==2.* From e0c3d2916c8bb2676919a9c2d668c65015992552 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Fri, 2 Aug 2024 22:43:28 -0400 Subject: [PATCH 32/38] Move workflow implementation to standalone py file --- .github/scripts/RequestPrReviewers.py | 98 +++++++++++++++++++++++++++ .github/scripts/requirements.txt | 1 - .github/workflows/request-reviews.yml | 60 +--------------- 3 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 .github/scripts/RequestPrReviewers.py diff --git a/.github/scripts/RequestPrReviewers.py b/.github/scripts/RequestPrReviewers.py new file mode 100644 index 000000000000..fdff65761708 --- /dev/null +++ b/.github/scripts/RequestPrReviewers.py @@ -0,0 +1,98 @@ +## @file +# Used in a CI workflow to request reviewers for a pull request. +# +# Refer to the following link for a list of pre-defined GitHub workflow +# environment variables: +# https://docs.github.com/actions/reference/environment-variables +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +import git +import GitHub +import os +import sys + + +"""Request Pull Request Reviewers Helpers""" + + +def request_pr_reviewers(): + """Request pull request reviewers for a GitHub PR. + + This function is intended to be used in a GitHub Actions workflow to + request reviewers for a pull request triggered by a GitHub event. The + function makes assumptions about GitHub workflow environment variables and + the pull request context in which it is run. + + The function will exit with a non-zero status indicating an error if a + critical error occurs during execution so the workflow fails. + + The following environment variables are expected to be set before calling + this function. The recommend GitHub context values are show for reference: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_NAME: ${{ github.repository_owner }} + PR_NUMBER: ${{ github.event.number}} + REPO_NAME: ${{ github.event.pull_request.base.repo.name }} + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} + WORKSPACE_PATH: ${{ github.workspace }} + """ + WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] + GET_MAINTAINER_LOCAL_PATH = os.path.join( + WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"] + ) + + # Step 1: Get the GitHub created PR commit SHA (contains all changes in a single commit) + pr_commit_sha = GitHub.get_pr_sha( + os.environ["GH_TOKEN"], + os.environ["ORG_NAME"], + os.environ["REPO_NAME"], + int(os.environ["PR_NUMBER"]), + ) + if not pr_commit_sha: + sys.exit(1) + + print( + f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}" + ) + + # Step 2: Fetch only the PR commit to get the files changed in the PR + git.Repo(WORKSPACE_PATH).remotes.origin.fetch(pr_commit_sha, depth=1) + + # Step 3: Get the list of reviewers for the PR + reviewers = GitHub.get_reviewers_for_range( + WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha + ) + if not reviewers: + print("::notice title=No New Reviewers Found!::No reviewers found for this PR.") + sys.exit(0) + + print( + f"::notice title=Preliminary Reviewer List::Total reviewer candidates for " + f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}" + ) + + # Step 4: Add the reviewers to the PR + # Note the final requested reviewer list in the workflow run for reference + new_reviewers = GitHub.add_reviewers_to_pr( + os.environ["GH_TOKEN"], + os.environ["ORG_NAME"], + os.environ["REPO_NAME"], + int(os.environ["PR_NUMBER"]), + reviewers, + ) + if new_reviewers: + print( + f"::notice title=New Reviewers Added::New reviewers requested for PR " + f"{os.environ['PR_NUMBER']}: {', '.join(new_reviewers)}" + ) + else: + print( + "::notice title=No New Reviewers Added::No reviewers were found that " + "should be newly requested." + ) + + +if __name__ == '__main__': + request_pr_reviewers() diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt index 9102ca158f48..c589084ab035 100644 --- a/.github/scripts/requirements.txt +++ b/.github/scripts/requirements.txt @@ -9,6 +9,5 @@ ## edk2-pytool-library==0.* -edk2-pytool-extensions==0.* GitPython==3.* PyGithub==2.* diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml index 7d1d18e50376..56776bbc0f35 100644 --- a/.github/workflows/request-reviews.yml +++ b/.github/workflows/request-reviews.yml @@ -52,7 +52,6 @@ jobs: run: pip install -r .github/scripts/requirements.txt --upgrade - name: Add Reviewers to Pull Request - shell: python env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ORG_NAME: ${{ github.repository_owner }} @@ -60,61 +59,4 @@ jobs: REPO_NAME: ${{ github.event.pull_request.base.repo.name }} TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} WORKSPACE_PATH: ${{ github.workspace }} - run: | - import git - import os - import sys - - sys.path.append(os.path.join(os.environ["WORKSPACE_PATH"], ".github")) - from scripts import GitHub - - WORKSPACE_PATH = os.environ["WORKSPACE_PATH"] - GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"]) - - # Step 1: Get the GitHub created PR commit SHA (contains all changes in a single commit) - pr_commit_sha = GitHub.get_pr_sha( - os.environ["GH_TOKEN"], - os.environ["ORG_NAME"], - os.environ["REPO_NAME"], - int(os.environ["PR_NUMBER"]), - ) - if not pr_commit_sha: - sys.exit(1) - - print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}") - - # Step 2: Fetch only the PR commit to get the files changed in the PR - git.Repo(WORKSPACE_PATH).remotes.origin.fetch(pr_commit_sha, depth=1) - - # Step 3: Get the list of reviewers for the PR - reviewers = GitHub.get_reviewers_for_range( - WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha - ) - if not reviewers: - print("::notice title=No New Reviewers Found!::No reviewers found for this PR.") - sys.exit(0) - - print( - f"::notice title=Preliminary Reviewer List::Total reviewer candidates for " - f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}" - ) - - # Step 4: Add the reviewers to the PR - # Note the final requested reviewer list in the workflow run for reference - new_reviewers = GitHub.add_reviewers_to_pr( - os.environ["GH_TOKEN"], - os.environ["ORG_NAME"], - os.environ["REPO_NAME"], - int(os.environ["PR_NUMBER"]), - reviewers, - ) - if new_reviewers: - print( - f"::notice title=New Reviewers Added::New reviewers requested for PR " - f"{os.environ['PR_NUMBER']}: {', '.join(new_reviewers)}" - ) - else: - print( - "::notice title=No New Reviewers Added::No reviewers were found that " - "should be newly requested." - ) + run: python .github/scripts/RequestPrReviewers.py From 5c5a41886fd9cdbd34e564078b0985f61451c652 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 5 Aug 2024 10:34:02 -0400 Subject: [PATCH 33/38] add more info to non-collab comment --- .github/scripts/GitHub.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index ae86c6c12f5e..fc1d2cab1e7d 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -260,7 +260,12 @@ def add_reviewers_to_pr( f"the repository so they can be requested in the future.\n\n" f"Non-collaborators requested:\n" f" {', '.join(non_collaborators)}\n\nAttn Admins:\n\n" - f"{'\n'.join([f'- @{a}' for a in repo_admins])}", + f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n\n" + f"- Add the non-collaborators as collaborators to the " + f"appropriate team(s) listed in " + f"[teams](https://github.com/orgs/tianocore/teams)\n" + f"- If they are no longer needed as reviewers, remove them " + f"from [`Maintainers.txt`](https://github.com/tianocore/edk2/blob/HEAD/Maintainers.txt)", ) # Add any new reviewers to the PR if needed. From 12820f6c2f42dc908472b49440da5aa1460a3b22 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 5 Aug 2024 10:39:56 -0400 Subject: [PATCH 34/38] update comment --- .github/scripts/GitHub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index fc1d2cab1e7d..c0c53d753f66 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -260,7 +260,7 @@ def add_reviewers_to_pr( f"the repository so they can be requested in the future.\n\n" f"Non-collaborators requested:\n" f" {', '.join(non_collaborators)}\n\nAttn Admins:\n\n" - f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n\n" + f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n" f"- Add the non-collaborators as collaborators to the " f"appropriate team(s) listed in " f"[teams](https://github.com/orgs/tianocore/teams)\n" From 7c2485311df950241f6e6eaaaddc57bf6c93569b Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 5 Aug 2024 10:43:31 -0400 Subject: [PATCH 35/38] update comment --- .github/scripts/GitHub.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index c0c53d753f66..a2502e68248d 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -259,7 +259,8 @@ def add_reviewers_to_pr( f"of the repository. Please add them as a collaborator to " f"the repository so they can be requested in the future.\n\n" f"Non-collaborators requested:\n" - f" {', '.join(non_collaborators)}\n\nAttn Admins:\n\n" + f"{'\n'.join([f'- @{a}' for c in non_collaborators])}" + f"\n\nAttn Admins:\n" f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n" f"- Add the non-collaborators as collaborators to the " f"appropriate team(s) listed in " From ab014fcf9bf3ec213228eda1144c9b155c663c58 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 5 Aug 2024 10:44:10 -0400 Subject: [PATCH 36/38] update comment --- .github/scripts/GitHub.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index a2502e68248d..daa89e51d2fa 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -262,6 +262,7 @@ def add_reviewers_to_pr( f"{'\n'.join([f'- @{a}' for c in non_collaborators])}" f"\n\nAttn Admins:\n" f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n" + f"Admin Instructions:\n" f"- Add the non-collaborators as collaborators to the " f"appropriate team(s) listed in " f"[teams](https://github.com/orgs/tianocore/teams)\n" From dafe44768323023806e944c91bc42019582b5a57 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 5 Aug 2024 10:45:38 -0400 Subject: [PATCH 37/38] update comment --- .github/scripts/GitHub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index daa89e51d2fa..38d9e6ac8519 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -259,7 +259,7 @@ def add_reviewers_to_pr( f"of the repository. Please add them as a collaborator to " f"the repository so they can be requested in the future.\n\n" f"Non-collaborators requested:\n" - f"{'\n'.join([f'- @{a}' for c in non_collaborators])}" + f"{'\n'.join([f'- @{c}' for c in non_collaborators])}" f"\n\nAttn Admins:\n" f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n" f"Admin Instructions:\n" From 101149733b1f582dc86b7dc591f79e5518faf735 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 18:43:42 +0000 Subject: [PATCH 38/38] pip: bump lcov-cobertura from 2.0.2 to 2.1.1 Bumps [lcov-cobertura](https://eriwen.github.io/lcov-to-cobertura-xml/) from 2.0.2 to 2.1.1. --- updated-dependencies: - dependency-name: lcov-cobertura dependency-version: 2.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pip-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip-requirements.txt b/pip-requirements.txt index e07b9cac52c5..adc0075ccf4f 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -16,5 +16,5 @@ edk2-pytool-library==0.21.8 edk2-pytool-extensions==0.27.6 edk2-basetools==0.1.51 antlr4-python3-runtime==4.7.1 -lcov-cobertura==2.0.2 +lcov-cobertura==2.1.1 regex==2024.5.15