Yesterday I posted an article about converting a really simple GitLab CI definition to Tekton.

The first bit of feedback I got was “that’s an easy example!” and indeed it was.

This is probably a more reasonable example:

image: golang:latest

variables:
  REPO_NAME: github.com/bigkevmcd/github-tool

before_script:
  - mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
  - ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
  - cd $GOPATH/src/$REPO_NAME

after_script:
  - echo "testing"

stages:
  - test
  - build

format:
  stage: test
  script:
    - go fmt $(go list ./... | grep -v /vendor/)
    - go vet $(go list ./... | grep -v /vendor/)
    - go test -race $(go list ./... | grep -v /vendor/)
  tekton:
    jobs:
      - CI_TESTING=test1
      - CI_TESTING=test2

lint:
  stage: test
  tekton:
    taskRef: lint-task
    params:
      - name: IMAGE_URL
        expr: "'quay.io/testing/testing'"

compile:
  stage: build
  script:
    - go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary
  artifacts:
    paths:
      - mybinary

Converting this with this command:

$ ./tekton-ci convert --pipeline-file examples/complete-example.yaml \
  --repository-url https://github.com/bigkevmcd/github-tool \
   --branch master

And this yields 305 lines of YAML with 7 taskSpecs, a taskRef, and sequenced correctly:

- name: git-clone
  taskSpec:

- name: before-step
  runAfter:
  - git-clone
  taskSpec:

- name: format-stage-test-0
  runAfter:
  - before-step
  taskSpec:

- name: format-stage-test-1
  runAfter:
  - before-step
  taskSpec:

- name: lint-stage-test
  runAfter:
  - before-step
  taskRef:

- name: compile-stage-build
  runAfter:
  - format-stage-test-0
  - format-stage-test-1
  taskSpec:

- name: compile-archiver
  runAfter:
  - format-stage-test-0
  - format-stage-test-1
  taskSpec:

- name: after-step
  runAfter:
  - compile-archiver
  taskSpec:

This example is in the source repository here.