Skip to content

Commit

Permalink
Merge pull request #49 from justinlampley/AddPullRequestAsFirmwareSou…
Browse files Browse the repository at this point in the history
…rceOption

Add Pull Request as a firmware source options
  • Loading branch information
jurgelenas authored Aug 24, 2021
2 parents b10ee00 + c262da0 commit 0cfa97d
Show file tree
Hide file tree
Showing 14 changed files with 523 additions and 15 deletions.
224 changes: 214 additions & 10 deletions graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@
"defaultValue": "\"\"",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "gitPullRequest",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
"name": "PullRequestInput",
"ofType": null
},
"defaultValue": "null",
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
Expand Down Expand Up @@ -208,6 +220,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pullRequests",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PullRequestType",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "checkForUpdates",
"description": null,
Expand Down Expand Up @@ -1220,8 +1256,99 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "GitPullRequest",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "PullRequestInput",
"description": null,
"fields": null,
"inputFields": [
{
"name": "title",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "number",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "headCommitHash",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
Expand Down Expand Up @@ -1267,6 +1394,81 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PullRequestType",
"description": null,
"fields": [
{
"name": "title",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "number",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "headCommitHash",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "UpdatesAvailability",
Expand Down Expand Up @@ -1795,6 +1997,18 @@
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "gitPullRequest",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
"name": "PullRequestInput",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"interfaces": null,
Expand Down Expand Up @@ -2055,16 +2269,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "SerialPortDisconnectResult",
Expand Down
5 changes: 5 additions & 0 deletions src/api/src/graphql/args/FirmwareVersionDataInput.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ArgsType, Field } from 'type-graphql';
import FirmwareSource from '../../models/enum/FirmwareSource';
import DeviceTarget from '../../library/FirmwareBuilder/Enum/DeviceTarget';
import PullRequest from '../../models/PullRequest';

@ArgsType()
export default class TargetDeviceOptionsArgs {
Expand All @@ -22,12 +23,16 @@ export default class TargetDeviceOptionsArgs {
@Field()
localPath: string;

@Field(() => PullRequest)
gitPullRequest: PullRequest | null;

constructor() {
this.source = FirmwareSource.GitBranch;
this.target = DeviceTarget.DIY_2400_TX_ESP32_SX1280_E28_via_UART;
this.gitTag = '';
this.gitBranch = '';
this.gitCommit = '';
this.localPath = '';
this.gitPullRequest = null;
}
}
5 changes: 5 additions & 0 deletions src/api/src/graphql/inputs/FirmwareVersionDataInput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Field, InputType } from 'type-graphql';
import FirmwareSource from '../../models/enum/FirmwareSource';
import PullRequest from '../../models/PullRequest';

@InputType('FirmwareVersionDataInput')
export default class FirmwareVersionDataInput {
Expand All @@ -18,11 +19,15 @@ export default class FirmwareVersionDataInput {
@Field()
localPath: string;

@Field(() => PullRequest)
gitPullRequest: PullRequest | null;

constructor() {
this.source = FirmwareSource.GitBranch;
this.gitTag = '';
this.gitBranch = '';
this.gitCommit = '';
this.localPath = '';
this.gitPullRequest = null;
}
}
9 changes: 9 additions & 0 deletions src/api/src/graphql/resolvers/Sources.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Inject, Service } from 'typedi';
import OctopusGitHubClient from '../../services/GitHubClient';
import { ConfigToken, IConfig } from '../../config';
import Release from '../../models/Release';
import PullRequest from '../../models/PullRequest';

@Service()
@Resolver()
Expand Down Expand Up @@ -35,4 +36,12 @@ export default class SourcesResolver {
this.config.git.repositoryName
);
}

@Query(() => [PullRequest])
async pullRequests() {
return this.gitClient.loadPullRequests(
this.config.git.owner,
this.config.git.repositoryName
);
}
}
29 changes: 29 additions & 0 deletions src/api/src/models/PullRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Field, InputType, ObjectType } from 'type-graphql';

@InputType('PullRequestInput')
@ObjectType('PullRequestType')
export default class PullRequest {
@Field()
title: string;

@Field()
id: number;

@Field()
number: number;

@Field()
headCommitHash: string;

constructor(
title: string,
id: number,
number: number,
headCommitHash: string
) {
this.title = title;
this.id = id;
this.number = number;
this.headCommitHash = headCommitHash;
}
}
1 change: 1 addition & 0 deletions src/api/src/models/enum/FirmwareSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum FirmwareSource {
GitBranch = 'GitBranch',
GitCommit = 'GitCommit',
Local = 'Local',
GitPullRequest = 'GitPullRequest',
}

registerEnumType(FirmwareSource, {
Expand Down
Loading

0 comments on commit 0cfa97d

Please sign in to comment.