Skip to content

Brickell-Research/caffeine_lang_github_action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

caffeine-lang GitHub Action

An example integration of the Caffeine language into a GitHub Action.

Inputs

Input Required Default Description
measurements_dir yes measurements Directory containing vendor measurement .caffeine files (relative to repository root).
expectations_dir yes expectations Directory containing expectation .caffeine files in org/team/service structure (relative to repository root).
output_path yes output Output file or directory path (relative to repository root).
caffeine_version no 5.6.0 Caffeine compiler release tag to install.

Version pinning

The action installs a pinned Caffeine compiler release (default 5.6.0) instead of always pulling releases/latest. This prevents an upstream breaking release (e.g. a future 6.0.0) from silently breaking every consumer that references this action via @main.

If you actively maintain your workflow, pass caffeine_version explicitly and bump it on your own schedule:

- uses: Brickell-Research/caffeine_lang_github_action@main
  with:
    measurements_dir: slos/specifications
    expectations_dir: slos/YOUR_ORG
    output_path: slos
    caffeine_version: "5.6.0"

If you set it once and forget it, omit caffeine_version and you'll stay on the conservative default. That default is held stable on purpose — it will not be bumped without a concrete reason, since @main consumers inherit it on their next CI run.

For full reproducibility, pin both the action ref (a commit SHA, or @v1 once tagged) and caffeine_version.

Example workflow

How I use it today in my Terraform SLO Sync workflow (for Datadog SLOs):

name: Sync SLOs - Caffeine Lang

on:
  push:
    branches:
      - main

jobs:
  test-binary:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: slos

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        # PAT with `contents: write` so the final step can push the
        # updated terraform.tfstate back to the repo. The default
        # GITHUB_TOKEN is read-only unless you also add
        # `permissions: contents: write` at the job level.
        token: ${{ secrets.GH_TOKEN }}

    - name: Compile SLOs with the Caffeine Language
      uses: Brickell-Research/caffeine_lang_github_action@main
      with:
        measurements_dir: slos/specifications
        expectations_dir: slos/YOUR_ORG
        output_path: slos
        caffeine_version: "5.6.0"

    - name: Set up Terraform
      uses: hashicorp/setup-terraform@v2
      with:
        terraform_version: "1.5.7"

    - name: Terraform Init
      run: |
          terraform init \
            -backend-config="path=terraform.tfstate" \
            -migrate-state \
            -force-copy \
            -input=false
      env:
        TF_INPUT: "false"
        TF_IN_AUTOMATION: "true"

    - name: Terraform Validate
      run: terraform validate

    - name: Validate Datadog Credentials
      env:
        DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
        DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY }}
      run: |
        if [ -z "$DATADOG_API_KEY" ] || [ -z "$DATADOG_APP_KEY" ]; then
          echo "Error: DATADOG_API_KEY or DATADOG_APP_KEY is not set in GitHub secrets."
          exit 1
        fi

        echo "Validating Datadog API credentials..."
        response_code=$(curl -s -o /dev/null -w "%{http_code}" -H "DD-API-KEY: $DATADOG_API_KEY" -H "DD-APPLICATION-KEY: $DATADOG_APP_KEY" "https://api.datadoghq.com/api/v1/validate")

        if [ "$response_code" -eq 200 ]; then
          echo "✅ Datadog credentials are valid."
        else
          echo "❌ Error: Datadog credentials validation failed. HTTP status code: $response_code"
          exit 1
        fi

    - name: Terraform Apply
      run: terraform apply -auto-approve -input=false
      env:
        TF_INPUT: "false"
        TF_IN_AUTOMATION: "true"
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        TF_VAR_datadog_api_key: ${{ secrets.DATADOG_API_KEY }}
        TF_VAR_datadog_app_key: ${{ secrets.DATADOG_APP_KEY }}

    - name: Commit and Push Terraform State
      run: |
        git config --global user.name "GitHub Actions Bot"
        git config --global user.email "github-actions[bot]@users.noreply.github.com"
        git add -f *.tfstate
        git commit -m "[SLO SYNC] Update Terraform state files [skip ci]" || exit 0
        git push

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors