Skip to content

Commit d9b917b

Browse files
author
Zack Chase
authored
Move to TS for pipeline definition (#115)
1 parent acb0f82 commit d9b917b

File tree

8 files changed

+411
-10
lines changed

8 files changed

+411
-10
lines changed

apps/ci/eslint.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const baseConfig = require('../../eslint.config.cjs');
2+
3+
module.exports = [...baseConfig];

apps/ci/project.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"name": "ci",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/ci/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"install": {
9+
"executor": "nx:run-commands",
10+
"options": {
11+
"commands": [],
12+
"cwd": "apps/ci"
13+
}
14+
},
15+
"clean": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"commands": []
19+
},
20+
"cache": false
21+
},
22+
"build:pipeline": {
23+
"executor": "@nx/esbuild:esbuild",
24+
"outputs": ["{options.outputPath}"],
25+
"defaultConfiguration": "production",
26+
"options": {
27+
"platform": "node",
28+
"outputPath": "dist/apps/ci",
29+
"format": ["cjs"],
30+
"bundle": false,
31+
"main": "apps/ci/src/pipeline.ts",
32+
"tsConfig": "apps/ci/tsconfig.app.json",
33+
"assets": ["apps/ci/src/assets"],
34+
"generatePackageJson": true,
35+
"esbuildOptions": {
36+
"sourcemap": true,
37+
"outExtension": {
38+
".js": ".js"
39+
}
40+
}
41+
},
42+
"configurations": {
43+
"development": {},
44+
"production": {
45+
"esbuildOptions": {
46+
"sourcemap": false,
47+
"outExtension": {
48+
".js": ".js"
49+
}
50+
}
51+
}
52+
}
53+
},
54+
"build:release-pipeline": {
55+
"executor": "@nx/esbuild:esbuild",
56+
"outputs": ["{options.outputPath}"],
57+
"defaultConfiguration": "production",
58+
"options": {
59+
"platform": "node",
60+
"outputPath": "dist/apps/ci",
61+
"format": ["cjs"],
62+
"bundle": false,
63+
"main": "apps/ci/src/release.ts",
64+
"tsConfig": "apps/ci/tsconfig.app.json",
65+
"assets": ["apps/ci/src/assets"],
66+
"generatePackageJson": true,
67+
"esbuildOptions": {
68+
"sourcemap": true,
69+
"outExtension": {
70+
".js": ".js"
71+
}
72+
}
73+
},
74+
"configurations": {
75+
"development": {},
76+
"production": {
77+
"esbuildOptions": {
78+
"sourcemap": false,
79+
"outExtension": {
80+
".js": ".js"
81+
}
82+
}
83+
}
84+
}
85+
},
86+
"run:pipeline": {
87+
"executor": "@nx/js:node",
88+
"defaultConfiguration": "development",
89+
"dependsOn": ["build"],
90+
"options": {
91+
"buildTarget": "ci:build:pipeline",
92+
"runBuildTargetDependencies": false,
93+
"watch": false
94+
}
95+
},
96+
"run:release-pipeline": {
97+
"executor": "@nx/js:node",
98+
"defaultConfiguration": "development",
99+
"dependsOn": ["build"],
100+
"options": {
101+
"buildTarget": "ci:build:release-pipeline",
102+
"runBuildTargetDependencies": false,
103+
"watch": false
104+
}
105+
},
106+
"test": {
107+
"options": {
108+
"passWithNoTests": true
109+
}
110+
}
111+
}
112+
}

apps/ci/src/pipeline.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { Pipeline } from "@buildkite/buildkite-sdk"
2+
import * as fs from "fs"
3+
4+
const pipeline = new Pipeline()
5+
const plugins = [
6+
{ "docker#v5.11.0": { image: "buildkite-sdk-tools:latest" } },
7+
]
8+
9+
pipeline.addStep({
10+
key: "install",
11+
label: ":test_tube: Install",
12+
plugins: [
13+
...plugins,
14+
{ "artifacts#v1.9.2": {
15+
upload: ["node_modules"],
16+
compressed: "node_modules.tgz"
17+
}},
18+
],
19+
commands: [
20+
"mise trust",
21+
"npm install --ignore-scripts",
22+
],
23+
})
24+
25+
const languagePlugins = [
26+
...plugins,
27+
{ "artifacts#v1.9.2": {
28+
download: ["node_modules"],
29+
compressed: "node_modules.tgz"
30+
}}
31+
]
32+
33+
const languageTargets = [
34+
{
35+
icon: ":typescript:",
36+
label: "Typescript",
37+
key: "typescript",
38+
sdkLabel: "sdk-typescript",
39+
appLabel: "app-typescript"
40+
},
41+
{
42+
icon: ":python:",
43+
label: "Python",
44+
key: "python",
45+
sdkLabel: "sdk-python",
46+
appLabel: "app-python"
47+
},
48+
{
49+
icon: ":go:",
50+
label: "Go",
51+
key: "go",
52+
sdkLabel: "sdk-go",
53+
appLabel: "app-go"
54+
},
55+
{
56+
icon: ":ruby:",
57+
label: "Ruby",
58+
key: "ruby",
59+
sdkLabel: "sdk-ruby",
60+
appLabel: "app-ruby"
61+
}
62+
]
63+
64+
languageTargets.forEach((target) => {
65+
pipeline.addStep({
66+
depends_on: ["install"],
67+
key: `${target.key}`,
68+
group: `${target.icon} ${target.label}`,
69+
steps: [
70+
{
71+
key: `${target.key}-diff`,
72+
label: ":git: Diff",
73+
plugins: languagePlugins,
74+
commands: [
75+
"mise trust",
76+
`nx install ${target.sdkLabel}`,
77+
"nx gen:build",
78+
`nx gen:types-${target.key}`,
79+
"exit $(git diff --exit-code)",
80+
],
81+
},
82+
{
83+
key: `${target.key}-test`,
84+
label: ":test_tube: Test",
85+
plugins: languagePlugins,
86+
commands: [
87+
"mise trust",
88+
`nx install ${target.sdkLabel}`,
89+
`nx test ${target.sdkLabel}`,
90+
],
91+
},
92+
{
93+
key: `${target.key}-build`,
94+
label: ":package: Build",
95+
plugins: languagePlugins,
96+
commands: [
97+
"mise trust",
98+
`nx install ${target.sdkLabel}`,
99+
`nx build ${target.sdkLabel}`
100+
],
101+
},
102+
{
103+
key: `${target.key}-docs`,
104+
label: ":books: Docs",
105+
depends_on: [`${target.key}-test`,`${target.key}-build`],
106+
plugins: languagePlugins,
107+
commands: [
108+
"mise trust",
109+
`nx install ${target.sdkLabel}`,
110+
`nx run ${target.sdkLabel}:docs:build`
111+
],
112+
},
113+
{
114+
label: ":lab_coat: Apps",
115+
key: `${target.key}-apps`,
116+
depends_on: [`${target.key}-test`,`${target.key}-build`],
117+
plugins: languagePlugins,
118+
commands: [
119+
"mise trust",
120+
`nx install ${target.appLabel}`,
121+
`nx run ${target.appLabel}:run`
122+
],
123+
},
124+
]
125+
})
126+
})
127+
128+
fs.writeFileSync(".buildkite/pipeline.json", pipeline.toJSON())

