Skip to content

Commit b4d9345

Browse files
authored
Csidyel/update starter templates (#351)
## 📝 Description rewrite front/workflow_templates/saas_new/properties/phoenix_docker.properties.json rewrite front/workflow_templates/saas_new/properties/phoenix_saas.properties.json rewrite front/workflow_templates/saas_new/templates/phoenix_docker.yml rewrite front/workflow_templates/saas_new/templates/phoenix_saas.yml ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 09c3479 commit b4d9345

File tree

8 files changed

+400
-326
lines changed

8 files changed

+400
-326
lines changed

front/workflow_templates/saas_new/properties/phoenix_docker.properties.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Elixir - Phoenix",
3-
"description": "Run tests and build Docker images for your Phoenix app with PostgreSQL and Redis support. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-orange white'>Phoenix</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>PostgreSQL</span><span class='f6 normal mr1 ph1 br2 bg-red white'>Redis</span></div>",
4-
"short_description": "Containerized CI/CD pipeline for Phoenix web applications",
2+
"title": "Elixir - Phoenix (Docker)",
3+
"description": "Run tests, security, and quality checks for your containerised Phoenix app with Docker services and PostgreSQL. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-indigo white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Phoenix</span><span class='f6 normal mr1 ph1 br2 bg-green white'>ExUnit</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Sobelow</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Credo</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Postgres</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Coveralls</span><span class='f6 normal mr1 ph1 br2 bg-light-gray white'>Docker</span></div><div class='mt2 ba br2 b--blue bg-washed-blue pa2'><strong>ℹ️ Coveralls integration:</strong> This pipeline uploads test‑coverage data to Coveralls. Add a <a href='https://docs.semaphoreci.com/using-semaphore/secrets' target='_blank'>project secret</a> named <code>coveralls</code> containing your <code>COVERALLS_REPO_TOKEN</code> so the upload step succeeds.</div>",
4+
"short_description": "Containerised CI pipeline for Phoenix web applications",
55
"group": "ci",
66
"language": "Elixir",
77
"environment": "docker",
8-
"use_case": "Web Application",
8+
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "docker", "security_checks"],
910
"icon": "lang-elixir.svg",
1011
"template_path": "templates/phoenix_docker.yml",
1112
"workflow_tip": "other"

front/workflow_templates/saas_new/properties/phoenix_saas.properties.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"title": "Elixir - Phoenix",
3-
"description": "Run tests and quality checks for your Phoenix app with ExUnit and browser testing via Wallaby. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-orange white'>Phoenix</span><span class='f6 normal mr1 ph1 br2 bg-green white'>ExUnit</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Wallaby</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Credo</span></div>",
4-
"short_description": "Full-featured CI/CD pipeline for Phoenix web applications",
3+
"description": "Run tests, security, and quality checks for your Phoenix app with ExUnit, Credo, Sobelow, and PostgreSQL. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-indigo white'>Elixir</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Phoenix</span><span class='f6 normal mr1 ph1 br2 bg-green white'>ExUnit</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Sobelow</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Credo</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Postgres</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Coveralls</span></div><div class='mt2 ba br2 b--blue bg-washed-blue pa2'><strong>ℹ️ Coveralls integration:</strong> This pipeline uploads test-coverage data to Coveralls. Add a <a href='https://docs.semaphoreci.com/using-semaphore/secrets' target='_blank'>project secret</a> named <code>coveralls</code> containing your <code>COVERALLS_REPO_TOKEN</code> so the upload step succeeds.</div>",
4+
"short_description": "Fullfeatured CI pipeline for Phoenix web applications",
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/phoenix_saas.yml",
1112
"workflow_tip": "other"

