Skip to content

Commit 2784baa

Browse files
committed
chore: add development environment configuration
- Add devenv.nix for reproducible development environment setup - Add devenv.lock for locking devenv dependencies - Add devenv.yaml for project configuration - Add .envrc for direnv integration with devenv - Add GitHub Actions workflows for CI and testing
1 parent bf5cd0b commit 2784baa

File tree

6 files changed

+361
-0
lines changed

6 files changed

+361
-0
lines changed

.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export DIRENV_WARN_TIMEOUT=20s
2+
3+
eval "$(devenv direnvrc)"
4+
5+
# The use_devenv function supports passing flags to the devenv command
6+
# For example: use devenv --impure --option services.postgres.enable:bool true
7+
use devenv

.github/workflows/ci.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
7+
jobs:
8+
compile:
9+
10+
name: Compile
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Elixir
18+
uses: erlef/setup-beam@v1
19+
with:
20+
elixir-version: '1.18'
21+
otp-version: '28'
22+
23+
- name: Restore dependencies cache
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
deps
28+
_build
29+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
30+
restore-keys: ${{ runner.os }}-mix-
31+
32+
- name: Install dependencies
33+
run: mix deps.get
34+
35+
- name: Compile with warnings as errors
36+
run: mix compile --warnings-as-errors
37+
38+
format:
39+
name: Format Check
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Elixir
47+
uses: erlef/setup-beam@v1
48+
with:
49+
elixir-version: '1.18'
50+
otp-version: '28'
51+
52+
- name: Restore dependencies cache
53+
uses: actions/cache@v4
54+
with:
55+
path: |
56+
deps
57+
_build
58+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
59+
restore-keys: ${{ runner.os }}-mix-
60+
61+
- name: Install dependencies
62+
run: mix deps.get
63+
64+
- name: Check code formatting
65+
run: mix format --check-formatted
66+
67+
credo:
68+
name: Credo
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v4
74+
75+
- name: Set up Elixir
76+
uses: erlef/setup-beam@v1
77+
with:
78+
elixir-version: '1.18'
79+
otp-version: '28'
80+
81+
- name: Restore dependencies cache
82+
uses: actions/cache@v4
83+
with:
84+
path: |
85+
deps
86+
_build
87+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
88+
restore-keys: ${{ runner.os }}-mix-
89+
90+
- name: Install dependencies
91+
run: mix deps.get
92+
93+
- name: Run Credo strict
94+
run: mix credo --strict
95+
96+
dialyzer:
97+
name: Dialyzer
98+
runs-on: ubuntu-latest
99+
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v4
103+
104+
- name: Set up Elixir
105+
uses: erlef/setup-beam@v1
106+
with:
107+
elixir-version: '1.18'
108+
otp-version: '28'
109+
110+
- name: Restore dependencies cache
111+
uses: actions/cache@v4
112+
with:
113+
path: |
114+
deps
115+
_build
116+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
117+
restore-keys: ${{ runner.os }}-mix-
118+
119+
- name: Install dependencies
120+
run: mix deps.get
121+
122+
- name: Restore Dialyzer PLT cache
123+
uses: actions/cache@v4
124+
with:
125+
path: priv/plts
126+
key: ${{ runner.os }}-dialyzer-${{ hashFiles('**/mix.lock') }}
127+
restore-keys: ${{ runner.os }}-dialyzer-
128+
129+
- name: Run Dialyzer
130+
run: mix dialyzer --halt-exit-status

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v5
17+
18+
- name: Set up Elixir
19+
uses: erlef/setup-beam@v1
20+
with:
21+
elixir-version: '1.18'
22+
otp-version: '28'
23+
24+
- uses: oven-sh/setup-bun@v2
25+
with:
26+
bun-version: latest
27+
28+
- name: Restore dependencies cache
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
deps
33+
_build
34+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-mix-
37+
38+
- name: Install dependencies
39+
run: mix deps.get
40+
41+
- name: Run tests
42+
run: mix test

