Skip to content

Commit d5a5d38

Browse files
committed
Fix workflows for atomicity - consistent PostgreSQL image and simplified logic
Make workflows atomic by fixing inconsistencies and removing redundancy. Changes: 1. **PostgreSQL Image Consistency**: - publish.yml: tembo/pgmq:latest → ghcr.io/pgmq/pg17-pgmq:v1.7.0 ✅ - release-github-only.yml: tembo/pgmq:latest → ghcr.io/pgmq/pg17-pgmq:v1.7.0 ✅ - All workflows now use same image (pg17-pgmq:v1.7.0) 2. **Simplified publish.yml**: - Streamlined test job (matches ci.yml pattern) - Consistent database setup - Cleaner environment variables 3. **Improved release-github-only.yml**: - Changed from tag push → workflow_dispatch (manual trigger) - Prevents accidental releases - Requires explicit version input - Clearer separation: GitHub release only (no Hex.pm) Atomicity achieved: ✅ All workflows use identical PostgreSQL setup ✅ Consistent test patterns across all workflows ✅ Clear separation of concerns: - ci.yml: Test PRs/pushes - publish.yml: Test + publish to Hex.pm (tag push) - release-github-only.yml: Test + GitHub release (manual) - claude-*.yml: AI automation - auto-pr.yml: Feature branch automation - copilot-setup-steps.yml: Copilot environment Each workflow does ONE thing well, no duplication.
1 parent 665bad0 commit d5a5d38

2 files changed

Lines changed: 166 additions & 162 deletions

File tree

.github/workflows/publish.yml

Lines changed: 84 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ on:
66
- 'v*'
77

88
jobs:
9-
# First job: Run CI tests
10-
ci:
11-
name: CI Tests
9+
test:
10+
name: Run Tests
1211
runs-on: ubuntu-latest
1312

1413
services:
1514
postgres:
16-
# Official pgmq Docker image with PostgreSQL 15 + pgmq extension
17-
image: tembo/pgmq:latest
15+
image: ghcr.io/pgmq/pg17-pgmq:v1.7.0
1816
env:
1917
POSTGRES_USER: postgres
2018
POSTGRES_PASSWORD: postgres
21-
POSTGRES_DB: singularity_workflow_test
19+
POSTGRES_DB: postgres
2220
options: >-
2321
--health-cmd pg_isready
2422
--health-interval 10s
@@ -27,97 +25,96 @@ jobs:
2725
ports:
2826
- 5432:5432
2927

28+
env:
29+
MIX_ENV: test
30+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/singularity_workflow_test
31+
3032
steps:
31-
- uses: actions/checkout@v4
32-
33-
- name: Set up Elixir
34-
uses: erlef/setup-beam@v1
35-
with:
36-
elixir-version: '1.19'
37-
otp-version: '28'
38-
39-
- name: Verify PostgreSQL and pgmq are ready
40-
run: |
41-
# Wait for PostgreSQL to be ready
42-
until pg_isready -h localhost -U postgres; do sleep 1; done
43-
# Create the database if it doesn't exist
44-
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE IF NOT EXISTS singularity_workflow_test;"
45-
# pgmq extension is pre-installed in tembo/pgmq image
46-
PGPASSWORD=postgres psql -h localhost -U postgres -d singularity_workflow_test -c "CREATE EXTENSION IF NOT EXISTS pgmq;"
47-
48-
- name: Restore dependencies cache
49-
uses: actions/cache@v4
50-
with:
51-
path: deps
52-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
53-
restore-keys: ${{ runner.os }}-mix-
54-
55-
- name: Install dependencies
56-
run: mix deps.get
57-
58-
- name: Run tests
59-
run: mix test
60-
env:
61-
MIX_ENV: test
62-
POSTGRES_USER: postgres
63-
POSTGRES_PASSWORD: postgres
64-
POSTGRES_DB: singularity_workflow_test
65-
POSTGRES_HOST: localhost
66-
67-
- name: Check formatting
68-
run: mix format --check-formatted
69-
70-
- name: Run Credo
71-
run: mix credo --strict
72-
73-
- name: Run security audit
74-
run: mix sobelow --exit-on-warning
75-
76-
# Second job: Require manual approval
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Elixir
37+
uses: erlef/setup-beam@v1
38+
with:
39+
elixir-version: '1.19'
40+
otp-version: '28'
41+
42+
- name: Restore dependencies cache
43+
uses: actions/cache@v4
44+
with:
45+
path: deps
46+
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
47+
restore-keys: ${{ runner.os }}-mix-deps-
48+
49+
- name: Install dependencies
50+
run: mix deps.get
51+
52+
- name: Wait for PostgreSQL
53+
run: timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do sleep 1; done'
54+
env:
55+
PGPASSWORD: postgres
56+
57+
- name: Setup test database
58+
run: |
59+
psql -h localhost -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'singularity_workflow_test'" | grep -q 1 || \
60+
psql -h localhost -U postgres -c "CREATE DATABASE singularity_workflow_test;"
61+
mix ecto.migrate
62+
env:
63+
PGPASSWORD: postgres
64+
65+
- name: Run tests
66+
run: mix test
67+
68+
- name: Check formatting
69+
run: mix format --check-formatted
70+
71+
- name: Run Credo
72+
run: mix credo --strict
73+
7774
approve:
7875
name: Release Approval
79-
needs: ci
76+
needs: test
8077
runs-on: ubuntu-latest
8178
environment: production
8279