front/workflow_templates/saas_new/properties/python_docker.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Python",
3-
"description": "Run parallel tests for your Python app in Docker with PostgreSQL and Redis support. Uses Poetry for dependencies. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Python</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Poetry</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>pytest</span></div>",
4-
"short_description": "Run your Python suite",
2+
"title": "Python Docker CI/CD Pipeline",
3+
"description": "Set up your your Python app in a Docker environment with integrated linting, security checks, and automated Docker builds. Uses pip for dependency management and pytest for testing. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Python</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>pytest</span><span class='f6 normal mr1 ph1 br2 bg-red white'>flake8</span><span class='f6 normal mr1 ph1 br2 bg-yellow white'>Bandit</span></div>",
4+
"short_description": "Run Python CI/CD pipeline in Docker",
55
"group": "ci",
66
"language": "Python",
77
"environment": "docker",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-python.svg",
1011
"template_path": "templates/python_docker.yml",
1112
"workflow_tip": "other"

front/workflow_templates/saas_new/properties/python_saas.properties.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Python",
3-
"description": "Run quality checks and parallel tests for your Python app using Poetry for dependency management and pytest for testing. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Python</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Poetry</span><span class='f6 normal mr1 ph1 br2 bg-green white'>pytest</span></div>",
4-
"short_description": "Run your Python suite",
2+
"title": "Python CI/CD Pipeline",
3+
"description": "Set up your Python CI/CD pipeline with dependency caching, linting via flake8, security scanning with Bandit, parallelized unit and integration tests using pytest, and automated Docker image builds. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Python</span><span class='f6 normal mr1 ph1 br2 bg-green white'>pytest</span><span class='f6 normal mr1 ph1 br2 bg-red white'>flake8</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>Bandit</span><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Docker</span></div>",
4+
"short_description": "Run a comprehensive Python CI/CD",
55
"group": "ci",
66
"language": "Python",
77
"environment": "linux",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-python.svg",
1011
"template_path": "templates/python_saas.yml",
1112
"workflow_tip": "other"
Lines changed: 89 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,132 @@
1-
# This is a Semaphore configuration file for Phoenix projects using Docker
2-
# For more information about Semaphore configuration visit:
3-
# https://docs.semaphoreci.com/reference/pipeline-yaml-reference/
1+
version: v1.0 # Pipeline schema: https://docs.semaphoreci.com/reference/pipeline-yaml/
2+
name: "🔥 Phoenix CI Pipeline"
43

5-
version: v1.0 # Semaphore configuration version
6-
name: "🔥 Phoenix CI Pipeline" # Pipeline display name
4+
# ---------------------------------------------------------------------------
5+
# GLOBAL SETTINGS
6+
# ---------------------------------------------------------------------------
77

8-
# Define the machine type, OS image, and containers
98
agent:
109
machine:
1110
type: {{ machine_type }}
1211
os_image: {{ os_image }}
12+
containers: # Runtime & side‑service containers → https://docs.semaphoreci.com/reference/pipeline-yaml/#containers
13+
- name: main # Primary job container (Elixir + Node)
14+
image: 'registry.semaphoreci.com/elixir:1.16' # Image catalogue → https://docs.semaphoreci.com/using-semaphore/optimization/container-registry#convenience-and-language-images
15+
- name: postgres # Postgres DB for tests
16+
image: 'registry.semaphoreci.com/postgres:17'
17+
env_vars:
18+
- name: POSTGRES_PASSWORD
19+
value: postgres
20+
- name: POSTGRES_DB
21+
value: phoenix_test
1322

14-
containers:
15-
- name: main
16-
image: 'registry.semaphoreci.com/elixir:1.15' # Elixir 1.15 container
17-
- name: postgres
18-
image: registry.semaphoreci.com/postgres:17 # PostgreSQL 17 for database operations
19-
- name: redis
20-
image: registry.semaphoreci.com/redis:7.0 # Redis 7.0 for caching
21-
22-
# Configure when to stop the pipeline early
23-
fail_fast:
24-
stop:
25-
when: branch != 'main' # Stop all blocks if a job fails on non-main branches
2623
auto_cancel:
27-
running:
28-
when: branch != 'main' # Cancel running pipelines on non-main branches
2924
queued:
30-
when: branch = 'main' # Cancel queued pipelines on main branch
25+
when: 'true'
26+
27+
fail_fast:
28+
cancel:
29+
when: branch != 'main'
3130

