Skip to content

Commit

Permalink
feat(heroku)!: remove systemCode option
Browse files Browse the repository at this point in the history
This was only needed for setting the SYSTEM_CODE environment variable in
Heroku config. Doppler projects handle that instead now.
  • Loading branch information
ivomurrell committed Sep 2, 2024
1 parent 92de8fd commit 4e6b931
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 31 deletions.
1 change: 0 additions & 1 deletion core/cli/test/files/conflict-resolution/.toolkitrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ options:
plugins:
'@dotcom-tool-kit/heroku':
pipeline: tool-kit-test
systemCode: tool-kit-test
'@dotcom-tool-kit/doppler':
project: tool-kit-test
tasks:
Expand Down
1 change: 0 additions & 1 deletion core/cli/test/files/duplicate/.toolkitrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ options:
plugins:
'@dotcom-tool-kit/heroku':
pipeline: tool-kit-test
systemCode: tool-kit-test

'@dotcom-tool-kit/doppler':
project: tool-kit-test
Expand Down
8 changes: 1 addition & 7 deletions lib/schemas/src/plugins/heroku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ export const HerokuSchema = z.object({
.string()
.describe(
"the ID of your app's Heroku pipeline. this can be found at https://dashboard.heroku.com/pipelines/[PIPELINE_ID]"
),
systemCode: z
.string()
.describe(
"your app's Biz Ops system code. this can be found at https://biz-ops.in.ft.com/System/[SYSTEM_CODE]"
)
})

export type HerokuOptions = z.infer<typeof HerokuSchema>

export const Schema = HerokuSchema
export const generators: PromptGenerators<typeof HerokuSchema> = {
pipeline: async (logger, prompt, onCancel, bizOpsSystem) => bizOpsSystem?.herokuApps[0]?.pipelineName,
systemCode: async (logger, prompt, onCancel, bizOpsSystem) => bizOpsSystem?.code
pipeline: async (logger, prompt, onCancel, bizOpsSystem) => bizOpsSystem?.herokuApps[0]?.pipelineName
}
7 changes: 3 additions & 4 deletions plugins/heroku/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ Scale down the Heroku staging app once it's no longer needed.

### `@dotcom-tool-kit/heroku`

| Property | Description | Type |
| :-------------------- | :-------------------------------------------------------------------------------------------------------------- | :------- |
| **`pipeline`** (\*) | the ID of your app's Heroku pipeline. this can be found at https://dashboard.heroku.com/pipelines/[PIPELINE_ID] | `string` |
| **`systemCode`** (\*) | your app's Biz Ops system code. this can be found at https://biz-ops.in.ft.com/System/[SYSTEM_CODE] | `string` |
| Property | Description | Type |
| :------------------ | :-------------------------------------------------------------------------------------------------------------- | :------- |
| **`pipeline`** (\*) | the ID of your app's Heroku pipeline. this can be found at https://dashboard.heroku.com/pipelines/[PIPELINE_ID] | `string` |

_(\*) Required._
<!-- end autogenerated docs -->
3 changes: 1 addition & 2 deletions plugins/heroku/test/tasks/production.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const mockPromoteStagingToProduction = jest.spyOn(utils, 'promoteStagingToProduc
jest.spyOn(Production.prototype, 'fetchIfAppHasDeployed').mockImplementation(() => Promise.resolve(true))

const pluginOptions = {
pipeline: 'next-health',
systemCode: 'next-health'
pipeline: 'next-health'
}

const productionOptions = {
Expand Down
14 changes: 7 additions & 7 deletions plugins/heroku/test/tasks/review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('../../src/gtg', () => {

describe('review', () => {
it('should call pass in the pipeline id to heroku api call', async () => {
const task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
const task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

await task.run()

Expand All @@ -62,7 +62,7 @@ describe('review', () => {
})

it('should return review app id from get heroku review app', async () => {
const task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
const task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

await task.run()

Expand All @@ -71,15 +71,15 @@ describe('review', () => {
})

it('should fail if either doppler option is missing', async () => {
let task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
let task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

try {
await task.run()
} catch (err) {
expect(err).toBeTruthy()
}

task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

try {
await task.run()
Expand All @@ -89,15 +89,15 @@ describe('review', () => {
})

it('should write app id to state', async () => {
const task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
const task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

await task.run()

expect(state.review).toEqual(appId)
})

it('should call gtg with appName', async () => {
const task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
const task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

await task.run()

Expand All @@ -106,7 +106,7 @@ describe('review', () => {

it('should throw an error if it fails', async () => {
pipeline = 'wrong-pipeline-name'
const task = new Review(logger, 'HerokuReview', { pipeline, systemCode: '' }, { scaling: {} })
const task = new Review(logger, 'HerokuReview', { pipeline }, { scaling: {} })

try {
await task.run()
Expand Down
17 changes: 8 additions & 9 deletions plugins/heroku/test/tasks/staging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const logger = winston as unknown as Logger

const pipeline = 'test-pipeline'
const appName = 'test-appName'
const systemCode = 'test-systemCode'
const buildInfo = {
id: 'build-id',
slug: null,
Expand Down Expand Up @@ -69,7 +68,7 @@ describe('staging', () => {
})

it('should call pipeline couplings with pipeline option', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await task.run()

Expand All @@ -78,7 +77,7 @@ describe('staging', () => {
})

it('should return appName from get heroku staging', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await task.run()

Expand All @@ -87,45 +86,45 @@ describe('staging', () => {
})

it('should call createBuild with app name', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await task.run()

expect(createBuild).toBeCalledWith(expect.anything(), appName)
})

it(`should call repeatedCheckForBuildSuccess if the slug id isn't present`, async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })
await task.run()

expect(repeatedCheckForBuildSuccess).toBeCalledWith(expect.anything(), appName, buildInfo.id)
})

it('should call setStagingSlug with app name and slug id', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })
await task.run()

expect(setStagingSlug).toBeCalledWith(expect.anything(), appName, slugId)
})

it('should call scaleDyno', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await task.run()

expect(scaleDyno).toBeCalledTimes(1)
})

it('should call gtg with appName', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await task.run()

expect(gtg).toBeCalledWith(expect.anything(), appName, 'staging')
})

it('should resolve successfully when complete', async () => {
const task = new Staging(logger, 'HerokuStaging', { pipeline, systemCode }, { scaling: {} })
const task = new Staging(logger, 'HerokuStaging', { pipeline }, { scaling: {} })

await expect(task.run()).resolves.not.toThrow()
})
Expand Down

0 comments on commit 4e6b931

Please sign in to comment.