forked from theupdateframework/python-tuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add to CI check for specification version.
This commit adds to the CI an automatic check for the TUF specification version and compares it with the python-tuf metadata API version. If the version does not match and there is not a issue already open, a new issue is opened. Closes theupdateframework#1598 Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
- Loading branch information
Kairo de Araujo
committed
Jan 7, 2022
1 parent
45cf607
commit faa9573
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Specification version check | ||
|
||
on: | ||
schedule: | ||
- cron: '0 13 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-spec-version: | ||
name: Open an issue when spec version bumps | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- name: Get supported version | ||
id: get-version | ||
run: | | ||
python3 -m pip install -e . | ||
script="from tuf.api.metadata import SPECIFICATION_VERSION; \ | ||
print(f\"v{'.'.join(SPECIFICATION_VERSION)}\")" | ||
ver=$(python3 -c "$script") | ||
echo "::set-output name=version::$ver" | ||
- name: Open issue (if needed) | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
const release = await github.rest.repos.getLatestRelease({ | ||
owner: "theupdateframework", | ||
repo: "specification" | ||
}); | ||
const spec_version = release.data.tag_name | ||
const supported_version = "${{ steps.get-version.outputs.version }}" | ||
if (spec_version != supported_version) { | ||
console.log("Specification version does not match...") | ||
const repo = context.repo.owner + "/" + context.repo.repo | ||
const issues = await github.rest.search.issuesAndPullRequests({ | ||
q: "specification+has+new+version+in:title+state:open+type:issue:" + repo, | ||
}) | ||
if (issues.data.total_count > 0) { | ||
console.log("Issue is already open, not creating.") | ||
} else { | ||
console.log("Creating a new issue...") | ||
await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: "specification has new version", | ||
body: "It seems specification " + | ||
"(https://github.com/theupdateframework/specification/blob/master/tuf-spec.md) " + | ||
"has new version. \n" + | ||
"Please review the version." | ||
}) | ||
} | ||
} else { | ||
console.log("Spec version and supported version match") | ||
} |