Skip to content

Instantly share code, notes, and snippets.

@ChristianAlexander
Last active June 13, 2025 07:44
Show Gist options
  • Save ChristianAlexander/d7318edcc21e7951ec1fc119895762ce to your computer and use it in GitHub Desktop.
Save ChristianAlexander/d7318edcc21e7951ec1fc119895762ce to your computer and use it in GitHub Desktop.
Setup Steps for Copilot Coding Agent in Phoenix Apps

Setup Steps

Workflow File

Add copilot-setup-steps.yml to your .github/workflows directory so Copilot Coding Agent doesn’t get lost trying to set up Elixir and Erlang.

This also ensures a postgres database is running, which is helpful for Phoenix apps out of the box.

Dependencies are cached to make the agent start up quickly, as well as saving on metered GitHub Actions compute time.

Copilot Instructions

Add copilot-instructions.md to your .github directory to provide instructions to the agent.

These instructions provide a simple baseline, establishing the expectation to format code and describing how to run tests / do basic troubleshooting.

Running Tests

To run the test suite:

mix test

Troubleshooting

Database Connection Issues

If you encounter database connection issues, ensure:

  • The database user has the correct credentials (username: postgres, password: postgres)
  • The database exists (created by mix ecto.create or mix setup)

Asset Build Issues

If assets fail to build, try:

mix assets.setup
mix assets.build

Formatting

Make sure all of the code is properly formatted according to Elixir styles.

You can format the code using:

mix format --check-formatted
name: Copilot Setup Steps
on: workflow_dispatch
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read
# Set up a Postgres DB service. By default, Phoenix applications
# use Postgres. This creates a database for running tests.
# Additional services can be defined here if required.
services:
db:
image: postgres:17
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# Step: Setup Elixir + Erlang image as the base.
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: "27.3.4"
elixir-version: "1.18.4"
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v4
# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install dependencies
run: mix deps.get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment