Skip to content

hello

The smallest script: one step, on every commit.

# The smallest script: one step, on every commit.

def ci(ctx):
    return [step("hello", image = "alpine:3", run = "echo hello from " + ctx.sha[:8])]
# Generated by `starci compile` from hello.ci.star. Edit that, not this.
#
# Each job is one step of the plan: the same image, command, tools and
# packages, given only the step's inputs. A job skips its work when it has
# already passed with the same inputs.
#
# What does not carry over:
#  - Passes are remembered in this repository's Actions cache, which GitHub
#    scopes by branch and evicts when old. starci's own store has neither
#    limit.

name: CI

on:
  push:
    branches: ['**']
    tags: ['**']
  pull_request:
  workflow_dispatch:

jobs:
  hello:
    name: "hello"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Has this already passed with these inputs?
        id: passed
        uses: actions/cache@v4
        with:
          path: ${{ runner.temp }}/starci-passed
          key: starci-passed-hello-3fd3a18513f2d029-${{ hashFiles('**', '!.git/**') }}
      - name: "hello"
        if: steps.passed.outputs.cache-hit != 'true'
        env:
          STARCI_RUN: "echo hello from "
        run: |
          docker run --rm \
            -v "$PWD:/workspace" \
            -w /workspace \
            alpine:3 sh -c "$STARCI_RUN"
      - name: Remember this pass
        if: steps.passed.outputs.cache-hit != 'true'
        run: mkdir -p "$RUNNER_TEMP/starci-passed" && date > "$RUNNER_TEMP/starci-passed/at"
# Generated by `starci compile --target circleci` from hello.ci.star. Edit that, not this.
#
# Each job is one step of the plan: the same image, command, tools and
# packages, given only the step's inputs. A job skips its work when it has
# already passed with the same inputs.
#
# What does not carry over:
#  - The script reads ctx.sha, so its plan depends on the commit. This file is
#    the plan for a commit about which nothing is known, and is the same for
#    every push: steps the script would add or drop for a particular branch or
#    set of changed files are not represented.
#  - Passes are remembered in this project's CircleCI cache, which expires.
#    starci's own store does not.

version: 2.1

jobs:
  hello:
    machine:
      image: ubuntu-2404:current
    resource_class: medium
    steps:
      - checkout
      - run:
          name: "Identify the inputs"
          command: |
            git ls-files -s -- ':(top)' > /tmp/starci-inputs
      - restore_cache:
          name: Has this already passed with these inputs?
          keys:
            - starci-passed-hello-3fd3a18513f2d029-{{ checksum "/tmp/starci-inputs" }}
      - run:
          name: "Stop here if it has"
          command: |
            if [ -e ~/starci-passed/at ]; then
              echo "Passed before with the same inputs, on $(cat ~/starci-passed/at). Nothing to do."
              circleci-agent step halt
            fi
      - run:
          name: "hello"
          environment:
            STARCI_RUN: "echo hello from "
          command: |
            docker run --rm \
              -v "$PWD:/workspace" \
              -w /workspace \
              alpine:3 sh -c "$STARCI_RUN"
      - run:
          name: "Remember this pass"
          command: |
            mkdir -p ~/starci-passed && date > ~/starci-passed/at
      - save_cache:
          key: starci-passed-hello-3fd3a18513f2d029-{{ checksum "/tmp/starci-inputs" }}
          paths:
            - ~/starci-passed

workflows:
  ci:
    jobs:
      - hello

Download: hello.ci.star, GitHub Actions, CircleCI