Skip to content

Commit 17b5598

Browse files
committed
Add biome and initial format rules
1 parent 33bf18d commit 17b5598

37 files changed

+3111
-976
lines changed

.idea/biome.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/Action.test.ts

+70-77
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Action} from "../src/Action";
2-
import {Artifact} from "../src/Artifact";
3-
import {Inputs} from "../src/Inputs";
4-
import {Releases} from "../src/Releases";
5-
import {ArtifactUploader} from "../src/ArtifactUploader";
6-
import {Outputs} from "../src/Outputs";
7-
import {ArtifactDestroyer} from "../src/ArtifactDestroyer";
8-
import {ActionSkipper} from "../src/ActionSkipper";
1+
import { Action } from "../src/Action"
2+
import { Artifact } from "../src/Artifact"
3+
import { Inputs } from "../src/Inputs"
4+
import { Releases } from "../src/Releases"
5+
import { ArtifactUploader } from "../src/ArtifactUploader"
6+
import { Outputs } from "../src/Outputs"
7+
import { ArtifactDestroyer } from "../src/ArtifactDestroyer"
8+
import { ActionSkipper } from "../src/ActionSkipper"
99

1010
const applyReleaseDataMock = jest.fn()
1111
const artifactDestroyMock = jest.fn()
@@ -18,30 +18,27 @@ const shouldSkipMock = jest.fn()
1818
const updateMock = jest.fn()
1919
const uploadMock = jest.fn()
2020

21-
const artifacts = [
22-
new Artifact('a/art1'),
23-
new Artifact('b/art2')
24-
]
21+
const artifacts = [new Artifact("a/art1"), new Artifact("b/art2")]
2522

26-
const createBody = 'createBody'
23+
const createBody = "createBody"
2724
const createDraft = true
28-
const createName = 'createName'
29-
const commit = 'commit'
30-
const discussionCategory = 'discussionCategory'
25+
const createName = "createName"
26+
const commit = "commit"
27+
const discussionCategory = "discussionCategory"
3128
const generateReleaseNotes = true
3229
const id = 100
3330
const createPrerelease = true
3431
const releaseId = 101
3532
const replacesArtifacts = true
36-
const tag = 'tag'
37-
const token = 'token'
38-
const updateBody = 'updateBody'
33+
const tag = "tag"
34+
const token = "token"
35+
const updateBody = "updateBody"
3936
const updateDraft = false
40-
const updateName = 'updateName'
37+
const updateName = "updateName"
4138
const updatePrerelease = false
4239
const updateOnlyUnreleased = false
43-
const url = 'http://api.example.com'
44-
const makeLatest = 'legacy'
40+
const url = "http://api.example.com"
41+
const makeLatest = "legacy"
4542