devenv.lock

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1758366037,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "ebb56bfe1aa0936de2f8a68c616dabff1285e905",
10+
"type": "github"
11+
},
12+
"original": {
13+
"dir": "src/modules",
14+
"owner": "cachix",
15+
"repo": "devenv",
16+
"type": "github"
17+
}
18+
},
19+
"flake-compat": {
20+
"flake": false,
21+
"locked": {
22+
"lastModified": 1747046372,
23+
"owner": "edolstra",
24+
"repo": "flake-compat",
25+
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "edolstra",
30+
"repo": "flake-compat",
31+
"type": "github"
32+
}
33+
},
34+
"git-hooks": {
35+
"inputs": {
36+
"flake-compat": "flake-compat",
37+
"gitignore": "gitignore",
38+
"nixpkgs": [
39+
"nixpkgs"
40+
]
41+
},
42+
"locked": {
43+
"lastModified": 1758108966,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b",
47+
"type": "github"
48+
},
49+
"original": {
50+
"owner": "cachix",
51+
"repo": "git-hooks.nix",
52+
"type": "github"
53+
}
54+
},
55+
"gitignore": {
56+
"inputs": {
57+
"nixpkgs": [
58+
"git-hooks",
59+
"nixpkgs"
60+
]
61+
},
62+
"locked": {
63+
"lastModified": 1709087332,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"locked": {
77+
"lastModified": 1755783167,
78+
"owner": "cachix",
79+
"repo": "devenv-nixpkgs",
80+
"rev": "4a880fb247d24fbca57269af672e8f78935b0328",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "cachix",
85+
"ref": "rolling",
86+
"repo": "devenv-nixpkgs",
87+
"type": "github"
88+
}
89+
},
90+
"nixpkgs-stable": {
91+
"locked": {
92+
"lastModified": 1758441781,
93+
"owner": "nixos",
94+
"repo": "nixpkgs",
95+
"rev": "4c5924c35ad05baebc59369168b348e6b9bb794d",
96+
"type": "github"
97+
},
98+
"original": {
99+
"owner": "nixos",
100+
"ref": "release-25.05",
101+
"repo": "nixpkgs",
102+
"type": "github"
103+
}
104+
},
105+
"nixpkgs-unstable": {
106+
"locked": {
107+
"lastModified": 1758294315,
108+
"owner": "nixos",
109+
"repo": "nixpkgs",
110+
"rev": "90ade7da38aa49c2e2693a04a44662a0e61530e9",
111+
"type": "github"
112+
},
113+
"original": {
114+
"owner": "nixos",
115+
"ref": "nixpkgs-unstable",
116+
"repo": "nixpkgs",
117+
"type": "github"
118+
}
119+
},
120+
"root": {
121+
"inputs": {
122+
"devenv": "devenv",
123+
"git-hooks": "git-hooks",
124+
"nixpkgs": "nixpkgs",
125+
"nixpkgs-stable": "nixpkgs-stable",
126+
"nixpkgs-unstable": "nixpkgs-unstable",
127+
"pre-commit-hooks": [
128+
"git-hooks"
129+
]
130+
}
131+
}
132+
},
133+
"root": "root",
134+
"version": 7
135+
}

devenv.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ pkgs, lib, config, inputs, ... }:
2+
3+
let
4+
pkgs-stable = import inputs.nixpkgs-stable { system = pkgs.stdenv.system; };
5+
pkgs-unstable = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; };
6+
in
7+
{
8+
env.GREET = "Elixir Caddy";
9+
10+
packages = [
11+
pkgs-stable.git
12+
pkgs-stable.figlet
13+
pkgs-stable.lolcat
14+
];
15+
16+
languages.elixir.enable = true;
17+
languages.elixir.package = pkgs-stable.beam27Packages.elixir;
18+
19+
scripts.hello.exec = ''
20+
figlet -w 120 $GREET | lolcat
21+
'';
22+
23+
enterShell = ''
24+
hello
25+
'';
26+
27+
}

devenv.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
2+
inputs:
3+
nixpkgs:
4+
url: github:cachix/devenv-nixpkgs/rolling
5+
nixpkgs-stable:
6+
url: github:nixos/nixpkgs/release-25.05
7+
nixpkgs-unstable:
8+
url: github:nixos/nixpkgs/nixpkgs-unstable
9+
10+
11+
# If you're using non-OSS software, you can set allowUnfree to true.
12+
allowUnfree: true
13+
14+
# If you're willing to use a package that's vulnerable
15+
# permittedInsecurePackages:
16+
# - "openssl-1.1.1w"
17+
18+
# If you have more than one devenv you can merge them
19+
#imports:
20+
# - ./backend

0 commit comments

Comments
 (0)