Skip to content

Starter templates Rspec and Elixir overhauls #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "Elixir",
"description": "Run quality checks and tests for your Elixir app in Docker with security scanning and type checking. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-green white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Dialyzer</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Credo</span></div>",
"short_description": "Run your Elixir suite",
"title": "Elixir CI/CD (Docker)",
"description": "Comprehensive Docker-based pipeline for non-Phoenix Elixir projects: dependency caching, code formatting, static analysis (Credo), security scanning (Sobelow & deps.audit), type checking with Dialyzer, parallelised tests on PostgreSQL, and an optional Docker image build + push on <code>main</code>. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-green white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Credo</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Dialyzer</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Sobelow</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Deps-Audit</span><span class='f6 normal mr1 ph1 br2 bg-light-blue white'>Postgres</span></div>",
"short_description": "Docker-native CI/CD for Elixir apps",
"group": "ci",
"language": "Elixir",
"environment": "docker",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-elixir.svg",
"template_path": "templates/elixir_docker.yml",
"workflow_tip": "other"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "Elixir",
"description": "Run quality checks and tests for your Elixir app using Mix tools for formatting, security, and type checking. Tests are parallelized for faster execution. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-green white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Mix</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Dialyzer</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Credo</span></div>",
"short_description": "Run your Elixir suite",
"title": "Elixir CI Pipeline",
"description": "End-to-end pipeline for non-Phoenix Elixir projects: dependency caching, code formatting, static analysis, security scanning, type checking, parallelised tests with PostgreSQL, and an optional Docker image build on <code>main</code>. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-green white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Mix</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Credo</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Sobelow</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Deps-Audit</span><span class='f6 normal mr1 ph1 br2 bg-red white'>Dialyzer</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Postgres</span><span class='f6 normal mr1 ph1 br2 bg-gray white'>Docker</span></div>",
"short_description": "Comprehensive CI for Elixir apps",
"group": "ci",
"language": "Elixir",
"environment": "linux",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-elixir.svg",
"template_path": "templates/elixir_saas.yml",
"workflow_tip": "other"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "Go",
"description": "Run quality checks and tests for your Go app in Docker using gotestsum for enhanced test reporting. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Go</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>gotestsum</span></div>",
"short_description": "Run your Go suite",
"title": "Go – Docker CI Pipeline",
"description": "Run a full featured Go CI pipeline inside Docker with dependency caching, code formatting and static analysis (gofmt, golangci-lint, staticcheck), security scanning via govulncheck, fast parallel tests and JUnit reports with gotestsum, binary compilation, and Docker image packaging. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Go</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>gotestsum</span><span class='f6 normal mr1 ph1 br2 bg-indigo white'>golangci-lint</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>staticcheck</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>govulncheck</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>JUnit</span></div>",
"short_description": "Full Go CI pipeline in Docker with parallel tests",
"group": "ci",
"language": "Go",
"language": "golang",
"environment": "docker",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-go.svg",
"template_path": "templates/go_docker.yml",
"workflow_tip": "other"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "Go",
"description": "Run quality checks and parallel tests for your Go app using gotestsum for enhanced test reporting. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Go</span><span class='f6 normal mr1 ph1 br2 bg-green white'>gotestsum</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>JUnit</span></div>",
"short_description": "Run your Go suite",
"title": "Go CI Pipeline",
"description": "Run a full featured Go CI pipeline with dependency caching, code formatting and static analysis (gofmt, golangci-lint, staticcheck), security scanning with govulncheck, parallel test execution and JUnit reports via gotestsum, binary artifact compilation, and Docker image packaging. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Go</span><span class='f6 normal mr1 ph1 br2 bg-green white'>gotestsum</span><span class='f6 normal mr1 ph1 br2 bg-indigo white'>golangci-lint</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>staticcheck</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>govulncheck</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>JUnit</span></div>",
"short_description": "Full Go CI pipeline with fast parallel tests",
"group": "ci",
"language": "Go",
"language": "golang",
"environment": "linux",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-go.svg",
"template_path": "templates/go_saas.yml",
"workflow_tip": "other"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "RSpec",
"description": "Run parallel RSpec tests in Docker with PostgreSQL and Redis support. Uses Knapsack for test distribution. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-red white'>Ruby</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>RSpec</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Knapsack</span></div>",
"short_description": "Run your Ruby RSpec suite",
"title": "Ruby – RSpec (Docker)",
"description": "Run a Rails-ready CI pipeline inside Docker with PostgreSQL 17 & Redis 7 service containers, dependency caching, asset compilation, JS/CSS linting (ESLint + Stylelint), Ruby quality checks (RuboCop), security scanning (Brakeman + Bundler-Audit), and fast parallel RSpec execution via Semaphore Boosters. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-red white'>Ruby</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>RSpec</span><span class='f6 normal mr1 ph1 br2 bg-indigo white'>RuboCop</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Brakeman</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Bundler</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>ESLint</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Stylelint</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Boosters</span></div>",
"short_description": "Full RSpec pipeline in Docker",
"group": "ci",
"language": "Ruby",
"environment": "docker",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-ruby.svg",
"template_path": "templates/rspec_docker.yml",
"workflow_tip": "other"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"title": "RSpec",
"description": "Use Bundler, Bundler-audit, RuboCop, and Brakeman to test your Rails app. This CI pipeline uses Knapsack Pro to paralelize your tests. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-red white'>Rails</span><span class='f6 normal mr1 ph1 br2 bg-indigo white'>RuboCop</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Knapsack</span></div>",
"short_description": "Run your Ruby RSpec suite",
"title": "Ruby – RSpec CI Pipeline",
"description": "Set up a full-featured Rails pipeline with dependency caching, asset compilation, JS/CSS linting (ESLint + Stylelint), Ruby quality checks (RuboCop), security scanning (Brakeman + Bundler-Audit), and lightning-fast parallel test execution powered by Semaphore Boosters. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-red white'>Rails</span><span class='f6 normal mr1 ph1 br2 bg-indigo white'>RuboCop</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Boosters</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>ESLint</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Stylelint</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Brakeman</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Bundler-Audit</span></div>",
"short_description": "Parallel RSpec pipeline for Rails apps",
"group": "ci",
"language": "Ruby",
"environment": "linux",
"use_case": "ci_pipeline",
"tags": ["ci_pipeline", "security_checks"],
"icon": "lang-ruby.svg",
"template_path": "templates/rspec_saas.yml",
"workflow_tip": "other"
Expand Down
162 changes: 120 additions & 42 deletions front/workflow_templates/saas_new/templates/elixir_docker.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,163 @@
# Semaphore CI pipeline for a non-Phoenix Elixir project
# Spec: https://docs.semaphoreci.com/reference/pipeline-yaml