apps/ci/src/release.ts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import { Pipeline } from "@buildkite/buildkite-sdk"
2+
import * as fs from "fs"
3+
4+
const pipeline = new Pipeline()
5+
6+
const plugins = [
7+
{ "docker#v5.11.0": {
8+
image: "buildkite-sdk-tools:latest",
9+
"propagate-environment": true,
10+
environment: [
11+
"GITHUB_TOKEN",
12+
"NPM_TOKEN",
13+
"PYPI_TOKEN",
14+
"GEM_HOST_API_KEY"
15+
]
16+
}},
17+
{ "rubygems-oidc#v0.2.0": { role: "rg_oidc_akr_emf87k6zphtb7x7adyrk" } },
18+
{ "aws-assume-role-with-web-identity#v1.0.0": {
19+
"role-arn": "arn:aws:iam::597088016345:role/marketing-website-production-pipeline-role"
20+
}},
21+
{ "aws-ssm#v1.0.0": {
22+
parameters: {
23+
NPM_TOKEN: "/prod/buildkite-sdk/npm-token",
24+
PYPI_TOKEN: "/prod/buildkite-sdk/pypi-token",
25+
GITHUB_TOKEN: "/prod/buildkite-sdk/github-token"
26+
}
27+
}}
28+
]
29+
30+
pipeline.addStep({
31+
key: "install",
32+
label: ":test_tube: Install",
33+
plugins: [
34+
...plugins,
35+
{ "artifacts#v1.9.2": {
36+
upload: ["node_modules"],
37+
compressed: "node_modules.tgz"
38+
}}
39+
],
40+
commands: [
41+
"mise trust",
42+
"npm install --ignore-scripts"
43+
]
44+
})
45+
46+
const languagePlugins = [
47+
...plugins,
48+
{ "artifacts#v1.9.2": {
49+
download: ["node_modules"],
50+
compressed: "node_modules.tgz"
51+
}}
52+
]
53+
54+
const languageTargets = [
55+
{
56+
icon: ":typescript:",
57+
label: "Typescript",
58+
key: "typescript",
59+
sdkLabel: "sdk-typescript",
60+
appLabel: "app-typescript"
61+
},
62+
{
63+
icon: ":python:",
64+
label: "Python",
65+
key: "python",
66+
sdkLabel: "sdk-python",
67+
appLabel: "app-python"
68+
},
69+
{
70+
icon: ":go:",
71+
label: "Go",
72+
key: "go",
73+
sdkLabel: "sdk-go",
74+
appLabel: "app-go"
75+
},
76+
{
77+
icon: ":ruby:",
78+
label: "Ruby",
79+
key: "ruby",
80+
sdkLabel: "sdk-ruby",
81+
appLabel: "app-ruby"
82+
}
83+
]
84+
85+
languageTargets.forEach((target) => {
86+
pipeline.addStep({
87+
depends_on: "install",
88+
key: `${target.key}`,
89+
group: `${target.icon} ${target.label}`,
90+
steps: [
91+
{
92+
key: `${target.key}-test`,
93+
label: ":test_tube: Test",
94+
plugins: languagePlugins,
95+
commands: [
96+
"mise trust",
97+
`nx install ${target.sdkLabel}`,
98+
`nx test ${target.sdkLabel}`
99+
],
100+
},
101+
{
102+
key: `${target.key}-publish`,
103+
label: ":rocket: Publish",
104+
depends_on: [`${target.key}-test`],
105+
plugins: languagePlugins,
106+
commands: [
107+
"mise trust",
108+
`nx install ${target.sdkLabel}`,
109+
`nx build ${target.sdkLabel}`,
110+
`nx run ${target.sdkLabel}:publish`
111+
],
112+
},
113+
]
114+
})
115+
})
116+
117+
fs.writeFileSync(".buildkite/pipeline.json", pipeline.toJSON())

apps/ci/tsconfig.app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}

apps/ci/tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.app.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
],
13+
"compilerOptions": {
14+
"esModuleInterop": true
15+
}
16+
}

0 commit comments

Comments
 (0)