Skip to content

Commit

Permalink
ci: Modified to operate even in deprecation reason changed situations (
Browse files Browse the repository at this point in the history
…#2000)

Co-authored-by: Sanghun Lee <sanghun@lablup.com>
  • Loading branch information
Yaminyam and fregataa committed Apr 8, 2024
1 parent 9a4baa7 commit 02aad90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update-api-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
echo "name=$author_name" >> $GITHUB_OUTPUT
echo "email=$author_email" >> $GITHUB_OUTPUT
- name: Make commit message for changing change log file
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_author: ${{ steps.get_author_info.outputs.name }} <${{ steps.get_author_info.outputs.email }}>
commit_message: 'chore: update GraphQL schema dump'
Expand All @@ -73,4 +73,4 @@ jobs:
with:
schema: 'main:src/ai/backend/manager/api/schema.graphql'
rules: |
custom-rule.js
gql-inspector-checker.js
30 changes: 15 additions & 15 deletions custom-rule.js → gql-inspector-checker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = (props) => {
const { changes, newSchema, oldSchema } = props;
return changes.map((change) => {
// console.log(change);
const deprecateNotationRegex = /Deprecated since (\d{2}\.\d{2}.\d{1})/;
const addNotationRegex = /Added in (\d{2}\.\d{2}.\d{1})/;
if (
[
"FIELD_DEPRECATION_REASON_ADDED",
Expand All @@ -10,14 +11,13 @@ module.exports = (props) => {
change.criticality.level !== "BREAKING"
) {
const newReason =
change.meta.addedDeprecationReason || change.meta.newDeprecationReason;
const regex = /Deprecated since (\d{2}\.\d{2})/;
if (!newReason.match(regex)) {
change.meta?.addedDeprecationReason ?? change.meta?.newDeprecationReason;
if (newReason && !newReason.match(deprecateNotationRegex)) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'Deprecation reason must include a version number in the format "Deprecated since XX.XX"';
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X."';
change.message =
'Deprecation reason must include a version number in the format "Deprecated since XX.XX", ' +
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X.", ' +
change.message;
}
} else if (
Expand All @@ -28,12 +28,12 @@ module.exports = (props) => {
const description = newSchema.getTypeMap()[typeName].getFields()[
fieldName
].astNode.description?.value;
if (!description || !description.match(/since (\d{2}\.\d{2})/)) {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New fields must include a description with a version number in the format "since XX.XX"';
'New fields must include a description with a version number in the format "Added in XX.XX.X."';
change.message =
'New fields must include a description with a version number in the format "XX.XX", ' +
'New fields must include a description with a version number in the format "Added in XX.XX.X.", ' +
change.message;
}
} else if (
Expand All @@ -43,12 +43,12 @@ module.exports = (props) => {
const typeName = change.path.split(".")[0];
const description =
newSchema.getTypeMap()[typeName].astNode.description?.value;
if (!description || !description.match(/since (\d{2}\.\d{2})/)) {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New types must include a description with a version number in the format "since XX.XX"';
'New types must include a description with a version number in the format "Added in XX.XX.X."';
change.message =
'New types must include a description with a version number in the format "XX.XX", ' +
'New types must include a description with a version number in the format "Added in XX.XX.X.", ' +
change.message;
}
} else if (
Expand All @@ -63,12 +63,12 @@ module.exports = (props) => {
(arg) => arg.name === argumentName
)?.description;

if (!description || !description.match(/since (\d{2}\.\d{2})/)) {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New arguments must include a description with a version number in the format "since XX.XX"';
'New arguments must include a description with a version number in the format "Added in XX.XX.X."';
change.message =
'New arguments must include a description with a version number in the format "XX.XX", ' +
'New arguments must include a description with a version number in the format "Added in XX.XX.X.", ' +
change.message;
}
}
Expand Down

0 comments on commit 02aad90

Please sign in to comment.