version: v1.0
name: "πŸ’« Elixir CI Pipeline"
name: "πŸ’§ Elixir CI Pipeline"

# -------------------------------------------------------------------
# Define the machine type and OS image to run the pipeline on
# -------------------------------------------------------------------
agent:
machine:
type: {{ machine_type }} # Define the machine type (e.g., e1-standard-2 for cost-efficiency)
os_image: {{ os_image }} # Specify the OS image (e.g., ubuntu2004 for compatibility)
type: {{ machine_type }}
os_image: {{ os_image }}

containers:
- name: main
image: 'registry.semaphoreci.com/elixir:1.15.7' # Elixir 1.15.7 with Erlang/OTP 26
image: 'registry.semaphoreci.com/elixir:1.16' # Elixir 1.16 with Erlang/OTP 26
- name: postgres
image: 'registry.semaphoreci.com/postgres:17' # PostgreSQL 17 for database operations

# Configure when to stop the pipeline early
fail_fast:
stop:
when: branch != 'main' # Stop execution early for non-main branches to save resources
when: branch != 'main' # Stop all blocks if a job fails on non-main branches
auto_cancel:
running:
when: branch != 'main' # Cancel running pipelines on non-main branches
queued:
when: branch = 'main' # Cancel queued pipelines on the main branch
when: branch = 'main' # Cancel queued pipelines on main branch

# -------------------------------------------------------------------
# GLOBAL JOB CONFIG – runs before every job
# Docs: https://docs.semaphoreci.com/reference/pipeline-yaml#global-job-config
# Keep only commands truly needed everywhere
# -------------------------------------------------------------------
global_job_config:
prologue:
commands:
- checkout # Fetch the latest code from the repository
- cache restore # Restore cached dependencies for faster builds
- mix local.hex --force # Install Hex, the Elixir package manager
- mix local.rebar --force # Install rebar3, a build tool for Erlang/Elixir
- mix deps.get # Fetch project dependencies
- checkout # Clone repo β†’ https://docs.semaphoreci.com/reference/toolbox#checkout
- mix local.hex --force
- mix local.rebar --force
- cache restore # Reuse deps/ or _build cache

# -------------------------------------------------------------------
# BLOCK: πŸ“¦ Install & Build – compile & cache artifacts
# -------------------------------------------------------------------
blocks:
- name: "πŸ› οΈ Setup and Cache"
- name: "πŸ“¦ Install & Build"
dependencies: []
task:
jobs:
- name: "Install Dependencies"
- name: "βš™οΈ Compile"
commands:
- mix deps.get
- mix compile
- cache store # Save deps/ or _build for later steps

