Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add check to see if release notes was modified #2789

Draft
wants to merge 38 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c6eba39
add check to see if release notes was modified
davidmrdavid Apr 11, 2024
49501f7
add this branch for validation
davidmrdavid Apr 11, 2024
53a4ca9
relax constraints
davidmrdavid Apr 11, 2024
f37ca07
relax constraints
davidmrdavid Apr 11, 2024
cf5678f
add yml
davidmrdavid Apr 11, 2024
a3401b4
add empty line
davidmrdavid Apr 11, 2024
26f89c1
close if-else-chain
davidmrdavid Apr 11, 2024
5864e93
change md
davidmrdavid Apr 11, 2024
3649ecb
add labels check
davidmrdavid Apr 11, 2024
4d0cf6c
add space
davidmrdavid Apr 11, 2024
dc563f4
add echo
davidmrdavid Apr 11, 2024
1e63f82
change condition
davidmrdavid Apr 11, 2024
3fa67fd
make validation re-run on relabeling
davidmrdavid Apr 11, 2024
2eb8d65
remove pull_request_target
davidmrdavid Apr 11, 2024
49cc860
add labeling trigger
davidmrdavid Apr 11, 2024
37523b8
add labels again
davidmrdavid Apr 11, 2024
2ed6cf6
add version correctness check
davidmrdavid Apr 11, 2024
789eaff
rename proj
davidmrdavid Apr 11, 2024
6231ae6
patch version constructor
davidmrdavid Apr 11, 2024
effa54f
use latest tag
davidmrdavid Apr 11, 2024
1fcc73f
add minorVersion check
davidmrdavid Apr 11, 2024
1267c75
make next step not run
davidmrdavid Apr 11, 2024
9e7b7db
check patch
davidmrdavid Apr 11, 2024
81f1739
test multi-line strs
davidmrdavid Apr 11, 2024
416504d
try setting env vars
davidmrdavid Apr 11, 2024
f3ccaf8
test
davidmrdavid Apr 11, 2024
a6430fb
improve message
davidmrdavid Apr 11, 2024
7eca545
improve err
davidmrdavid Apr 11, 2024
59d5780
add label check
davidmrdavid Apr 11, 2024
61b3ea5
make validation run on labeled
davidmrdavid Apr 11, 2024
53051e1
fix
davidmrdavid Apr 11, 2024
36d459d
translate to pwsh
davidmrdavid Apr 11, 2024
fa03f72
comment the release notes action
davidmrdavid Apr 11, 2024
7110642
add missing space
davidmrdavid Apr 11, 2024
983a94c
add quotes around strings
davidmrdavid Apr 11, 2024
48b4d70
add more comments
davidmrdavid Apr 11, 2024
e6597f0
rename files
davidmrdavid Apr 11, 2024
d75a665
change triggers
davidmrdavid Apr 11, 2024
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
50 changes: 50 additions & 0 deletions .github/workflows/release-notes-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Check release_notes.md is updated

on:
workflow_dispatch:
push:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
paths:
- '*'

pull_request:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
types: [labeled, unlabeled, synchronize] # Trigger on PR labeling events, or a PR push (synchronize)
paths:
- '.github/workflows/release-notes-check.yml'
- '.github/workflows/version-check.yml'

jobs:
build:
runs-on: ubuntu-latest
# Skip all validation if label 'no-release-notes' is applied to the PR
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-release-notes') }}
steps:
- uses: actions/checkout@v2

- name: Check `release_notes.md`
id: check_changes
shell: pwsh
run: |

Write-Host "Checking for changes in release_notes.md..."

# `github.sha` is documented here : https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
# `github.event.before` is documented here (under "Webhook payload object for push"): https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
$latestCommitInPR = "${{ github.sha }}"
$latestCommitInTargetBranch = "${{ github.event.before }}"

# Get list of files changed in this PR
$changedFiles = git diff --name-only latestCommitInTargetBranch $latestCommitInPR

# If `release_notes.md` was modified, the PR passes the validation.
# If it's not modified, fail and instruct author on what to do (either modify it or add 'no-release-notes' label)
if ($changedFiles -match "release_notes.md") {
Write-Host "release_notes.md was modified. Pass!"
} else {
$errorMessage = "This PR does not update `release_notes.md`. If the PR should be included " +
"in the next release's release notes, please update this file. If the PR should not be included, " +
"then please add the label `no-release-notes` to the PR."
Write-Error $errorMessage
exit 1 # Fail the GH action
}
126 changes: 126 additions & 0 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Guarantee WebJobs Extension version is correct