4643
describe("Action", () => {
4744
beforeEach(() => {
@@ -53,27 +50,29 @@ describe("Action", () => {
5350
uploadMock.mockClear()
5451
})
5552

56-
it('creates release but does not upload if no artifact', async () => {
53+
it("creates release but does not upload if no artifact", async () => {
5754
const action = createAction(false, false)
5855

5956
await action.perform()
6057

61-
expect(createMock).toBeCalledWith(tag,
58+
expect(createMock).toBeCalledWith(
59+
tag,
6260
createBody,
6361
commit,
6462
discussionCategory,
6563
createDraft,
6664
generateReleaseNotes,
6765
makeLatest,
6866
createName,
69-
createPrerelease)
67+
createPrerelease
68+
)
7069
expect(uploadMock).not.toBeCalled()
7170
assertOutputApplied()
7271
})
7372

74-
it('creates release if no release exists to update', async () => {
73+
it("creates release if no release exists to update", async () => {
7574
const action = createAction(true, true)
76-
const error = {status: 404}
75+
const error = { status: 404 }
7776
getMock.mockRejectedValue(error)
7877

7978
await action.perform()
@@ -87,19 +86,18 @@ describe("Action", () => {
8786
generateReleaseNotes,
8887
makeLatest,
8988
createName,
90-
createPrerelease)
89+
createPrerelease
90+
)
9191
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
9292
assertOutputApplied()
9393
})
9494

95-
it('creates release if no draft releases', async () => {
95+
it("creates release if no draft releases", async () => {
9696
const action = createAction(true, true)
97-
const error = {status: 404}
97+
const error = { status: 404 }
9898
getMock.mockRejectedValue(error)
9999
listMock.mockResolvedValue({
100-
data: [
101-
{id: id, draft: false, tag_name: tag}
102-
]
100+
data: [{ id: id, draft: false, tag_name: tag }],
103101
})
104102

105103
await action.perform()
@@ -117,10 +115,9 @@ describe("Action", () => {
117115
)
118116
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
119117
assertOutputApplied()
120-
121118
})
122119

123-
it('creates release then uploads artifact', async () => {
120+
it("creates release then uploads artifact", async () => {
124121
const action = createAction(false, true)
125122

126123
await action.perform()
@@ -140,7 +137,7 @@ describe("Action", () => {
140137
assertOutputApplied()
141138
})
142139

143-
it('removes all artifacts when artifact destroyer is enabled', async () => {
140+
it("removes all artifacts when artifact destroyer is enabled", async () => {
144141
const action = createAction(false, true, true)
145142

146143
await action.perform()
@@ -149,7 +146,7 @@ describe("Action", () => {
149146
assertOutputApplied()
150147
})
151148

152-
it('removes no artifacts when artifact destroyer is disabled', async () => {
149+
it("removes no artifacts when artifact destroyer is disabled", async () => {
153150
const action = createAction(false, true)
154151

155152
await action.perform()
@@ -158,7 +155,7 @@ describe("Action", () => {
158155
assertOutputApplied()
159156
})
160157

161-
it('skips action', async () => {
158+
it("skips action", async () => {
162159
const action = createAction(false, false, false)
163160
shouldSkipMock.mockResolvedValue(true)
164161

@@ -168,7 +165,7 @@ describe("Action", () => {
168165
expect(updateMock).not.toBeCalled()
169166
})
170167

171-
it('throws error when create fails', async () => {
168+
it("throws error when create fails", async () => {
172169
const action = createAction(false, true)
173170
createMock.mockRejectedValue("error")
174171

@@ -193,14 +190,14 @@ describe("Action", () => {
193190
expect(uploadMock).not.toBeCalled()
194191
})
195192

196-
it('throws error when get fails', async () => {
193+
it("throws error when get fails", async () => {
197194
const action = createAction(true, true)
198195
const error = {
199196
errors: [
200197
{
201-
code: 'already_exists'
202-
}
203-
]
198+
code: "already_exists",
199+
},
200+
],
204201
}
205202

206203
createMock.mockRejectedValue(error)
@@ -215,19 +212,17 @@ describe("Action", () => {
215212
expect(getMock).toBeCalledWith(tag)
216213
expect(updateMock).not.toBeCalled()
217214
expect(uploadMock).not.toBeCalled()
218-
219215
})
220216

221-
it('throws error when list has no data', async () => {
222-
217+
it("throws error when list has no data", async () => {
223218
const action = createAction(true, true)
224-
getMock.mockRejectedValue({status: 404})
219+
getMock.mockRejectedValue({ status: 404 })
225220
const error = {
226221
errors: [
227222
{
228-
code: 'already_exists'
229-
}
230-
]
223+
code: "already_exists",
224+
},
225+
],
231226
}
232227

233228
createMock.mockRejectedValue(error)
@@ -244,7 +239,7 @@ describe("Action", () => {
244239
expect(updateMock).not.toBeCalled()
245240
})
246241

247-
it('throws error when update fails', async () => {
242+
it("throws error when update fails", async () => {
248243
const action = createAction(true, true)
249244

250245
updateMock.mockRejectedValue("error")
@@ -270,9 +265,9 @@ describe("Action", () => {
270265
expect(uploadMock).not.toBeCalled()
271266
})
272267

273-
it('throws error when upload fails', async () => {
268+
it("throws error when upload fails", async () => {
274269
const action = createAction(false, true)
275-
const expectedError = {status: 404}
270+
const expectedError = { status: 404 }
276271
uploadMock.mockRejectedValue(expectedError)
277272

278273
expect.hasAssertions()
@@ -296,15 +291,15 @@ describe("Action", () => {
296291
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
297292
})
298293

299-
it('updates draft release', async () => {
294+
it("updates draft release", async () => {
300295
const action = createAction(true, true)
301-
const error = {status: 404}
296+
const error = { status: 404 }
302297
getMock.mockRejectedValue(error)
303298
listMock.mockResolvedValue({
304299
data: [
305-
{id: 123, draft: false, tag_name: tag},
306-
{id: id, draft: true, tag_name: tag}
307-
]
300+
{ id: 123, draft: false, tag_name: tag },
301+
{ id: id, draft: true, tag_name: tag },
302+
],
308303
})
309304

310305
await action.perform()
@@ -324,7 +319,7 @@ describe("Action", () => {
324319
assertOutputApplied()
325320
})
326321

327-
it('updates release but does not upload if no artifact', async () => {
322+
it("updates release but does not upload if no artifact", async () => {
328323
const action = createAction(true, false)
329324

330325
await action.perform()
@@ -344,7 +339,7 @@ describe("Action", () => {
344339
assertOutputApplied()
345340
})
346341

347-
it('updates release then uploads artifact', async () => {
342+
it("updates release then uploads artifact", async () => {
348343
const action = createAction(true, true)
349344

350345
await action.perform()
@@ -365,12 +360,10 @@ describe("Action", () => {
365360
})
366361

367362
function assertOutputApplied() {
368-
expect(applyReleaseDataMock).toBeCalledWith({id: releaseId, upload_url: url})
363+
expect(applyReleaseDataMock).toBeCalledWith({ id: releaseId, upload_url: url })
369364
}
370365

371-
function createAction(allowUpdates: boolean,
372-
hasArtifact: boolean,
373-
removeArtifacts: boolean = false): Action {
366+
function createAction(allowUpdates: boolean, hasArtifact: boolean, removeArtifacts: boolean = false): Action {
374367
let inputArtifact: Artifact[]
375368
if (hasArtifact) {
376369
inputArtifact = artifacts
@@ -385,30 +378,30 @@ describe("Action", () => {
385378
listArtifactsForRelease: listArtifactsMock,
386379
listReleases: listMock,
387380
update: updateMock,
388-
uploadArtifact: jest.fn()
381+
uploadArtifact: jest.fn(),
389382
}
390383
})
391384

392385
createMock.mockResolvedValue({
393386
data: {
394387
id: releaseId,
395-
upload_url: url
396-
}
388+
upload_url: url,
389+
},
397390
})
398391
getMock.mockResolvedValue({
399392
data: {
400-
id: id
401-
}
393+
id: id,
394+
},
402395
})
403396
listMock.mockResolvedValue({
404-
data: []
397+
data: [],
405398
})
406399
shouldSkipMock.mockResolvedValue(false)
407400
updateMock.mockResolvedValue({
408401
data: {
409402
id: releaseId,
410-
upload_url: url
411-
}
403+
upload_url: url,
404+
},
412405
})
413406
uploadMock.mockResolvedValue({})
414407

@@ -436,28 +429,28 @@ describe("Action", () => {
436429
updatedReleaseBody: updateBody,
437430
updatedReleaseName: updateName,
438431
updatedPrerelease: updatePrerelease,
439-
updateOnlyUnreleased: updateOnlyUnreleased
432+
updateOnlyUnreleased: updateOnlyUnreleased,
440433
}
441434
})
442435
const MockOutputs = jest.fn<Outputs, any>(() => {
443436
return {
444-
applyReleaseData: applyReleaseDataMock
437+
applyReleaseData: applyReleaseDataMock,
445438
}
446439
})
447440
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
448441
return {
449-
uploadArtifacts: uploadMock
442+
uploadArtifacts: uploadMock,
450443
}
451444
})
452445
const MockArtifactDestroyer = jest.fn<ArtifactDestroyer, any>(() => {
453446
return {
454-
destroyArtifacts: artifactDestroyMock
447+
destroyArtifacts: artifactDestroyMock,
455448
}
456449
})
457450

458451
const MockActionSkipper = jest.fn<ActionSkipper, any>(() => {
459452
return {
460-
shouldSkip: shouldSkipMock
453+
shouldSkip: shouldSkipMock,
461454
}
462455
})
463456

0 commit comments

Comments
 (0)