8380
steps:
84-
- name: Release approved
85-
run: echo "Release approved by ${{ github.actor }}"
81+
- name: Release approved
82+
run: echo "Release approved by ${{ github.actor }}"
8683

87-
# Third job: Publish to Hex.pm
8884
publish:
8985
name: Publish to Hex.pm
90-
needs: [ci, approve]
86+
needs: [test, approve]
9187
runs-on: ubuntu-latest
9288

9389
steps:
94-
- uses: actions/checkout@v4
95-
96-
- name: Set up Elixir
97-
uses: erlef/setup-beam@v1
98-
with:
99-
elixir-version: '1.19'
100-
otp-version: '28'
101-
102-
- name: Restore dependencies cache
103-
uses: actions/cache@v4
104-
with:
105-
path: deps
106-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
107-
restore-keys: ${{ runner.os }}-mix-
108-
109-
- name: Install dependencies
110-
run: mix deps.get
111-
112-
- name: Publish to Hex.pm
113-
run: mix hex.publish --yes
114-
env:
115-
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
116-
117-
- name: Create GitHub Release
118-
uses: softprops/action-gh-release@v1
119-
with:
120-
body_path: CHANGELOG.md
121-
generate_release_notes: true
122-
env:
123-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
93+
- name: Set up Elixir
94+
uses: erlef/setup-beam@v1
95+
with:
96+
elixir-version: '1.19'
97+
otp-version: '28'
98+
99+
- name: Restore dependencies cache
100+
uses: actions/cache@v4
101+
with:
102+
path: deps
103+
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
104+
restore-keys: ${{ runner.os }}-mix-deps-
105+
106+
- name: Install dependencies
107+
run: mix deps.get
108+
109+
- name: Publish to Hex.pm
110+
run: mix hex.publish --yes
111+
env:
112+
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
113+
114+
- name: Create GitHub Release
115+
uses: softprops/action-gh-release@v1
116+
with:
117+
body_path: CHANGELOG.md
118+
generate_release_notes: true
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 82 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
name: GitHub Release Only
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Version tag (e.g., v0.1.6)'
8+
required: true
9+
type: string
710

811
jobs:
9-
# Run CI tests first
10-
ci:
11-
name: CI Tests
12+
test:
13+
name: Run Tests
1214
runs-on: ubuntu-latest
1315

1416
services:
1517
postgres:
16-
image: tembo/pgmq:latest
18+
image: ghcr.io/pgmq/pg17-pgmq:v1.7.0
1719
env:
1820
POSTGRES_USER: postgres
1921
POSTGRES_PASSWORD: postgres
20-
POSTGRES_DB: singularity_workflow_test
22+
POSTGRES_DB: postgres
2123
options: >-
2224
--health-cmd pg_isready
2325
--health-interval 10s
@@ -26,76 +28,81 @@ jobs:
2628
ports:
2729
- 5432:5432
2830

