Skip to content

Commit 5f2eaa0

Browse files
authored
Starter templates Rspec and Elixir overhauls (#400)
## πŸ“ Description Changes to the following starter templates: Rspec cloud and docker Elixir cloud and docker Go cloud and docker Their properties files as well ## βœ… Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 9142b04 commit 5f2eaa0

12 files changed

+581
-347
lines changed

β€Žfront/workflow_templates/saas_new/properties/elixir_docker.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Elixir",
3-
"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>",
4-
"short_description": "Run your Elixir suite",
2+
"title": "Elixir CI/CD (Docker)",
3+
"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>",
4+
"short_description": "Docker-native CI/CD for Elixir apps",
55
"group": "ci",
66
"language": "Elixir",
77
"environment": "docker",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-elixir.svg",
1011
"template_path": "templates/elixir_docker.yml",
1112
"workflow_tip": "other"

β€Žfront/workflow_templates/saas_new/properties/elixir_saas.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Elixir",
3-
"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>",
4-
"short_description": "Run your Elixir suite",
2+
"title": "Elixir CI Pipeline",
3+
"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>",
4+
"short_description": "Comprehensive CI for Elixir apps",
55
"group": "ci",
66
"language": "Elixir",
77
"environment": "linux",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-elixir.svg",
1011
"template_path": "templates/elixir_saas.yml",
1112
"workflow_tip": "other"

β€Žfront/workflow_templates/saas_new/properties/go_docker.properties.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Go",
3-
"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>",
4-
"short_description": "Run your Go suite",
2+
"title": "Go – Docker CI Pipeline",
3+
"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>",
4+
"short_description": "Full Go CI pipeline in Docker with parallel tests",
55
"group": "ci",
6-
"language": "Go",
6+
"language": "golang",
77
"environment": "docker",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-go.svg",
1011
"template_path": "templates/go_docker.yml",
1112
"workflow_tip": "other"

β€Žfront/workflow_templates/saas_new/properties/go_saas.properties.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Go",
3-
"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>",
4-
"short_description": "Run your Go suite",
2+
"title": "Go CI Pipeline",
3+
"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>",
4+
"short_description": "Full Go CI pipeline with fast parallel tests",
55
"group": "ci",
6-
"language": "Go",
6+
"language": "golang",
77
"environment": "linux",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-go.svg",
1011
"template_path": "templates/go_saas.yml",
1112
"workflow_tip": "other"

β€Žfront/workflow_templates/saas_new/properties/rspec_docker.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "RSpec",
3-
"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>",
4-
"short_description": "Run your Ruby RSpec suite",
2+
"title": "Ruby – RSpec (Docker)",
3+
"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>",
4+
"short_description": "Full RSpec pipeline in Docker",
55
"group": "ci",
66
"language": "Ruby",
77
"environment": "docker",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-ruby.svg",
1011
"template_path": "templates/rspec_docker.yml",
1112
"workflow_tip": "other"

β€Žfront/workflow_templates/saas_new/properties/rspec_saas.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "RSpec",
3-
"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>",
4-
"short_description": "Run your Ruby RSpec suite",
2+
"title": "Ruby – RSpec CI Pipeline",
3+
"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>",
4+
"short_description": "Parallel RSpec pipeline for Rails apps",
55
"group": "ci",
66
"language": "Ruby",
77
"environment": "linux",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-ruby.svg",
1011
"template_path": "templates/rspec_saas.yml",
1112
"workflow_tip": "other"
Lines changed: 120 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,163 @@
1+
# Semaphore CI pipeline for a non-Phoenix Elixir project
2+
# Spec: https://docs.semaphoreci.com/reference/pipeline-yaml
3+
14
version: v1.0
2-
name: "πŸ’« Elixir CI Pipeline"
5+
name: "πŸ’§ Elixir CI Pipeline"
36

7+
# -------------------------------------------------------------------
8+
# Define the machine type and OS image to run the pipeline on
9+
# -------------------------------------------------------------------
410
agent:
511
machine:
6-
type: {{ machine_type }} # Define the machine type (e.g., e1-standard-2 for cost-efficiency)
7-
os_image: {{ os_image }} # Specify the OS image (e.g., ubuntu2004 for compatibility)
12+
type: {{ machine_type }}
13+
os_image: {{ os_image }}
814

915
containers:
1016
- name: main
11-
image: 'registry.semaphoreci.com/elixir:1.15.7' # Elixir 1.15.7 with Erlang/OTP 26
17+
image: 'registry.semaphoreci.com/elixir:1.16' # Elixir 1.16 with Erlang/OTP 26
1218
- name: postgres
1319
image: 'registry.semaphoreci.com/postgres:17' # PostgreSQL 17 for database operations
1420

21+
# Configure when to stop the pipeline early
1522
fail_fast:
1623
stop:
17-
when: branch != 'main' # Stop execution early for non-main branches to save resources
24+
when: branch != 'main' # Stop all blocks if a job fails on non-main branches
1825
auto_cancel:
1926
running:
2027
when: branch != 'main' # Cancel running pipelines on non-main branches
2128
queued:
22-
when: branch = 'main' # Cancel queued pipelines on the main branch
29+
when: branch = 'main' # Cancel queued pipelines on main branch
2330

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

44+
# -------------------------------------------------------------------
45+
# BLOCK: πŸ“¦ Install & Build – compile & cache artifacts
46+
# -------------------------------------------------------------------
3347
blocks:
34-
- name: "πŸ› οΈ Setup and Cache"
48+
- name: "πŸ“¦ Install & Build"
3549
dependencies: []
3650
task:
3751
jobs:
38-
- name: "Install Dependencies"
52+
- name: "βš™οΈ Compile"
53+
commands:
54+
- mix deps.get
55+
- mix compile
56+
- cache store # Save deps/ or _build for later steps
57+
58+
# -------------------------------------------------------------------
59+
# CODE-QUALITY BLOCKS – one block per check
60+
# -------------------------------------------------------------------
61+
- name: "πŸ–‹ Format"
62+
dependencies: ["πŸ“¦ Install & Build"]
63+
task:
64+
jobs:
65+
- name: "🎨 mix format"
66+
commands:
67+
- mix format --check-formatted
68+
69+
- name: "πŸ”Ž Credo"
70+
dependencies: ["πŸ“¦ Install & Build"]
71+
task:
72+
jobs:
73+
- name: "πŸ” mix credo"
3974
commands:
40-
- mix deps.compile # Compile dependencies to ensure compatibility
41-
- mix compile # Compile the project
42-
- cache store # Store compiled dependencies for future runs
75+
- mix credo --strict
4376

44-
- name: "πŸ” Code Quality"
45-
dependencies: ["πŸ› οΈ Setup and Cache"]
77+
- name: "πŸ” Sobelow"
78+
dependencies: ["πŸ“¦ Install & Build"]
4679
task:
4780
jobs:
48-
- name: "Run Formatter and Credo"
81+
- name: "πŸ›‘οΈ mix sobelow"
4982
commands:
50-
- mix format --check-formatted # Ensure all code is properly formatted
51-
- mix credo --strict # Perform static analysis to enforce best practices
83+
- mix sobelow --exit
5284

53-
- name: "πŸ” Security Checks"
54-
dependencies: ["πŸ› οΈ Setup and Cache"]
85+
- name: "πŸ›‘ Deps Audit"
86+
dependencies: ["πŸ“¦ Install & Build"]
5587
task:
5688
jobs:
57-
- name: "Run Security Scans"
89+
- name: "πŸ›‘οΈ mix deps.audit"
5890
commands:
59-
- mix deps.audit # Audit dependencies for known vulnerabilities
60-
- mix sobelow # Run security analysis on the codebase
91+
- mix deps.audit
6192

6293
- name: "πŸ“Š Dialyzer"
63-
dependencies: ["πŸ› οΈ Setup and Cache"]
94+
dependencies: ["πŸ“¦ Install & Build"]
95+
task:
96+
jobs:
97+
- name: "🧠 mix dialyzer"
98+
env_vars:
99+
- name: MIX_ENV
100+
value: test
101+
commands:
102+
- mix dialyzer --halt-exit-status
103+
104+
# -------------------------------------------------------------------
105+
# BLOCK: πŸ§ͺ Tests – split suite for faster feedback
106+
# -------------------------------------------------------------------
107+
- name: "πŸ§ͺ Tests"
108+
dependencies: ["πŸ“¦ Install & Build"]
64109
task:
110+
epilogue: # Publish JUnit only for test jobs
111+
always:
112+
commands:
113+
- '[ -f report.xml ] && test-results publish report.xml' # https://docs.semaphoreci.com/using-semaphore/tests/test-reports
65114
jobs:
66-
- name: "Type Checking"
115+
- name: "πŸ§ͺ Tests-1"
116+
env_vars:
117+
- name: MIX_TEST_PARTITION
118+
value: "1"
67119
commands:
68-
- mix dialyzer # Perform static type checking for code correctness
120+
- mix test --color
121+
- name: "πŸ§ͺ Tests-2"
122+
env_vars:
123+
- name: MIX_TEST_PARTITION
124+
value: "2"
125+
commands:
126+
- mix test --color
69127

70-
- name: "πŸ§ͺ Test Suite"
71-
dependencies: ["πŸ› οΈ Setup and Cache"]
128+
# -------------------------------------------------------------------
129+
# BLOCK: πŸš€ Docker Deploy – runs only on main branch
130+
# Secrets docs: https://docs.semaphoreci.com/reference/pipeline-yaml#secrets-in-task
131+
# -------------------------------------------------------------------
132+
- name: "πŸš€ Docker Deploy"
133+
dependencies:
134+
- "πŸ–‹ Format"
135+
- "πŸ”Ž Credo"
136+
- "πŸ” Sobelow"
137+
- "πŸ›‘ Deps Audit"
138+
- "πŸ“Š Dialyzer"
139+
- "πŸ§ͺ Tests"
140+
run:
141+
when: "branch = 'main'"
72142
task:
73-
env_vars:
74-
- name: MIX_ENV
75-
value: test # Set the environment to test
76-
- name: PGHOST
77-
value: postgres # PostgreSQL container name
78-
- name: PGUSER
79-
value: postgres # PostgreSQL user
143+
secrets:
144+
- name: dockerhub # Registry creds
80145
jobs:
81-
- name: "🟒 Run Tests with Coverage"
82-
parallelism: 4 # Run tests in parallel for faster execution
146+
- name: "🐳 Build & Push"
83147
commands:
84-
- mix test.setup # Set up the test database
85-
- mix test --partitions $SEMAPHORE_JOB_COUNT --partition $SEMAPHORE_JOB_INDEX --cover # Run tests with partitioning and coverage reporting
148+
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
149+
- docker build -t myapp:${SEMAPHORE_GIT_SHA} .
150+
- docker tag myapp:${SEMAPHORE_GIT_SHA} myapp:latest
151+
- docker push myapp:${SEMAPHORE_GIT_SHA}
152+
- docker push myapp:latest
153+
154+
# -------------------------------------------------------------------
155+
# AFTER PIPELINE – merge JUnit files into a single report
156+
# Docs: https://docs.semaphoreci.com/using-semaphore/tests/test-reports#step3
157+
# -------------------------------------------------------------------
158+
after_pipeline:
159+
task:
160+
jobs:
161+
- name: "πŸ“Š Merge Reports"
162+
commands:
163+
- test-results gen-pipeline-report # Combine job reports

0 commit comments

Comments
Β (0)