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

Add to CI check for specification version. #1760

Merged
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
65 changes: 65 additions & 0 deletions .github/workflows/specification-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Specification version check

on:
schedule:
- cron: '0 13 * * *'
workflow_dispatch:

permissions:
contents: read
issues: write

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 (" + spec_version + ") version does not matches with python-tuf supported (" +
supported_version + ") version."
)
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:" + repo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the "in:title" search might actually require quotes to get an exact search string but I think I'm fine with this: let's have another look if we get false positives in this.

})
if (issues.data.total_count > 0) {
console.log("Issue is already open, not creating.")
} else {
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."
})
console.log("New issue created.")
}
} else {
console.log(
"Specification (" + spec_version + ") version matches with python-tuf supported (" +
supported_version + ") version."
)
}