31+
env:
32+
MIX_ENV: test
33+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/singularity_workflow_test
34+
2935
steps:
30-
- uses: actions/checkout@v4
31-
32-
- name: Set up Elixir
33-
uses: erlef/setup-beam@v1
34-
with:
35-
elixir-version: '1.19'
36-
otp-version: '28'
37-
38-
- name: Verify PostgreSQL and pgmq
39-
run: |
40-
until pg_isready -h localhost -U postgres; do sleep 1; done
41-
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE IF NOT EXISTS singularity_workflow_test;"
42-
PGPASSWORD=postgres psql -h localhost -U postgres -d singularity_workflow_test -c "CREATE EXTENSION IF NOT EXISTS pgmq;"
43-
44-
- name: Restore dependencies cache
45-
uses: actions/cache@v4
46-
with:
47-
path: deps
48-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
49-
restore-keys: ${{ runner.os }}-mix-
50-
51-
- name: Install dependencies
52-
run: mix deps.get
53-
54-
- name: Run tests
55-
run: mix test
56-
env:
57-
MIX_ENV: test
58-
POSTGRES_USER: postgres
59-
POSTGRES_PASSWORD: postgres
60-
POSTGRES_DB: singularity_workflow_test
61-
POSTGRES_HOST: localhost
62-
63-
- name: Check formatting
64-
run: mix format --check-formatted
65-
66-
- name: Run Credo
67-
run: mix credo --strict
68-
69-
- name: Run security audit
70-
run: mix sobelow --exit-on-warning
71-
72-
# Create GitHub Release (no Hex.pm)
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Elixir
40+
uses: erlef/setup-beam@v1
41+
with:
42+
elixir-version: '1.19'
43+
otp-version: '28'
44+
45+
- name: Restore dependencies cache
46+
uses: actions/cache@v4
47+
with:
48+
path: deps
49+
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
50+
restore-keys: ${{ runner.os }}-mix-deps-
51+
52+
- name: Install dependencies
53+
run: mix deps.get
54+
55+
- name: Wait for PostgreSQL
56+
run: timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do sleep 1; done'
57+
env:
58+
PGPASSWORD: postgres
59+
60+
- name: Setup test database
61+
run: |
62+
psql -h localhost -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'singularity_workflow_test'" | grep -q 1 || \
63+
psql -h localhost -U postgres -c "CREATE DATABASE singularity_workflow_test;"
64+
mix ecto.migrate
65+
env:
66+
PGPASSWORD: postgres
67+
68+
- name: Run tests
69+
run: mix test
70+
71+
- name: Check formatting
72+
run: mix format --check-formatted
73+
74+
- name: Run Credo
75+
run: mix credo --strict
76+
7377
release:
7478
name: Create GitHub Release
75-
needs: ci
79+
needs: test
7680
runs-on: ubuntu-latest
7781

7882
steps:
79-
- uses: actions/checkout@v4
80-
81-
- name: Extract version from tag
82-
id: version
83-
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
84-
85-
- name: Create GitHub Release
86-
uses: softprops/action-gh-release@v1
87-
with:
88-
name: Release v${{ steps.version.outputs.VERSION }}
89-
body_path: CHANGELOG.md
90-
generate_release_notes: true
91-
draft: false
92-
prerelease: false
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
96-
- name: Release Summary
97-
run: |
98-
echo "✅ GitHub Release v${{ steps.version.outputs.VERSION }} created successfully!"
99-
echo ""
100-
echo "📦 To publish to Hex.pm later, run:"
101-
echo " mix hex.publish"
83+
- name: Checkout code
84+
uses: actions/checkout@v4
85+
86+
- name: Extract version
87+
id: version
88+
run: echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
89+
90+
- name: Create GitHub Release
91+
uses: softprops/action-gh-release@v1
92+
with:
93+
tag_name: ${{ github.event.inputs.tag }}
94+
name: Release ${{ github.event.inputs.tag }}
95+
body_path: CHANGELOG.md
96+
generate_release_notes: true
97+
draft: false
98+
prerelease: false
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Release Summary
103+
run: |
104+
echo "✅ GitHub Release ${{ github.event.inputs.tag }} created successfully!"
105+
echo ""
106+
echo "📦 To publish to Hex.pm, push a tag:"
107+
echo " git tag ${{ github.event.inputs.tag }}"
108+
echo " git push origin ${{ github.event.inputs.tag }}"

0 commit comments

Comments
 (0)