on:
workflow_dispatch:
push:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
paths:
- '*'
pull_request:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
types: [labeled, unlabeled, synchronize] # Trigger on PR labeling events, or a PR push (synchronize)
paths:
- '.github/workflows/release-notes-check.yml'
- '.github/workflows/version-check.yml'

jobs:
build:
runs-on: ubuntu-latest
# Skip all validation if label 'version-already-correct' is applied to the PR
if: ${{ !contains(github.event.pull_request.labels.*.name, 'version-already-correct') }}
steps:
- uses: actions/checkout@v2
- name: Ensure a label is provided
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }} &&
${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }} &&
${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }} &&
shell: pwsh
run: |
$errorMessage = "This PR does not include either the 'major-pr', 'minor-pr', or 'patch-pr' labels, "+
"which correspond to whether this change warrants a major, minor, or patch version increase over the "+
"last release, nor does it include a 'version-already-correct' label, indicating the WebJobs extension "+
"version is correct as-is. Label this PR with one of those four labels to proceed."
Write-Error $errorMessage
- name: Obtain version in csproj and version of latest tag
shell: pwsh
run: |
$csprojPath = ".\src\WebJobs.Extensions.DurableTask\WebJobs.Extensions.DurableTask.csproj"

# Parse the .csproj file to reconstruct the version
[xml]$csproj = Get-Content -Path $csprojPath
$majorVersionString = $csproj.Project.PropertyGroup.MajorVersion
$minorVersionString = $csproj.Project.PropertyGroup.MinorVersion
$patchVersionString = $csproj.Project.PropertyGroup.PatchVersion
$version = "$majorVersionString.$minorVersionString.$patchVersionString"
$projectVersion = [Version]$version
"PROJ_VERSION=$projectVersion" | Out-File -Append -FilePath $Env:GITHUB_ENV


# Obtain latest tag
git fetch --tags
$latestTag = git describe --tags $(git rev-list --tags --max-count=1)
Write-Output "Latest tag in the repository is $latestTag"

$latestTag = $latestTag.TrimStart('v')
$minVersion = [Version]$latestTag
"MIN_VERSION=$minVersion" | Out-File -Append -FilePath $Env:GITHUB_ENV


# Split the version number by '.' character
$versionParts = $latestTag -split '\.'

# decompose the tag
$tagMajor = $versionParts[0]
$tagMinor = $versionParts[1]
$tagPatch = $versionParts[2]

# Set version components as environment variables for future use
"TAG_MAJOR=$($versionParts[0])" | Out-File -Append -FilePath $Env:GITHUB_ENV
"TAG_MINOR=$($versionParts[1])" | Out-File -Append -FilePath $Env:GITHUB_ENV
"TAG_PATCH=$($versionParts[2])" | Out-File -Append -FilePath $Env:GITHUB_ENV

"PROJ_MAJOR=$($tagMajor)" | Out-File -Append -FilePath $Env:GITHUB_ENV
"PROJ_MINOR=$($tagMinor)" | Out-File -Append -FilePath $Env:GITHUB_ENV
"PROJ_PATCH=$($tagPatch)" | Out-File -Append -FilePath $Env:GITHUB_ENV

# Compare the project version to the minimum required version
if ($projectVersion -lt $minVersion) {
Write-Error "WebJobs extension version ($projectVersion) is less than the minimum required version ($minVersion)."
exit 1
} else {
Write-Host "WebJobs extension version ($projectVersion) meets the minimum required version ($minVersion)."
}

- name: Check minorVersion
if: ${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }}
shell: pwsh
run: |
# Compare the project version to the minimum required version
if ($env:PROJ_PATCH -lt $env:TAG_PATCH) {
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
"a patch-release greater than the latest tag version ($env:MIN_VERSION)." +
"Please increment the patch version or remove the `patch-pr` label."
Write-Error $errorMessage
exit 1
} else {
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
}
- name: Check minorVersion
if: ${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }}
shell: pwsh
run: |
# Ensure that csproj is at least one minor version greater than the last release
if ($env:PROJ_MINOR -lt $env:TAG_MINOR) {
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
"a patch-release greater than the latest tag version ($env:MIN_VERSION)." +
"Please increment the patch version or remove the `patch-pr` label."
Write-Error $errorMessage
exit 1
} else {
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
}

- name: Check majorVersion
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }}
shell: pwsh
run: |
# Ensure that csproj is at least one major version greater than the last release
if ($env:PROJ_MAJOR -lt $env:TAG_MAJOR) {
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
"a major-release greater than the latest tag version ($env:MIN_VERSION)." +
"Please increment the patch version or remove the `patch-pr` label."
Write-Error $errorMessage
exit 1
} else {
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
}
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release Notes


## Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.2.0

### New Features
Expand Down
Loading