32-
# Commands to run before each job
3331
global_job_config:
32+
env_vars:
33+
- name: MIX_ENV
34+
value: test
3435
prologue:
3536
commands:
36-
- checkout # Get the code from repository
37-
- mix local.hex --force # Install Hex package manager
38-
- mix local.rebar --force # Install rebar3 build tool
39-
- mix deps.get # Install dependencies
40-
- cache restore # Restore cached dependencies
37+
- checkout # Fetch repo at current commit
38+
- cache restore # Restore cached deps & _build
39+
40+
# ---------------------------------------------------------------------------
41+
# BLOCKS
42+
# ---------------------------------------------------------------------------
4143

42-
# Pipeline blocks represent groups of jobs that can run in parallel
4344
blocks:
44-
# Block for setting up dependencies and caching
45-
- name: "🛠️ Setup and Cache"
46-
dependencies: []
45+
# ⚙️ Block 1: Install dependencies & compile – caches Hex/Rebar & JS assets
46+
- name: "⚙️ Install & Compile"
4747
task:
4848
jobs:
49-
- name: "📦 Install Dependencies"
49+
- name: "⚙️ Install & Compile"
5050
commands:
51-
- mix deps.compile # Compile dependencies
52-
- mix compile # Compile project
53-
- npm ci --prefix assets # Install Node.js dependencies
54-
- cache store # Cache dependencies for future runs
51+
- mix local.hex --force
52+
- mix local.rebar --force
53+
- mix deps.get # Fetch project dependencies
54+
- mix compile
55+
- npm install --prefix assets # Install JS dependencies for Phoenix assets
56+
- cache store # Cache deps & build artefacts
5557

56-
# Block for asset compilation
58+
# 🎨 Block 2: Build & digest front‑end assets
5759
- name: "🎨 Assets"
58-
dependencies: ["🛠️ Setup and Cache"]
60+
dependencies: ["⚙️ Install & Compile"]
5961
task:
6062
jobs:
6163
- name: "🖌️ Compile Assets"
6264
commands:
63-
- npm run deploy --prefix assets # Build and digest assets
64-
- mix phx.digest # Digest and compress static files
65+
- npm run deploy --prefix assets # Build production JS/CSS bundle
66+
- mix phx.digest # Generate digested asset fingerprints
6567

66-
# Block for code quality checks
67-
- name: "🔍 Code Quality"
68-
dependencies: ["🛠️ Setup and Cache"]
68+
# 🔍 Block 3: Static analysis – format, Credo, Dialyzer
69+
- name: "🔍 Static Analysis"
70+
dependencies: ["⚙️ Install & Compile"]
6971
task:
7072
jobs:
71-
- name: "✨ Lint and Format"
73+
- name: "🖌️ Format Check"
7274
commands:
73-
- mix format --check-formatted # Check code formatting
74-
- mix credo --strict # Run static code analysis
75-
- cd assets && npm run lint # Check JavaScript code
76-
77-
# Block for security checks
78-
- name: "🔐 Security Checks"
79-
dependencies: ["🛠️ Setup and Cache"]
80-
task:
81-
jobs:
82-
- name: "🛡️ Security Scan"
75+
- mix format --check-formatted
76+
- name: "🕵️ Credo Lint"
77+
commands:
78+
- mix credo --strict
79+
- name: "🧠 Dialyzer"
8380
commands:
84-
- mix deps.audit # Check Elixir dependencies
85-
- mix sobelow --config # Run security-focused static analysis
86-
- cd assets && npm audit # Check Node.js dependencies
81+
- mix dialyzer --halt-exit-status
8782

88-
# Block for type checking
89-
- name: "📊 Dialyzer"
90-
dependencies: ["🛠️ Setup and Cache"]
83+
# 🛡️ Block 4: Security scans – dependency & code audits
84+
- name: "🛡️ Security"
85+
dependencies: ["⚙️ Install & Compile"]
9186
task:
9287
jobs:
93-
- name: "🔎 Type Checking"
88+
- name: "🛡️ Sobelow & Audits"
9489
commands:
95-
- mix dialyzer # Run static type checking
90+
- mix deps.audit # Hex deps audit
91+
- mix sobelow --exit # Phoenix-specific security scan
92+
- npm audit --audit-level=moderate --prefix assets
9693

97-
# Block for running tests
98-
- name: "🧪 Test Suite"
99-
dependencies: ["🛠️ Setup and Cache", "🎨 Assets"]
94+
# 🧪 Block 5: Tests (unit & integration) – depends only on security
95+
- name: "🧪 Tests"
96+
dependencies: ["🛡️ Security"]
10097
task:
10198
env_vars:
102-
- name: MIX_ENV
103-
value: test
10499
- name: DATABASE_URL
105-
value: postgresql://postgres@postgres:5432/app_test # Use container hostname
106-
- name: REDIS_URL
107-
value: redis://redis:6379 # Use container hostname
100+
value: "postgres://postgres:postgres@postgres:5432/phoenix_test" # Host "postgres" resolves to DB side‑container
108101
jobs:
109-
- name: "🟢 ExUnit Tests"
110-
parallelism: 4 # Run tests in parallel
102+
- name: "🧪 Unit Tests"
111103
commands:
112-
- mix ecto.create # Create test database
113-
- mix ecto.migrate # Run database migrations
114-
- mix test --cover # Run tests with coverage
104+
- mix deps.get # Fetch project dependencies
105+
- mix test --exclude integration --cover --export-coverage unit \
106+
--formatter ExUnit.CLIFormatter \
107+
--formatter JUnitFormatter \
108+
--junit-report-file test_results/unit.xml
109+
- test-results gen-suite-report # Publish per‑suite report → https://docs.semaphoreci.com/using-semaphore/tests/test-reports --name "Unit Tests" --format junit --path test_results/unit.xml
115110

116-
# Block for browser tests
117-
- name: "🌐 Browser Tests"
118-
dependencies: ["🧪 Test Suite"]
119-
task:
120-
jobs:
121-
- name: "🎭 Wallaby Tests"
111+
- name: "🔬 Integration Tests"
122112
commands:
123-
- mix wallaby.install # Install browser testing dependencies
124-
- mix test --only browser:true # Run browser tests
113+
- mix deps.get # Fetch project dependencies
114+
- mix test --only integration --cover --export-coverage integration \
115+
--formatter ExUnit.CLIFormatter \
116+
--formatter JUnitFormatter \
117+
--junit-report-file test_results/integration.xml
118+
- test-results gen-suite-report # Publish per‑suite report → https://docs.semaphoreci.com/using-semaphore/tests/test-reports --name "Integration Tests" --format junit --path test_results/integration.xml
125119

126-
# Block for deployment checks
127-
- name: "🚀 Deploy Checks"
128-
dependencies: ["🧪 Test Suite"]
129-
task:
130-
jobs:
131-
- name: "🔄 Migration Safety"
132-
commands:
133-
- mix ecto.migrations # Check pending migrations
134-
- mix phx.routes # Check route definitions
135-
- name: "📦 Release Build"
136-
commands:
137-
- MIX_ENV=prod mix release --dry-run # Test release building
120+
# ---------------------------------------------------------------------------
121+
# AFTER PIPELINE – coverage & reports
122+
# ---------------------------------------------------------------------------
138123

139-
# Block for Docker image
140-
- name: "🐳 Docker"
141-
dependencies: ["🚀 Deploy Checks"]
142-
task:
143-
secrets:
144-
- name: dockerhub-credentials
145-
jobs:
146-
- name: "📦 Build and Push"
147-
commands:
148-
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
149-
- docker build -t "${DOCKER_USERNAME}/phoenix-app:${SEMAPHORE_GIT_SHA:0:7}" .
150-
- docker push "${DOCKER_USERNAME}/phoenix-app:${SEMAPHORE_GIT_SHA:0:7}"
124+
after_pipeline:
125+
task:
126+
secrets:
127+
- name: coveralls # COVERALLS_REPO_TOKEN
128+
jobs:
129+
- name: "📤 Upload Coverage & Reports"
130+
commands:
131+
- mix coveralls.semaphore --exclude integration --import-cover cover # Upload coverage → https://github.com/parroty/excoveralls
132+
- test-results gen-pipeline-report # Aggregate & publish test reports → https://docs.semaphoreci.com/using-semaphore/tests/test-reports

0 commit comments

Comments
 (0)