Skip to content

Commit

Permalink
Ensures that the Gitlab API is exposed properly through the dts
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jun 30, 2021
1 parent 0e094bb commit e8d2052
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1

# Get local dependencies
# Get local dependencies & test
- run: yarn install
- run: yarn build
- run: yarn test

# Validate related tooling
- run: yarn declarations
- run: yarn tsc distribution/danger.d.ts
- run: rm -rf node_modules/@types/babel-*
- run: rm -rf node_modules/@types/babylon
- run: echo "Testing Flow definition file"
- run: yarn build:flow-types
- run: yarn flow check


- run: 'echo "This is only for Integration tests on two blank projects"'

Expand Down
1 change: 1 addition & 0 deletions scripts/danger-dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createDTS = () => {
//
import { Octokit as GitHub } from "@octokit/rest"
import { Gitlab } from "gitlab"
`
const footer = ``
Expand Down
3 changes: 2 additions & 1 deletion source/danger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import { Octokit as GitHub } from "@octokit/rest"
import { Gitlab } from "gitlab"

type MarkdownString = string
// TODO: extract out from BitBucket specifically, or create our own type
Expand Down Expand Up @@ -1455,7 +1456,7 @@ interface GitLabDSL extends GitLabJSONDSL {
utils: {
fileContents(path: string, repoSlug?: string, ref?: string): Promise<string>
}
api: GitLabAPI
api: InstanceType<typeof Gitlab>
}

// ---
Expand Down
4 changes: 2 additions & 2 deletions source/dsl/GitLabDSL.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Please don't have includes in here that aren't inside the DSL folder, or the d.ts/flow defs break

// TODO: extract out from BitBucket specifically, or create our own type
import GitLabAPI from "../platforms/gitlab/GitLabAPI"
import { Gitlab } from "gitlab"
import { RepoMetaData } from "./BitBucketServerDSL"

// getPlatformReviewDSLRepresentation
Expand All @@ -22,7 +22,7 @@ export interface GitLabDSL extends GitLabJSONDSL {
utils: {
fileContents(path: string, repoSlug?: string, ref?: string): Promise<string>
}
api: GitLabAPI
api: InstanceType<typeof Gitlab>
}

// ---
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/GitLab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@ export const gitlabJSONToGitLabDSL = (gl: GitLabDSL, api: GitLabAPI): GitLabDSL
utils: {
fileContents: api.getFileContents,
},
api,
api: api.apiInstance,
})
4 changes: 4 additions & 0 deletions source/platforms/gitlab/GitLabAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class GitLabAPI {
return `${this.projectURL}/merge_requests/${this.repoMetadata.pullRequestID}`
}

get apiInstance() {
return this.api
}

getUser = async (): Promise<GitLabUserProfile> => {
this.d("getUser")
const user = (await this.api.Users.current()) as GitLabUserProfile
Expand Down

0 comments on commit e8d2052

Please sign in to comment.