Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "PR Labeling"
on:
pull_request_target:
types: [opened, closed, synchronize, reopened, edited, ready_for_review]

permissions:
contents: read
pull-requests: write
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/validation_mrtk3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ on:
push:
branches:
- main
- 'feature/*'
- "feature/*"
pull_request:

jobs:
validation:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6

- name: Get Pull Request changes
if: github.event_name == 'pull_request'
run: |
${{ github.workspace }}/Pipelines/Scripts/gitchanges.ps1 -TargetBranch '${{ github.base_ref }}' -OutputFile '${{ runner.temp }}/build/changed_files.txt' -RepoRoot '${{ github.workspace }}'
shell: pwsh
- name: Get Pull Request changes
if: github.event_name == 'pull_request'
run: |
${{ github.workspace }}/Pipelines/Scripts/gitchanges.ps1 -TargetBranch '${{ github.base_ref }}' -OutputFile '${{ runner.temp }}/build/changed_files.txt' -RepoRoot '${{ github.workspace }}'
shell: pwsh

- name: Scoped code validation
if: github.event_name == 'pull_request'
run: |
${{ github.workspace }}/Pipelines/Scripts/validatecode.ps1 -Directory '${{ github.workspace }}' -ChangesFile '${{ runner.temp }}/build/changed_files.txt'
shell: pwsh
- name: Scoped code validation
if: github.event_name == 'pull_request'
run: |
${{ github.workspace }}/Pipelines/Scripts/validatecode.ps1 -Directory '${{ github.workspace }}' -ChangesFile '${{ runner.temp }}/build/changed_files.txt'
shell: pwsh

- name: Global code validation
if: github.event_name == 'push'
run: |
${{ github.workspace }}/Pipelines/Scripts/validatecode.ps1 -Directory '${{ github.workspace }}'
shell: pwsh
- name: Global code validation
if: github.event_name == 'push'
run: |
${{ github.workspace }}/Pipelines/Scripts/validatecode.ps1 -Directory '${{ github.workspace }}'
shell: pwsh

- name: Check changelogs
if: github.event_name == 'pull_request'
run: |
${{ github.workspace }}/Pipelines/Scripts/check-changelogs.ps1 -ChangesFile '${{ runner.temp }}/build/changed_files.txt'
shell: pwsh
63 changes: 63 additions & 0 deletions Pipelines/Scripts/check-changelogs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) Mixed Reality Toolkit Contributors
# Licensed under the BSD 3-Clause

<#
.SYNOPSIS
Validates that changelogs have been properly updated for changed files.
.DESCRIPTION
Validates that changelogs have been properly updated for changed files.
.EXAMPLE
.\check-changelogs.ps1 -ChangesFile c:\path\to\changes\file.txt
#>
param(
# The filename containing the list of files to scope the code validation
# to. This is useful in pull request validation when there isn't a need
# to check every single file in the repo for changes (i.e. only the list
# of changed files)
[Parameter(Mandatory = $true)]
[string]$ChangesFile
)

$changelogUpdated = @{ }

# If the file containing the list of changes was provided and actually exists,
# this validation should scope to only those changed files.
if ($ChangesFile -and (Test-Path $ChangesFile -PathType leaf)) {
Get-Content $ChangesFile | ForEach-Object {
Write-Host "Checking file: $_"
$packageName = $_ | Select-String -Pattern "org\.mixedrealitytoolkit\.\w+(\.\w+)*" | Select-Object -First 1

if (-not $packageName) {
return # this is not an MRTK package, so skip
}

$packageName = $packageName.Matches[0].Value

$isChangelog = $_ -match "CHANGELOG.md"
if ($changelogUpdated.ContainsKey($packageName)) {
if ($isChangelog) {
$changelogUpdated[$packageName] = $true
}
}
else {
$changelogUpdated[$packageName] = $isChangelog
}
}
}

$containsIssue = $false
$changelogUpdated.GetEnumerator() | ForEach-Object {
if (-not $_.Value) {
Write-Warning "Package '$($_.Key)' has changes, but its CHANGELOG.md was not updated. This is not always an issue but usually is"
$containsIssue = $true
}
}

if ($containsIssue) {
Write-Output "Potential issues found, please see above for details"
exit 1;
}
else {
Write-Output "No issues found"
exit 0;
}