1- name : " Copilot Setup Steps "
1+ name : CI
22
3- # Automatically run the setup steps when they are changed to allow for easy validation, and
4- # allow manual testing through the repository's "Actions" tab
53on :
6- workflow_dispatch :
74 push :
8- paths :
9- - .github/workflows/copilot-setup-steps.yml
5+ branches : [main]
106 pull_request :
11- paths :
12- - .github/workflows/copilot-setup-steps.yml
7+ branches : [main]
8+ workflow_dispatch :
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
1313
1414jobs :
15- # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16- copilot-setup-steps :
15+ test :
16+ name : Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }})
17+ runs-on : ubuntu-latest
18+
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ elixir : ['1.19']
23+ otp : ['28']
24+
25+ permissions :
26+ contents : read
27+ checks : write
28+
29+ services :
30+ postgres :
31+ image : ghcr.io/pgmq/pg17-pgmq:v1.7.0
32+ env :
33+ POSTGRES_USER : postgres
34+ POSTGRES_PASSWORD : postgres
35+ POSTGRES_DB : postgres
36+ options : >-
37+ --health-cmd pg_isready
38+ --health-interval 10s
39+ --health-timeout 5s
40+ --health-retries 5
41+ ports :
42+ - 5432:5432
43+
44+ env :
45+ MIX_ENV : test
46+ DATABASE_URL : postgresql://postgres:postgres@localhost:5432/singularity_workflow_test
47+
48+ steps :
49+ - name : Checkout code
50+ uses : actions/checkout@v4
51+
52+ - name : Set up Elixir
53+ uses : erlef/setup-beam@v1
54+ with :
55+ elixir-version : ${{ matrix.elixir }}
56+ otp-version : ${{ matrix.otp }}
57+
58+ - name : Restore dependencies cache
59+ uses : actions/cache@v4
60+ with :
61+ path : deps
62+ key : ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
63+ restore-keys : ${{ runner.os }}-mix-deps-
64+
65+ - name : Restore build cache
66+ uses : actions/cache@v4
67+ with :
68+ path : _build
69+ key : ${{ runner.os }}-mix-build-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
70+ restore-keys : |
71+ ${{ runner.os }}-mix-build-${{ matrix.elixir }}-${{ matrix.otp }}-
72+
73+ - name : Install dependencies
74+ run : mix deps.get
75+
76+ - name : Compile dependencies
77+ run : mix deps.compile
78+
79+ - name : Compile application (warnings as errors)
80+ run : mix compile --warnings-as-errors
81+
82+ - name : Wait for PostgreSQL
83+ run : |
84+ timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do sleep 1; done'
85+ env :
86+ PGPASSWORD : postgres
87+
88+ - name : Setup test database
89+ run : |
90+ psql -h localhost -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'singularity_workflow_test'" | grep -q 1 || \
91+ psql -h localhost -U postgres -c "CREATE DATABASE singularity_workflow_test;"
92+ mix ecto.migrate
93+ env :
94+ PGPASSWORD : postgres
95+
96+ - name : Run tests
97+ run : mix test --trace
98+
99+ quality :
100+ name : Code Quality
101+ runs-on : ubuntu-latest
102+
103+ permissions :
104+ contents : read
105+
106+ steps :
107+ - name : Checkout code
108+ uses : actions/checkout@v4
109+
110+ - name : Set up Elixir
111+ uses : erlef/setup-beam@v1
112+ with :
113+ elixir-version : ' 1.19'
114+ otp-version : ' 28'
115+
116+ - name : Restore dependencies cache
117+ uses : actions/cache@v4
118+ with :
119+ path : deps
120+ key : ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
121+ restore-keys : ${{ runner.os }}-mix-deps-
122+
123+ - name : Restore build cache
124+ uses : actions/cache@v4
125+ with :
126+ path : _build
127+ key : ${{ runner.os }}-mix-build-quality-${{ hashFiles('**/mix.lock') }}
128+ restore-keys : ${{ runner.os }}-mix-build-quality-
129+
130+ - name : Restore PLT cache
131+ uses : actions/cache@v4
132+ with :
133+ path : priv/plts
134+ key : ${{ runner.os }}-plt-${{ hashFiles('**/mix.lock') }}
135+ restore-keys : ${{ runner.os }}-plt-
136+
137+ - name : Install dependencies
138+ run : mix deps.get
139+
140+ - name : Check code formatting
141+ run : mix format --check-formatted
142+
143+ - name : Run Credo (strict)
144+ run : mix credo --strict
145+
146+ - name : Run Dialyzer
147+ run : mix dialyzer --format github
148+
149+ - name : Run Sobelow security scan
150+ run : mix sobelow --exit-on-warning --skip
151+
152+ - name : Audit dependencies
153+ run : mix deps.audit
154+
155+ coverage :
156+ name : Test Coverage
17157 runs-on : ubuntu-latest
18158
19- # Set the permissions to the lowest permissions possible needed for your steps.
20- # Copilot will be given its own token for its operations.
21159 permissions :
22- # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
23160 contents : read
24161
25162 services :
26163 postgres :
27- # Use official pgmq image with PostgreSQL 17 and pgmq pre-installed
28- # pgmq is REQUIRED for task coordination and queue management
29164 image : ghcr.io/pgmq/pg17-pgmq:v1.7.0
30165 env :
31166 POSTGRES_USER : postgres
@@ -39,8 +174,10 @@ jobs:
39174 ports :
40175 - 5432:5432
41176
42- # You can define any steps you want, and they will run before the agent starts.
43- # If you do not check out your code, Copilot will do this for you.
177+ env :
178+ MIX_ENV : test
179+ DATABASE_URL : postgresql://postgres:postgres@localhost:5432/singularity_workflow_test
180+
44181 steps :
45182 - name : Checkout code
46183 uses : actions/checkout@v4
@@ -51,29 +188,45 @@ jobs:
51188 elixir-version : ' 1.19'
52189 otp-version : ' 28'
53190
54- - name : Restore Elixir dependencies cache
191+ - name : Restore dependencies cache
55192 uses : actions/cache@v4
56193 with :
57194 path : deps
58- key : ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
59- restore-keys : ${{ runner.os }}-mix-
195+ key : ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
196+ restore-keys : ${{ runner.os }}-mix-deps-
197+
198+ - name : Restore build cache
199+ uses : actions/cache@v4
200+ with :
201+ path : _build
202+ key : ${{ runner.os }}-mix-build-test-${{ hashFiles('**/mix.lock') }}
203+ restore-keys : ${{ runner.os }}-mix-build-test-
60204
61- - name : Install Elixir dependencies
205+ - name : Install dependencies
62206 run : mix deps.get
63207
64- - name : Wait for PostgreSQL and create test database
208+ - name : Wait for PostgreSQL
65209 run : |
66- # Wait for PostgreSQL to be ready
67- timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do echo "Waiting for postgres..."; sleep 1; done'
68- sleep 1
210+ timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do sleep 1; done'
211+ env :
212+ PGPASSWORD : postgres
69213
70- # Create test database idempotently
71- psql -h localhost -p 5432 -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'singularity_workflow_test'" | grep -q 1 || psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE singularity_workflow_test;"
214+ - name : Setup test database
215+ run : |
216+ psql -h localhost -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'singularity_workflow_test'" | grep -q 1 || \
217+ psql -h localhost -U postgres -c "CREATE DATABASE singularity_workflow_test;"
218+ mix ecto.migrate
72219 env :
73220 PGPASSWORD : postgres
74221
75- - name : Run migrations
76- run : mix ecto.migrate
222+ - name : Run tests with coverage
223+ run : mix coveralls.json
224+
225+ - name : Upload coverage to Codecov
226+ uses : codecov/codecov-action@v4
227+ with :
228+ files : ./cover/excoveralls.json
229+ flags : unittests
230+ fail_ci_if_error : false
77231 env :
78- MIX_ENV : test
79- DATABASE_URL : " postgresql://postgres:postgres@localhost:5432/singularity_workflow_test"
232+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
0 commit comments