Skip to content

Commit

Permalink
copy paste ci file
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Oct 10, 2024
1 parent 86cc275 commit d35d746
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# Trigger the workflow on any pull request
pull_request:

env:
MIX_ENV: test
ELIXIR_VERSION_SPEC: "1.15.7"
OTP_VERSION_SPEC: "26.0.2"
permissions: read-all

jobs:
Expand Down Expand Up @@ -37,3 +41,28 @@ jobs:
with:
file: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
credo:
name: Credo
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/[email protected]
with:
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
otp-version: ${{ env.OTP_VERSION_SPEC }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Run tests
run: mix coveralls.json
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: coverage/excoveralls.json
token: ${{ secrets.CODECOV_TOKEN }}
135 changes: 135 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Elixir CI

on: [push, pull_request]
env:
MIX_ENV: test
ELIXIR_VERSION_SPEC: "1.15.7"
OTP_VERSION_SPEC: "26.0.2"

jobs:
compile:
name: Compile
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/[email protected]
with:
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
otp-version: ${{ env.OTP_VERSION_SPEC }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Compile
run: mix compile --warnings-as-errors

test:
name: Test
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./backend


services:
invoices_control_db_test:
image: postgres:latest
ports: ['5432:5432']
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: 'trust'
POSTGRES_DB: invoices_control_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MIX_ENV: test

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/[email protected]
with:
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
otp-version: ${{ env.OTP_VERSION_SPEC }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Setup database
env:
MIX_ENV: test
PGHOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
run:
mix ecto.drop
mix ecto.create
mix ecto.migrate
- name: Run tests
env:
MIX_ENV: test
PGHOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
run:
mix test

check-formatted:
name: Check Formatted
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend


steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/[email protected]
with:
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
otp-version: ${{ env.OTP_VERSION_SPEC }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Check formatted
run: mix format --check-formatted

credo:
name: Credo
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend


steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/[email protected]
with:
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
otp-version: ${{ env.OTP_VERSION_SPEC }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Run credo
run: mix credo --strict
3 changes: 3 additions & 0 deletions backend/lib/peach/event.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule Peach.Event do
@moduledoc """
Defines an event object for the peach app
"""
use Ecto.Schema
import Ecto.Changeset

Expand Down
5 changes: 4 additions & 1 deletion backend/lib/peach/events.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
defmodule Events do
alias Peach.Repo
@moduledoc """
Manages the events for the peach app
"""
alias Peach.Event
alias Peach.Repo

@doc """
Creates an event with the given attributes.
Expand Down
3 changes: 3 additions & 0 deletions backend/lib/peach/ticket.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule Peach.Ticket do
@moduledoc """
Defines a ticket for the peach app
"""
use Ecto.Schema
import Ecto.Changeset

Expand Down
3 changes: 3 additions & 0 deletions backend/lib/peach/ticket_tier.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule Peach.TicketTier do
@moduledoc """
Defines a ticket tier for the peach app
"""
use Ecto.Schema
import Ecto.Changeset

Expand Down
9 changes: 8 additions & 1 deletion backend/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ defmodule Peach.MixProject do
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coveralls: :test,
"coveralls.json": :test
],
aliases: aliases(),
deps: deps()
]
Expand Down Expand Up @@ -44,7 +49,9 @@ defmodule Peach.MixProject do
{:gettext, "~> 0.20"},
{:jason, "~> 1.2"},
{:dns_cluster, "~> 0.1.1"},
{:bandit, "~> 1.5"}
{:bandit, "~> 1.5"},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.18", only: [:test]}
]
end

Expand Down
4 changes: 4 additions & 0 deletions backend/mix.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
%{
"bandit": {:hex, :bandit, "1.5.7", "6856b1e1df4f2b0cb3df1377eab7891bec2da6a7fd69dc78594ad3e152363a50", [:mix], [{:hpax, "~> 1.0.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "f2dd92ae87d2cbea2fa9aa1652db157b6cba6c405cb44d4f6dd87abba41371cd"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"castore": {:hex, :castore, "1.0.9", "5cc77474afadf02c7c017823f460a17daa7908e991b0cc917febc90e466a375c", [:mix], [], "hexpm", "5ea956504f1ba6f2b4eb707061d8e17870de2bee95fb59d512872c2ef06925e7"},
"credo": {:hex, :credo, "1.7.8", "9722ba1681e973025908d542ec3d95db5f9c549251ba5b028e251ad8c24ab8c5", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cb9e87cc64f152f3ed1c6e325e7b894dea8f5ef2e41123bd864e3cd5ceb44968"},
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"dns_cluster": {:hex, :dns_cluster, "0.1.3", "0bc20a2c88ed6cc494f2964075c359f8c2d00e1bf25518a6a6c7fd277c9b0c66", [:mix], [], "hexpm", "46cb7c4a1b3e52c7ad4cbe33ca5079fbde4840dedeafca2baf77996c2da1bc33"},
"ecto": {:hex, :ecto, "3.12.3", "1a9111560731f6c3606924c81c870a68a34c819f6d4f03822f370ea31a582208", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9efd91506ae722f95e48dc49e70d0cb632ede3b7a23896252a60a14ac6d59165"},
"ecto_sql": {:hex, :ecto_sql, "3.12.0", "73cea17edfa54bde76ee8561b30d29ea08f630959685006d9c6e7d1e59113b7d", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dc9e4d206f274f3947e96142a8fdc5f69a2a6a9abb4649ef5c882323b6d512f0"},
"excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"},
"expo": {:hex, :expo, "1.1.0", "f7b9ed7fb5745ebe1eeedf3d6f29226c5dd52897ac67c0f8af62a07e661e5c75", [:mix], [], "hexpm", "fbadf93f4700fb44c331362177bdca9eeb8097e8b0ef525c9cc501cb9917c960"},
"file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"},
"finch": {:hex, :finch, "0.19.0", "c644641491ea854fc5c1bbaef36bfc764e3f08e7185e1f084e35e0672241b76d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc5324ce209125d1e2fa0fcd2634601c52a787aff1cd33ee833664a5af4ea2b6"},
"gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"},
"hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"},
Expand Down
2 changes: 1 addition & 1 deletion backend/test/peach_web/controllers/create_event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ defmodule PeachWeb.EventControllerTest do

import Ecto.Query

alias Peach.Repo
alias Peach.Event
alias Peach.Repo
alias Peach.TicketTier

@valid_event_attrs %{
Expand Down
5 changes: 3 additions & 2 deletions backend/test/support/data_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Peach.DataCase do
by setting `use Peach.DataCase, async: true`, although
this option is not recommended for other databases.
"""
alias Ecto.Adapters.SQL.Sandbox

use ExUnit.CaseTemplate

Expand All @@ -36,10 +37,10 @@ defmodule Peach.DataCase do
Sets up the sandbox based on the test tags.
"""
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Peach.Repo, shared: not tags[:async])
pid = Sandbox.start_owner!(Peach.Repo, shared: not tags[:async])
# Reset the sequence for the `events` table before each test
Peach.Repo.query!("ALTER SEQUENCE events_id_seq RESTART WITH 1")
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
on_exit(fn -> Sandbox.stop_owner(pid) end)
end

@doc """
Expand Down

0 comments on commit d35d746

Please sign in to comment.