|
| 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()) |
0 commit comments