CI for Laravel

Yaml Tidbits

Here are some things to know about running builds on Chipper CI using the Yaml configuration.

Complex Pipeline Commands

The build pipeline is now defined in Yaml:

pipeline:

  - name: Some Command
    cmd: |
      echo "I can do just about anything here!"

While using Yaml's pipe syntax (cmd: |) lets you write longer, multi-line pipeline scripts, you might agree that it makes your Yaml file ugly and harder to read (or be worried about Yaml syntax issues, depending on the content of the scripts).

A common way around this (and what I do for all CI solutions I've used) is to:

  1. Commit the complex scripts to your repository
  2. Run those in your CI pipeline

Sounds easy! Here's a few details.

Example Script

Here's an example of how I'd create a bash script to run in a CI pipeline:

# Make a scripts dir (or whatever you
#  want to call it)
mkdir scripts

# Create a script
touch scripts/some-complicated-step.sh

# Ensure the script is executable
# (You may need to make sure Git commits file mode changes)
chmod +x scripts/*.sh

And the contents of that script might look like this:

#!/usr/bin/env bash
# 👆 Ensure it is interprated as a bash script
# with that first line

# 👇 Stop on first failure and exit with failure code
# More details here: https://sipb.mit.edu/doc/safe-shell/
set -e

echo "Here are a bunch of complicated commands!"

# do things here

Example Pipeline

Now that your complicated bash script is created, you can set Chipper CI to run it (instead of polluting your beautiful Yaml file):

pipeline:

  - name: Do the Needful™
    cmd: ./scripts/some-complicated-step.sh

That's it!

Yaml Syntax

Chipper CI tries to make up for easily-made Yaml syntax mistakes, but there are only so many if statements we can throw at our code before we go crazy.

Here are a few things to be aware of:

################################################################
## The Environment is a "map". Yaml will return
#   something like {"php": "8.1", "node": "14}

# ✅ This is correct
#
environment:
  php: 8.3
  node: 14

# ❌ This is incorrect. 
#
# ➡️ Make sure to use spaces or Yaml returns something like {"php:8.1"}
environment:
  php:8.3
  node:14

################################################################
## Services are an array of services.
#  Yaml will return something like [{"mysql": "5.7"}, {"redis": "latest"}]

# ✅ This is correct
#
# Redis will always be "latest" in Chipper CI
services:
 - mysql: 5.7
 - redis:

# ❌ This is incorrect. 
#
# ➡️ Use the dashes! (e.g. `- mysql: 5.7`)
# ➡️ Use a colon even when omitting a version
services:
  mysql: 5.7
  redis:

# ❌ This is incorrect. 
#
# ➡️ Use a space after the colon
# ➡️ Always include the colon
services:
 - mysql:5.7
 - redis

Note that if we have to guess on a PHP/Node/Service version, we'll always guess on the latest version that Chipper CI supports.