Skip to content

Commit 42761eb

Browse files
jaysa68Jaysa Garcia
andauthored
make test works in devenv shell! (#680)
* make test works in devenv shell! * run make test on PRs * bump mirrors-autopep8 * bump mirrors-autopep8 to v2.3.1 * just remove autopep8 hook * switch to uv --------- Co-authored-by: Jaysa Garcia <jaysa@smokey.ocf.berkeley.edu>
1 parent ab6924b commit 42761eb

16 files changed

Lines changed: 1289 additions & 552 deletions

.envrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
export DIRENV_WARN_TIMEOUT=20s
4+
5+
eval "$(devenv direnvrc)"
6+
7+
# `use devenv` supports the same options as the `devenv shell` command.
8+
#
9+
# To silence all output, use `--quiet`.
10+
#
11+
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
12+
use devenv

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v5
14+
15+
- name: Run tests
16+
run: make test

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/.cache
22
/.tox
33
/venv
4+
/.venv
45
__pycache__/
6+
7+
# Devenv
8+
.devenv*
9+
devenv.local.nix
10+
devenv.local.yaml
11+
12+
# direnv
13+
.direnv
14+
15+
# pre-commit
16+
.pre-commit-config.yaml

.pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ repos:
3535
rev: 3.7.7
3636
hooks:
3737
- id: flake8
38-
- repo: https://github.com/pre-commit/mirrors-autopep8
39-
rev: v1.4.4
40-
hooks:
41-
- id: autopep8
4238
- repo: https://github.com/asottile/reorder_python_imports
4339
rev: v1.4.0
4440
hooks:

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
BIN := venv/bin
1+
BIN := .venv/bin
22
PYTHON := $(BIN)/python
33

44
.PHONY: test
5-
test: venv
5+
test: .venv
66
$(BIN)/py.test -v tests/
77
$(BIN)/pre-commit run --all-files
88

9-
venv: requirements.txt
10-
python ./vendor/venv-update venv= venv -ppython3 install= -r requirements.txt -r requirements-dev.txt
9+
.venv: pyproject.toml uv.lock
10+
uv sync --group dev
1111

1212
.PHONY: install-hooks
13-
install-hooks: venv
13+
install-hooks: .venv
1414
$(BIN)/pre-commit install -f --install-hooks
1515

1616
.PHONY: clean
1717
clean:
18-
rm -rf venv
18+
rm -rf .venv
1919

2020
.PHONY: update-requirements
21-
update-requirements: venv
22-
$(BIN)/upgrade-requirements
23-
sed -i 's/^ocflib==.*/ocflib/' requirements.txt
21+
update-requirements:
22+
uv lock --upgrade

configs/vhost-mail.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ heartstrings heartstrings.studentorg.berkeley.edu
2828
mcbusa mcbusa.studentorg.berkeley.edu
2929

3030
# in-person by sbwilliams
31-
priorit priorit.studentorg.berkeley.edu
31+
priorit priorit.studentorg.berkeley.edu
3232

3333
# rt#15345 by sbwilliams
3434
emb surge.studentorg.berkeley.edu

devenv.lock

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1777837414,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "9708ea1ebc52d6189cff09b837067daefb0bf0e7",
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": 1767039857,
23+
"owner": "NixOS",
24+
"repo": "flake-compat",
25+
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "NixOS",
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": 1776796298,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "3cfd774b0a530725a077e17354fbdb87ea1c4aad",
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": 1762808025,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"inputs": {
77+
"nixpkgs-src": "nixpkgs-src"
78+
},
79+
"locked": {
80+
"lastModified": 1776852779,
81+
"owner": "cachix",
82+
"repo": "devenv-nixpkgs",
83+
"rev": "ec3063523dcd911aeadb50faa589f237cdab5853",
84+
"type": "github"
85+
},
86+
"original": {
87+
"owner": "cachix",
88+
"ref": "rolling",
89+
"repo": "devenv-nixpkgs",
90+
"type": "github"
91+
}
92+
},
93+
"nixpkgs-src": {
94+
"flake": false,
95+
"locked": {
96+
"lastModified": 1776329215,
97+
"narHash": "sha256-a8BYi3mzoJ/AcJP8UldOx8emoPRLeWqALZWu4ZvjPXw=",
98+
"owner": "NixOS",
99+
"repo": "nixpkgs",
100+
"rev": "b86751bc4085f48661017fa226dee99fab6c651b",
101+
"type": "github"
102+
},
103+
"original": {
104+
"owner": "NixOS",
105+
"ref": "nixpkgs-unstable",
106+
"repo": "nixpkgs",
107+
"type": "github"
108+
}
109+
},
110+
"root": {
111+
"inputs": {
112+
"devenv": "devenv",
113+
"git-hooks": "git-hooks",
114+
"nixpkgs": "nixpkgs",
115+
"pre-commit-hooks": [
116+
"git-hooks"
117+
]
118+
}
119+
}
120+
},
121+
"root": "root",
122+
"version": 7
123+
}

devenv.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{ pkgs, lib, config, inputs, ... }:
2+
3+
{
4+
cachix.enable = false;
5+
6+
packages = [
7+
pkgs.git
8+
pkgs.cracklib
9+
];
10+
11+
# https://devenv.sh/languages/
12+
# languages.rust.enable = true;
13+
languages.python = {
14+
enable = true;
15+
package = pkgs.python312;
16+
uv.enable = true;
17+
};
18+
19+
enterShell = ''
20+
echo successfully entered ocf/etc devenv
21+
python --version
22+
'';
23+
24+
# https://devenv.sh/tasks/
25+
# tasks = {
26+
# "myproj:setup".exec = "mytool build";
27+
# "devenv:enterShell".after = [ "myproj:setup" ];
28+
# };
29+
30+
# https://devenv.sh/tests/
31+
enterTest = ''
32+
echo "Running tests"
33+
git --version | grep --color=auto "${pkgs.git.version}"
34+
'';
35+
36+
# https://devenv.sh/git-hooks/
37+
# git-hooks.hooks.shellcheck.enable = true;
38+
39+
# See full reference at https://devenv.sh/reference/options/
40+
}

devenv.yaml

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

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[project]
2+
name = "ocf-etc"
3+
version = "0.1.0"
4+
requires-python = ">=3.12"
5+
dependencies = []
6+
7+
[dependency-groups]
8+
dev = [
9+
"jinja2>=3",
10+
"jsonschema",
11+
"ocflib",
12+
"pre-commit>=3",
13+
"pyfakefs>=5",
14+
"pytest",
15+
"pyyaml",
16+
"requests>=2.28",
17+
"setuptools>=65",
18+
"urllib3>=2",
19+
"virtualenv>=20.14",
20+
]

0 commit comments

Comments
 (0)