Skip to content

Commit

Permalink
Add tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ladatz committed Jan 19, 2024
1 parent 5673bd6 commit 0959ee7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .markdownlinkcheck.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ignorePatterns": [
{
"pattern": "^http://localhost"
}
],
"aliveStatusCodes": [
200,
203,
206
],
"_retryComment": "enable retry on 429, this seems to be happening with GitHub links sometimes.",
"retryOn429": true,
"retryCount": 2,
"_fallbackRetryDelayComment": "The `fallbackRetryDelay` is only used when the `retry-after` header of the response has an invalid value. See https://github.com/tcort/markdown-link-check#config-file-format for more info",
"fallbackRetryDelay": "60s"
}
12 changes: 12 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// disable line length limitations for existing documentation
"MD013": false,
// allow same headings
"MD024": false,
// allow inline html
"MD033": false,
//ignore first line headers
"MD041": false,
// code block style
"MD046": false
}
51 changes: 51 additions & 0 deletions tools/notice_generation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT

set -e
cd "$(dirname "$0")/.."

if ! command -v gh &> /dev/null
then
echo "GitHub CLI not found. Please install before running the script."
exit
fi

if [ -z "$GITHUB_PAT_TOKEN" ]
then
echo "Missing \$GITHUB_PAT_TOKEN environment variable. Please set it before running the script."
exit
fi

if ! command -v cargo-about &> /dev/null
then
echo "Cargo-about could not be found. Installing now"
cargo install --locked cargo-about
fi

PR_TITLE="chore: Notice file change"
if [ "$(gh pr list --search "$PR_TITLE" --json number | jq '. | length')" -gt 0 ]
then
echo>&2 "A PR is already there for a NOTICE file change. Please merge it or cancel it to have this pipeline properly running."
exit 1
fi

NOTICE_FILENAME="NOTICE"
echo "Running cargo-about for NOTICE file generation..."
cargo about generate --workspace devops/cg/about.hbs --config devops/cg/about.toml | sed -E 's/[ \t]+\r?$//' > $NOTICE_FILENAME

if [ -z "$(git diff --name-only $NOTICE_FILENAME)" ]
then
echo "File not changed"
else
echo "File changed. Checking out a new branch and creating a PR"
BRANCH_NAME="fix/notice-file-update-$(date +%s)"
git checkout -b "$BRANCH_NAME"
git add $NOTICE_FILENAME
git commit -m "New notice file"
git push -f --set-upstream origin "$BRANCH_NAME"
## token needs repo access and read:org
echo "$GITHUB_PAT_TOKEN" | gh auth login --with-token
gh pr create -B main -H "$BRANCH_NAME" --title "$PR_TITLE" --body 'This PR is merging latest changes related to notice file. Please review them before approving.'
fi

0 comments on commit 0959ee7

Please sign in to comment.