Imported from leandrocp/github-actions (
AGENTS.md). Install upstream withnpx skills add leandrocp/github-actions. Copyright stays with the author.
AGENTS.md
This file provides guidance to AI agents when working with code in this repository.
Repository Purpose
This repository provides reusable GitHub Actions workflows for CI/CD in Elixir and Rust projects. It is designed to be referenced by other repositories using the workflow_call trigger.
Based on mtrudel/elixir-ci-actions.
Architecture
Workflow Structure
All workflows are reusable (on: workflow_call) and located in .github/workflows/:
- elixir-test.yml: Runs Elixir tests across multiple Elixir/OTP version combinations
- elixir-lint.yml: Lints Elixir code and optionally runs Credo; can also install Rust for projects that compile Rust or NIF code
- elixir-release.yml: Maintains git-cliff release pull requests and creates tags/releases after merge
- rust-test.yml: Runs Rust tests across stable/MSRV and nightly OS matrices
- rust-lint.yml: Lints Rust code (rustfmt, clippy) and optionally verifies MSRV
- nif-release.yml: Builds precompiled Rustler NIF artifacts for multiple targets and publishes tagged releases
- hex-publish.yml: Publishes Elixir packages to Hex with configurable Elixir/OTP, optional Rust setup, custom env vars, and pre-publish hooks
The repository also includes validate.yml, a repository-level workflow that runs actionlint for changes under .github/workflows/. It is not reusable.
The elixir-release/ directory contains the composite action, git-cliff
configuration, and changelog helper used by elixir-release.yml.
Key Design Patterns
-
Matrix Testing: Reusable workflows use strategy matrices where it makes sense
- Elixir test: defaults to Elixir 1.20/OTP 29 and
main-otp-29/maint-29 - Elixir lint: defaults to the same Elixir/OTP pairs and can optionally run Credo
- Rust test: defaults to stable on LTS runners and nightly on latest runners; when
msrvis set, an additional MSRV matrix runs on the stable OS set - Rust test stages:
test-stagedefaults toall; callers can composestableandcompatibilitycalls withneedsfor an opt-in stable-first gate - NIF release: builds a target matrix across macOS, Linux, Windows, and FreeBSD targets
- Elixir test: defaults to Elixir 1.20/OTP 29 and
-
Customizable Inputs: All workflows accept version arrays as JSON strings
- Example:
pairs: '[{"elixir": "1.17.x", "otp": "27.x"}]' - Example:
rust-versions: '["nightly"]' - Example:
stable-os-versions: '["ubuntu-22.04", "macos-14"]' - Example:
nif-versions: '["2.15", "2.16"]'
- Example:
-
Custom Environment Variables: Elixir workflows support additional environment variables
- Accepts JSON object via
env_varsinput - Example:
env_vars: '{"MDEX_BUILD": "1"}' - Useful for projects requiring special compilation flags (e.g., forcing NIF builds)
- Accepts JSON object via
-
Coverage:
elixir-test.ymlsupportscoverage: trueto runmix test --cover- Coverage thresholds stay in each project's
mix.exsviatest_coverage
- Coverage thresholds stay in each project's
-
Publishing Workflows
elixir-release.ymlrequires an existingvX.Y.Ztag and a token that can create pull requests, tags, and releaseselixir-release.ymlexpects one@version "x.y.z"declaration and preserves existing changelog historyhex-publish.ymlrequires theHEX_API_KEYsecrethex-publish.ymlusesenv-vars(hyphenated) rather thanenv_varshex-publish.ymlcan install Rust and run apre-publish-commandbeforepublish-commandnif-release.ymlexpects both the Mix app working directory and the Rust project directory when they differ
Development
- Run
actionlintto validate workflow syntax and content - Prefer updating
README.mdwhen workflow inputs, defaults, or examples change