blackduck: open PR on NOTICES file change (#8215)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Gary Verhaegen 2020-12-10 10:08:28 +01:00 committed by GitHub
parent e2e0523b78
commit 029c655adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 24 deletions

View File

@ -578,32 +578,16 @@ jobs:
fi
done
AUTH="$(get_gh_auth_header)"
trap "git checkout $(branch_sha)" EXIT
git checkout origin/master
BRANCH=update-compat-versions-for-$(release_tag)
# if this is a rerun, branch might already exist
git branch -D $BRANCH || true
git checkout -b $BRANCH
cp .bazelrc compatibility/
compatibility/update-versions.sh
# Note that maven_install.json might be unchanged but
# git add is happy about that.
git add compatibility/versions.bzl compatibility/maven_install.json
git -c user.name="Azure Pipelines DAML Build" \
-c user.email="support@digitalasset.com" \
commit \
-m "$(printf "update compat versions for $(release_tag)\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
git push origin $BRANCH:$BRANCH
curl -H "Content-Type: application/json" \
-H "$AUTH" \
--silent \
--fail \
--include \
--location \
-d "{\"title\": \"update compat versions for $(release_tag)\", \"head\": \"$BRANCH\", \"base\": \"master\"}" \
https://api.github.com/repos/digital-asset/daml/pulls
BRANCH=update-compat-versions-for-$(release_tag)-$(Build.BuildId)
TITLE="update compat versions for $(release_tag)"
open_pr "$BRANCH" "$TITLE"
setvar "branch" "$BRANCH"
name: out

View File

@ -22,6 +22,29 @@ steps:
echo "Authorization: basic $(git config remote.origin.url | grep -o '://.*:.*@' | cut -c4- | rev | cut -c2- | rev | tr -d '\n' | base64 -w0)"
fi
}
open_pr() {
local branch title
branch="$1"
title="$2"
git branch -D $branch || true
git checkout -b $branch
git -c user.name="Azure Pipelines DAML Build" \
-c user.email="support@digitalasset.com" \
commit \
-m "$(printf "$title\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
git push origin $branch:$branch
jq -n --arg title "$title" \
--arg branch "$branch" \
'{"title": $title, "head": $branch, "base": "master"}' \
| curl -H "Content-Type: application/json" \
-H "$(get_gh_auth_header)" \
--fail \
--silent \
--include \
--location \
-d @- \
https://api.github.com/repos/digital-asset/daml/pulls
}
user_slack_handle() {
local email sha
sha=$1

View File

@ -204,6 +204,7 @@ jobs:
demands: assignment -equals default
steps:
- checkout: self
persistCredentials: true
- bash: ci/dev-env-install.sh
displayName: 'Build/Install the Developer Environment'
- bash: ci/configure-bazel.sh
@ -211,15 +212,15 @@ jobs:
env:
IS_FORK: $(System.PullRequest.IsFork)
# to upload to the bazel cache
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- bash: |
set -euo pipefail
eval "$(dev-env/bin/dade assist)"
export LC_ALL=en_US.UTF-8
bazel build //...
# Make sure that Bazel query works
bazel query 'deps(//...)'
bazel query 'deps(//...)' >/dev/null
displayName: 'Build'
- bash: |
set -euo pipefail
@ -258,4 +259,20 @@ jobs:
displayName: 'Blackduck Scan'
env:
BLACKDUCK_HUBDETECT_TOKEN: $(BLACKDUCK_HUBDETECT_TOKEN)
- template: ../bash-lib.yml
parameters:
var_name: bash_lib
- bash: |
set -euo pipefail
eval "$(./dev-env/bin/dade-assist)"
source $(bash_lib)
tr -d '\015' <*_Black_Duck_Notices_Report.txt | grep -v digital-asset_daml >NOTICES
if git diff --exit-code -- NOTICES; then
echo "NOTICES file already up-to-date."
else
git add NOTICES
open_pr "notices-update-$(Build.BuildId)" "update NOTICES file"
fi
displayName: notices
- template: ../daily_tell_slack.yml