# -------------------------------------------------------------------
# CODE-QUALITY BLOCKS – one block per check
# -------------------------------------------------------------------
- name: "πŸ–‹ Format"
dependencies: ["πŸ“¦ Install & Build"]
task:
jobs:
- name: "🎨 mix format"
commands:
- mix format --check-formatted

- name: "πŸ”Ž Credo"
dependencies: ["πŸ“¦ Install & Build"]
task:
jobs:
- name: "πŸ” mix credo"
commands:
- mix deps.compile # Compile dependencies to ensure compatibility
- mix compile # Compile the project
- cache store # Store compiled dependencies for future runs
- mix credo --strict

- name: "πŸ” Code Quality"
dependencies: ["πŸ› οΈ Setup and Cache"]
- name: "πŸ” Sobelow"
dependencies: ["πŸ“¦ Install & Build"]
task:
jobs:
- name: "Run Formatter and Credo"
- name: "πŸ›‘οΈ mix sobelow"
commands:
- mix format --check-formatted # Ensure all code is properly formatted
- mix credo --strict # Perform static analysis to enforce best practices
- mix sobelow --exit

- name: "πŸ” Security Checks"
dependencies: ["πŸ› οΈ Setup and Cache"]
- name: "πŸ›‘ Deps Audit"
dependencies: ["πŸ“¦ Install & Build"]
task:
jobs:
- name: "Run Security Scans"
- name: "πŸ›‘οΈ mix deps.audit"
commands:
- mix deps.audit # Audit dependencies for known vulnerabilities
- mix sobelow # Run security analysis on the codebase
- mix deps.audit

- name: "πŸ“Š Dialyzer"
dependencies: ["πŸ› οΈ Setup and Cache"]
dependencies: ["πŸ“¦ Install & Build"]
task:
jobs:
- name: "🧠 mix dialyzer"
env_vars:
- name: MIX_ENV
value: test
commands:
- mix dialyzer --halt-exit-status

# -------------------------------------------------------------------
# BLOCK: πŸ§ͺ Tests – split suite for faster feedback
# -------------------------------------------------------------------
- name: "πŸ§ͺ Tests"
dependencies: ["πŸ“¦ Install & Build"]
task:
epilogue: # Publish JUnit only for test jobs
always:
commands:
- '[ -f report.xml ] && test-results publish report.xml' # https://docs.semaphoreci.com/using-semaphore/tests/test-reports
jobs:
- name: "Type Checking"
- name: "πŸ§ͺ Tests-1"
env_vars:
- name: MIX_TEST_PARTITION
value: "1"
commands:
- mix dialyzer # Perform static type checking for code correctness
- mix test --color
- name: "πŸ§ͺ Tests-2"
env_vars:
- name: MIX_TEST_PARTITION
value: "2"
commands:
- mix test --color

- name: "πŸ§ͺ Test Suite"
dependencies: ["πŸ› οΈ Setup and Cache"]
# -------------------------------------------------------------------
# BLOCK: πŸš€ Docker Deploy – runs only on main branch
# Secrets docs: https://docs.semaphoreci.com/reference/pipeline-yaml#secrets-in-task
# -------------------------------------------------------------------
- name: "πŸš€ Docker Deploy"
dependencies:
- "πŸ–‹ Format"
- "πŸ”Ž Credo"
- "πŸ” Sobelow"
- "πŸ›‘ Deps Audit"
- "πŸ“Š Dialyzer"
- "πŸ§ͺ Tests"
run:
when: "branch = 'main'"
task:
env_vars:
- name: MIX_ENV
value: test # Set the environment to test
- name: PGHOST
value: postgres # PostgreSQL container name
- name: PGUSER
value: postgres # PostgreSQL user
secrets:
- name: dockerhub # Registry creds
jobs:
- name: "🟒 Run Tests with Coverage"
parallelism: 4 # Run tests in parallel for faster execution
- name: "🐳 Build & Push"
commands:
- mix test.setup # Set up the test database
- mix test --partitions $SEMAPHORE_JOB_COUNT --partition $SEMAPHORE_JOB_INDEX --cover # Run tests with partitioning and coverage reporting
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker build -t myapp:${SEMAPHORE_GIT_SHA} .
- docker tag myapp:${SEMAPHORE_GIT_SHA} myapp:latest
- docker push myapp:${SEMAPHORE_GIT_SHA}
- docker push myapp:latest

# -------------------------------------------------------------------
# AFTER PIPELINE – merge JUnit files into a single report
# Docs: https://docs.semaphoreci.com/using-semaphore/tests/test-reports#step3
# -------------------------------------------------------------------
after_pipeline:
task:
jobs:
- name: "πŸ“Š Merge Reports"
commands:
- test-results gen-pipeline-report # Combine job reports
Loading