summaryrefslogtreecommitdiff
path: root/.ci/ci.ts
blob: 79084625cc0387ab57041c77e24790caeeb42b6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node

import { BuildDockerImageJob, DefaultGitHookPipelineBuilder } from "@emprespresso/ci_model";

const REGISTRY = "img.liz.coffee";
const NAMESPACE = "emprespresso";
const IMG = "rookery";

/**
 * Every push: build the Dockerfile's `rookery` target, which runs the whole test suite
 * (`gradlew check`) and packages the desktop app. A failing test fails the image build.
 */
const getPipeline = () => {
  const gitHookPipeline = new DefaultGitHookPipelineBuilder();
  const branch = gitHookPipeline.getBranch();
  if (!branch) return gitHookPipeline.build();

  const build: BuildDockerImageJob = {
    type: "build_docker_image.js",
    arguments: {
      context: gitHookPipeline.getSourceDestination(),
      registry: REGISTRY,
      namespace: NAMESPACE,
      repository: IMG,
      imageTag: branch,
      commit: gitHookPipeline.getRev(),
      buildTarget: IMG,
      dockerfile: "Dockerfile",
    },
  };
  gitHookPipeline.addStage({ parallelJobs: [build] });

  return gitHookPipeline.build();
};

const main = () => {
  const data = getPipeline().serialize();
  process.stdout.write(data);
};

main();