Guelor
I’m still new to GitHub action. I’m running a Phoenix/Elixir project, In my config file, I have the following configuration for the test:
# Set HTTPClientMock as the HTTP client for the PayService
config :sender_service, :pay_service,
http_client: SenderService.HTTPClientMock,
url: System.get_env("PAY_URL"),
secret_key: System.get_env("PAY_SECRET_KEY"),
api_key: System.get_env("PAY_API_KEY")
and this a snippet of the test:
defmodule SenderService.PayServiceTest do
use ExUnit.Case, async: true
alias SenderService.PayService
import Mox
describe "pay_service" do
@http_client SenderService.HTTPClientMock
test "get_balances returns a list of balances" do
url = System.get_env("PAY_URL") <> "/v1/accounts/balances"
list_balances_body = [
%{
balance: "0.00000000",
holdAmount: "0.00000000",
productSymbol: "USD"
}
]
expect(@http_client, :get, fn actual_url, actual_headers ->
assert actual_url == "https://uat-pay-api.com/v1/accounts/balances"
# Check that Authorization header is present
authorization_header = List.keyfind(actual_headers, "Authorization", 0)
assert authorization_header != nil
{:ok, %HTTPoison.Response{body: list_balances_body |> Jason.encode!(), status_code: 200}}
end)
assert {:ok, balances} = PayService.get_balances()
expected_balances = [
%{
"balance" => "0.00000000",
"holdAmount" => "0.00000000",
"productSymbol" => "USD"
}
]
assert expected_balances == balances
Mox.verify!(@http_client)
end
end
end
which works locally with the config/test.exs file that I provide. But I’m getting the following error on GitHub action:
- test pay_service get_balances returns a list of balances ( SenderService.PayServiceTest)
Error: test/sender_service/pay_service_test.exs:11
** (ArgumentError) construction of binary failed: segment 1 of type ‘binary’: expected a binary but got: nil
code: url = System.get_env(“PAY_URL”) <> “/v1/accounts/balances”
stacktrace:
test/sender_service/pay_service_test.exs:12: (test)
I attempted to add the environment variables to both the “Actions secrets and variables” on GitHub, but I’m still encountering the error mentioned above. Am I missing something? Below are the “.yml” files for the workflow:
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Elixir CI
on:
push:
jobs:
verify:
# 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.
runs-on: ubuntu-latest
strategy:
# Specify the OTP and Elixir versions to use when building
# and running the workflow steps.
matrix:
otp: [25.0.4] # Define the OTP version [required]
elixir: [1.14.3] # Define the elixir version [required]
services:
db:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: sender_service_dev
ports: ['5432:5432']
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: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v3
# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: deps-cache
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
# 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: build-cache
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-build-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install deps
run: |
mix deps.get
# Step: Check that the checked in code has already been formatted.
# This step fails if something was found unformatted.
- name: Check Formatting
run: mix format --check-formatted
# Step: Execute the tests
- name: Run tests
run: mix test
# deploy:
# # only run this job if the verify job succeeds
# needs: verify
# # only run this job if the workflow is running on the master branch
# if: github.ref == 'refs/heads/master'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# # actions/checkout@v2 only checks out the latest commit,
# # so we need to tell it to check out the entire master branch
# with:
# ref: master
# fetch-depth: 0
# # configure the gigalixir-actions with our credentials and app name
# - uses: mhanberg/gigalixir-action@v0.1.0
# with:
# GIGALIXIR_USERNAME: ${{ secrets.GIGALIXIR_USERNAME }}
# GIGALIXIR_PASSWORD: ${{ secrets.GIGALIXIR_PASSWORD }}
# GIGALIXIR_APP: ${{ secrets.GIGALIXIR_APP }}
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
Any help on this would be deeply appreciated, thanks! ![]()
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming









