Skip to content

Commit

Permalink
feat(recipe-auto-pipeline): expect local compilation if docker tag is…
Browse files Browse the repository at this point in the history
…n't supplied
  • Loading branch information
DecentM committed Jul 25, 2024
1 parent 962d026 commit 23a1c58
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .ci/pipeline/concourse-ts.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated with concourse-ts at 00:13:06 on 26/07/2024
# Generated with concourse-ts at 01:30:59 on 26/07/2024
#
# jobs: 1
# groups: 0
Expand All @@ -7,14 +7,14 @@
# var_sources: 0

jobs:
- name: ci
- name: auto-pipeline
plan:
- attempts: 3
timeout: 1h
get: git-ci
trigger: true
- timeout: 6h
set_pipeline: self
set_pipeline: concourse-ts
file: git-ci/.ci/pipeline/concourse-ts.yml
max_in_flight: 1
display:
Expand Down
22 changes: 9 additions & 13 deletions ci/pipeline/concourse-ts.pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import '../configure.js'

import * as ConcourseTs from '@decentm/concourse-ts'
import { create_auto_pipeline } from '@decentm/concourse-ts-recipe-auto-pipeline'

import { git_ci } from '../resources/git'
import { CliGroup } from './groups/cli'

type Group = 'ci' | CliGroup

const name = 'concourse-ts'

const auto_pipeline = create_auto_pipeline<Group>({
resource: git_ci,
path: `.ci/pipeline/${name}.yml`,
})

export default () => {
return new ConcourseTs.Pipeline<Group>('concourse-ts', (pipeline) => {
pipeline.add_job(
new ConcourseTs.Job('ci', (job) => {
job.add_step(git_ci.as_get_step())
job.add_step(
new ConcourseTs.SetPipelineStep('set-pipeline', (step) => {
step.file = `${git_ci.name}/.ci/pipeline/concourse-ts.yml`
step.set_pipeline = 'self'
})
)
})
)
})
return new ConcourseTs.Pipeline<Group>(name, auto_pipeline())
}
28 changes: 22 additions & 6 deletions packages/concourse-ts-recipe-auto-pipeline/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as ConcourseTs from '@decentm/concourse-ts'

export enum AutoPipelineCompilation {
Local,
Docker,
}

export type AutoPipelineOptions<Group extends string = never> = {
/**
* A Resource that contains at least one valid concourse-ts pipeline file
Expand All @@ -19,7 +24,7 @@ export type AutoPipelineOptions<Group extends string = never> = {
*
* https://hub.docker.com/r/decentm/concourse-ts-cli/tags
*/
cli_tag: string
cli_tag?: string
}

const create_cli_command_task = <Group extends string = never>(
Expand Down Expand Up @@ -111,20 +116,31 @@ export const create_auto_pipeline =
compile_and_transform
)

const set_compiled_pipeline_step = new ConcourseTs.SetPipelineStep(
'set-compiled-pipeline',
(step) => {
step.set_pipeline = pipeline
step.file = `output/pipeline/${pipeline.name}.yml`
}
)

const set_pipeline_step = new ConcourseTs.SetPipelineStep(
'set-pipeline',
(step) => {
step.set_pipeline = pipeline
step.file = `output/pipeline/${pipeline.name}.yml`
step.file = `${options.resource.name}/${options.path}`
}
)

const auto_pipeline_job = new ConcourseTs.Job('auto-pipeline', (job) => {
job.max_in_flight = 1

job.add_step(get_resource_step)
job.add_step(compile_task.as_task_step())
job.add_step(set_pipeline_step)

if (options.cli_tag) {
job.add_step(compile_task.as_task_step())
job.add_step(set_compiled_pipeline_step)
} else {
job.add_step(set_pipeline_step)
}
})

if (customise) {
Expand Down

0 comments on commit 23a1c58

Please sign in to comment.