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

chore(fdr): add tags and PR links to releases data model #1489

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
36 changes: 29 additions & 7 deletions fern/apis/fdr/definition/generators/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,41 @@ imports:
commons: ./commons.yml

types:
CliReleaseRequest:
extends: commons.ReleaseRequest
CliReleaseTagEnum:
enum:
- name: fern_definition
value: "Fern Definition"
- name: openapi
value: "OpenAPI"
- name: asyncapi
value: "AsyncAPI"
- name: grpc
value: "gRPC"
Copy link
Member

Choose a reason for hiding this comment

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

do you think there's any benefit of structuring here? my guess is string is fine and if we want to structure we just put all of that onus on the client (seed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, updated


CliReleaseTag:
discriminated: false
union:
- string
- CliReleaseTagEnum

BaseCliRelease:
properties:
irVersion:
type: integer
docs: The major version of the IR that this CLI exposes.
tags:
type: optional<list<CliReleaseTag>>
docs: Tags to categorize the CLI release.

CliReleaseRequest:
extends:
- commons.ReleaseRequest
- BaseCliRelease

CliRelease:
extends: commons.Release
properties:
irVersion:
type: integer
docs: The major version of the IR that this CLI exposes.
extends:
- commons.Release
- BaseCliRelease

ListCliReleasesResponse:
properties:
Expand Down
7 changes: 6 additions & 1 deletion fern/apis/fdr/definition/generators/commons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ types:
properties:
type: ChangelogEntryType
summary: string
pullRequestUrl:
type: optional<string>
docs: |
The URL to the pull request that introduced this change. This is optional for backcompat.
You do not always need to specify the URL as the CLI can fill it in with the current PR, but given you can choose to not
release within the same PR as the change is introduced, this should be specified for divorcing the two.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to links

upgradeNotes: optional<string>

# Keep a Changelog
added: optional<list<string>>
changed: optional<list<string>>
Expand Down
26 changes: 12 additions & 14 deletions fern/apis/fdr/definition/generators/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ imports:
root: ./__package__.yml

types:
GeneratorReleaseRequest:
extends: commons.ReleaseRequest
BaseGeneratorRelease:
properties:
generatorId: root.GeneratorId
irVersion:
Expand All @@ -20,20 +19,19 @@ types:
customConfigSchema:
type: optional<string>
docs: The JSON schema (stringified) for the custom config that this generator version supports.
tags:
type: optional<list<string>>
docs: Tags to categorize the Generator release.
armandobelardo marked this conversation as resolved.
Show resolved Hide resolved

GeneratorReleaseRequest:
extends:
- commons.ReleaseRequest
- BaseGeneratorRelease

GeneratorRelease:
extends: commons.Release
properties:
generatorId: root.GeneratorId
irVersion:
type: integer
docs: The major version of the IR that this generator version consumes.
migration:
type: optional<string>
docs: The TypeScript file for the migration to run when upgrading to this version.
customConfigSchema:
type: optional<string>
docs: The JSON schema (stringified) for the custom config that this generator version supports.
extends:
- commons.Release
- BaseGeneratorRelease

ListGeneratorReleasesResponse:
properties:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "CliRelease" ADD COLUMN "tags" TEXT[] DEFAULT ARRAY[]::TEXT[];

-- AlterTable
ALTER TABLE "GeneratorRelease" ADD COLUMN "tags" TEXT[] DEFAULT ARRAY[]::TEXT[];
2 changes: 2 additions & 0 deletions servers/fdr/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ model GeneratorRelease {
customConfigSchema String?

releaseType ReleaseType
tags String[] @default([])

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand All @@ -222,6 +223,7 @@ model CliRelease {
changelogEntry Bytes?

releaseType ReleaseType
tags String[] @default([])

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down
25 changes: 25 additions & 0 deletions servers/fdr/src/__test__/local/db/cliVersionsDao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@ it("cli verion not semver", async () => {
}).rejects.toThrow(new InvalidVersionError({ providedVersion: "abc.1.2" }));
});

it("cli release with tags and URLs", async () => {
const release: CliReleaseRequest = {
version: "0.1.2-rc13",
irVersion: 0,
tags: ["OpenAPI", "Fern Definition"],
changelogEntry: [
{
type: "feat",
summary: "added a new feature",
added: ["added a new feature"],
pullRequestUrl: "https://123.com",
},
],
};

await fdrApplication.dao.cliVersions().upsertCliRelease({
cliRelease: release,
});

const dbRelease = await fdrApplication.dao.cliVersions().getCliRelease({ cliVersion: "0.1.2-rc13" });
expect(dbRelease).not.toBeUndefined();
expect(dbRelease?.tags).toEqual(release.tags);
expect(dbRelease?.changelogEntry?.[0]?.pullRequestUrl).toEqual(release.changelogEntry?.[0]?.pullRequestUrl);
});

it("cli version get latest respects semver, not time", async () => {
// create some versions and sleep between them to ensure the timestamps are different
await fdrApplication.dao.cliVersions().upsertCliRelease({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading