Skip to main content

CI pipeline toolkit.

Project description

cici.tools

brettops tool pipeline status pre-commit code style: black code style: prettier

WARNING: cici is experimental and I can't even decide on a name for it. Stay away!

Usage

bundle

build

The build subcommand introduces BrettOps Pipeline format, a pipeline format that compiles into other pipeline formats.

BrettOps Pipelines are simple and easy to write, and can be compiled to any format.

They can also be executed locally with the included runner.

update

About BrettOps CI syntax

  • All data is strictly ordered and evaluated sequentially.

  • All jobs / pipelines are named.

  • Scripts, variables, and other snippets can be loaded from disk at build time.

  • Includes are evaluated at build time.

  • Can convert to GitLab CI for use with GitLab.

  • Uses Argo Workflow-style templating for vendor-neutral variables.

Example

Here is a BrettOps pipeline, saved as .brettops-pipeline.yml:

name: marp

stages:
  - name: test
  - name: build
  - name: deploy

inputs:
  - name: opts
  - name: footer
  - name: format_opts
  - name: svg_png_dpi
    default: "200"
  - name: theme_url

jobs:
  - name: build
    stage: build
    environment:
      image: registry.gitlab.com/brettops/containers/marp:main
    outputs:
      - type: path
        name: public
        value: public/
    scripts:
      - script:
          - marp --version
          - echo "${{input.format_opts}}"

          # inject a theme into the local environment if present
          - |-
            if [[ -n "${{input.theme_url}}" ]] ; then
              marp_theme_file="$(mktemp -u).css"
              wget -O "$marp_theme_file" "${{input.theme_url}}"
              {{input.opts}}="${{input.opts}} --theme $marp_theme_file"
            fi
          - echo "${{input.opts}}"
          # preprocess slides with marp-format
          - mapfile -t SLIDES < <(find . -name slides.md -type f -not -path "./public/*")
          - |-
            for slide in "${SLIDES[@]}"
            do
              preprocess="$(echo "$slide" | sed -e 's@slides\.md$@index.md@')"
              echo "preprocessing '$slide' to '$preprocess'"
              marp-format --output "$preprocess" "$slide" --metadata "footer=${{input.footer}}" ${{input.format_opts}}
            done

          # run marp on preprocessed slides
          - mapfile -t PREPROCESSED < <(find . -name index.md -type f)
          - marp ${{input.opts}} --html "${PREPROCESSED[@]}"
          - marp ${{input.opts}} --allow-local-files --pdf "${PREPROCESSED[@]}"

          # marshal into public directory
          - >-
            rsync -zarv
            --exclude ".git/"
            --exclude "public/"
            --include "*/"
            --include "index.html"
            --include "index.md"
            --include "index.pdf"
            --include "*.jpg"
            --include "*.png"
            --include "*.svg"
            --exclude "*"
            . public/

This format is intentionally verbose, as it is designed to transpile into other formats. It is also designed to generate pipeline documentation in a literate style. It is also intended to support being run locally using a built-in pipeline orchestrator.

Export to GitLab CI

cici build -t gitlab
stages:
  - test
  - build
  - deploy

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "push" && $CI_OPEN_MERGE_REQUESTS
      when: never
    - when: always

variables:
  MARP_OPTS: ""
  MARP_FOOTER: ""
  MARP_FORMAT_OPTS: ""
  MARP_SVG_PNG_DPI: "200"
  MARP_THEME_URL: ""

marp-build:
  stage: build
  image: registry.gitlab.com/brettops/containers/marp:main
  script:
    - marp --version
    - echo "$MARP_FORMAT_OPTS"
    - |-
      if [[ -n "$MARP_THEME_URL" ]] ; then
        marp_theme_file="$(mktemp -u).css"
        wget -O "$marp_theme_file" "$MARP_THEME_URL"
        MARP_OPTS="$MARP_OPTS --theme $marp_theme_file"
      fi
    - echo "$MARP_OPTS"
    - mapfile -t SLIDES < <(find . -name slides.md -type f -not -path "./public/*")
    - |-
      for slide in "${SLIDES[@]}"
      do
        preprocess="$(echo "$slide" | sed -e 's@slides\.md$@index.md@')"
        echo "preprocessing '$slide' to '$preprocess'"
        marp-format --output "$preprocess" "$slide" --metadata "footer=$MARP_FOOTER" $MARP_FORMAT_OPTS
      done
    - mapfile -t PREPROCESSED < <(find . -name index.md -type f)
    - marp $MARP_OPTS --html "${PREPROCESSED[@]}"
    - marp $MARP_OPTS --allow-local-files --pdf "${PREPROCESSED[@]}"
    - >-
      rsync -zarv --exclude ".git/" --exclude "public/" --include "*/" --include "index.html"
      --include "index.md" --include "index.pdf" --include "*.jpg" --include "*.png"
      --include "*.svg" --exclude "*" . public/
  artifacts:
    paths:
      - public/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cici.tools-0.1.4.tar.gz (25.7 kB view hashes)

Uploaded Source

Built Distribution

cici.tools-0.1.4-py3-none-any.whl (27.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page