Skip to content

Commit

Permalink
refactor: небольшой рефакторинг имен и структуры
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Jun 4, 2024
1 parent 9faf31d commit ec57020
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 225 deletions.
8 changes: 4 additions & 4 deletions __tests__/github.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { debug } from 'console'
import { config } from 'dotenv'

import { GithubMerge } from '../src/github'
import { GithubReview } from '../src/github'

describe('github', () => {
config()
Expand All @@ -21,15 +21,15 @@ describe('github', () => {
// })

it('getQualityDiscussion', async () => {

Check warning on line 23 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 23 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
const githubMR = new GithubMerge({
const githubMR = new GithubReview({
pull_number: 9,
token: token,

Check failure on line 26 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 26 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
repo: repo

Check failure on line 27 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 27 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
})
debug(await githubMR.getQualityDiscussion())
})
it('getReviews', async () => {

Check warning on line 31 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 31 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
const githubMR = new GithubMerge({
const githubMR = new GithubReview({
pull_number: 9,
token: token,

Check failure on line 34 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 34 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
repo: repo

Check failure on line 35 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 35 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
Expand All @@ -38,7 +38,7 @@ describe('github', () => {
})

it('getReviewComments', async () => {

Check warning on line 40 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 40 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
const githubMR = new GithubMerge({
const githubMR = new GithubReview({
pull_number: 9,
token: token,

Check failure on line 43 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 43 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
repo: repo

Check failure on line 44 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 44 in __tests__/github.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
Expand Down
12 changes: 6 additions & 6 deletions __tests__/publisher.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { config } from 'dotenv'

import { Publisher } from '../src/publisher'
import { ReviewPublisher } from '../src/publisher/review'
import { Sonar } from '../src/sonar'
import { GithubMerge } from '../src/github'
import { GithubReview } from '../src/github'

describe('main.ts', () => {
config()
Expand All @@ -19,12 +19,12 @@ describe('main.ts', () => {
branchPluginEnabled: true,
pull_number: 370
})
const github = new GithubMerge({
const github = new GithubReview({
repo: repo,

Check failure on line 23 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 23 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
pull_number: 9,
token: token

Check failure on line 25 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 25 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
})
const publisher = new Publisher(sonar, github)
const publisher = new ReviewPublisher(sonar, github)
await publisher.generateReport()
})
it('publishIssues', async () => {

Check warning on line 30 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 30 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
Expand All @@ -34,12 +34,12 @@ describe('main.ts', () => {
branchPluginEnabled: true,
pull_number: 370
})
const github = new GithubMerge({
const github = new GithubReview({
repo: repo,

Check failure on line 38 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 38 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
pull_number: 370,
token: token

Check failure on line 40 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 40 in __tests__/publisher.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Expected property shorthand
})
const publisher = new Publisher(sonar, github)
const publisher = new ReviewPublisher(sonar, github)
const status = {
projectStatus: {
status: 'UNKNOWN',
Expand Down
113 changes: 68 additions & 45 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/github/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type ReviewComments =
Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/comments']['response']['data']
export type ReviewComment = ReviewComments[0]

export class GithubMerge {
export class GithubReview {
pull_number: number
octokit: InstanceType<typeof GitHub>
repo: Repo
Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as core from '@actions/core'
import { Sonar } from './sonar'
import { SonarProperties } from './sonar/properties'
import { GithubMerge } from './github'
import { GithubReview } from './github'
import githubAutoConfig from './github/autoconfig'
import { Repo } from './model/entity'
import { Publisher } from './publisher'
import * as PublisherFactory from './publisher'

/**
* The main function for the action.
Expand Down Expand Up @@ -47,7 +47,7 @@ interface Args {
}

export async function generateReport(args: Args) {
const github = new GithubMerge({
const github = new GithubReview({
token: args.githubToken,
pull_number: args.mergeID,
repo: args.repo
Expand All @@ -61,6 +61,6 @@ export async function generateReport(args: Args) {
pull_number: args.mergeID
})

const publisher = new Publisher(sonar, github)
const publisher = PublisherFactory.create(sonar, github)
await publisher.generateReport()
}
10 changes: 10 additions & 0 deletions src/model/entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import * as entity from 'src/sonar/entity'

export interface Repo {
owner: string
repo: string
}

export interface Publisher {
generateReport(): Promise<boolean>
publishIssues(
quality: entity.Qualitygate,
issues: entity.Issue[]
): Promise<boolean>
}
Loading

0 comments on commit ec57020

Please sign in to comment.