WIP: feat(nix): Begin adding actions #848
19 changed files with 307 additions and 152 deletions
10
.flake8
Normal file
10
.flake8
Normal file
|
@ -0,0 +1,10 @@
|
|||
[flake8]
|
||||
exclude = migrations
|
||||
max-line-length = 88
|
||||
ignore =
|
||||
# whitespace before ':' (not PEP8-compliant for slicing)
|
||||
E203,
|
||||
# lambda expression
|
||||
E731,
|
||||
# line break before binary operator (not PEP8-compliant)
|
||||
W503
|
15
.forgejo/workflows/migrations-check.yaml
Normal file
15
.forgejo/workflows/migrations-check.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
jobs:
|
||||
migrations_check:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with: {}
|
||||
- name: Setup dev secrets...
|
||||
run: cp gestioasso/settings/secret_example.py gestioasso/settings/secret.py
|
||||
- name: Check that all migrations exist
|
||||
run: nix-shell --run "python manage.py makemigrations --dry-run --check bda
|
||||
bds clubs cofcms events gestioncof kfet kfetauth kfetcms open petitscours
|
||||
shared"
|
||||
name: Check for missing migrations
|
||||
'on':
|
||||
- pull_request
|
15
.forgejo/workflows/pre-commit.yaml
Normal file
15
.forgejo/workflows/pre-commit.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
jobs:
|
||||
pre-commit:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Check stage pre-commit
|
||||
run: nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage
|
||||
pre-commit --show-diff-on-failure'
|
||||
- name: Check stage pre-push
|
||||
run: nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage
|
||||
pre-push --show-diff-on-failure'
|
||||
name: Run pre-commit on all files
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -21,3 +21,4 @@ media/
|
|||
# VSCode
|
||||
.vscode/
|
||||
.direnv
|
||||
.pre-commit-config.yaml
|
||||
|
|
1
.pre-commit-config.yaml
Symbolic link
1
.pre-commit-config.yaml
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/s6xfmmc25y8kgg0xh35qlg7sc0h7rllb-pre-commit-config.json
|
|
@ -1,4 +1,5 @@
|
|||
from django.apps import AppConfig, apps as global_apps
|
||||
from django.apps import AppConfig
|
||||
from django.apps import apps as global_apps
|
||||
from django.db.models import Q
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
|
|
130
default.nix
Normal file
130
default.nix
Normal file
|
@ -0,0 +1,130 @@
|
|||
{
|
||||
sources ? import ./npins,
|
||||
pkgs ? import sources.nixpkgs { },
|
||||
}:
|
||||
|
||||
let
|
||||
###
|
||||
# Pkgs configuration
|
||||
|
||||
inherit (pkgs.lib)
|
||||
genAttrs
|
||||
mapAttrs
|
||||
mapAttrs'
|
||||
nameValuePair
|
||||
removeSuffix
|
||||
;
|
||||
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
kat-pkgs = import sources.kat-pkgs { inherit pkgs; };
|
||||
|
||||
python3 = pkgs.python3.override {
|
||||
packageOverrides = final: prev: {
|
||||
inherit (nix-pkgs)
|
||||
authens
|
||||
django-bootstrap-form
|
||||
django-cas-ng
|
||||
loadcredential
|
||||
;
|
||||
|
||||
inherit (kat-pkgs.python3Packages)
|
||||
django-djconfig
|
||||
django-hCaptcha
|
||||
wagtail-modeltranslation
|
||||
wagtailmenus
|
||||
;
|
||||
};
|
||||
};
|
||||
|
||||
###
|
||||
# CI configuration
|
||||
|
||||
nix-actions = import sources.nix-actions { inherit pkgs; };
|
||||
|
||||
workflows = nix-actions.install {
|
||||
src = ./.;
|
||||
|
||||
buildCheck = false;
|
||||
|
||||
workflows = mapAttrs' (
|
||||
name: _:
|
||||
nameValuePair (removeSuffix ".nix" name) (
|
||||
import ./workflows/${name} {
|
||||
inherit nix-actions;
|
||||
inherit (pkgs) lib;
|
||||
}
|
||||
)
|
||||
) (builtins.readDir ./workflows);
|
||||
};
|
||||
|
||||
git-hooks = (import sources.git-hooks).run {
|
||||
src = ./.;
|
||||
|
||||
hooks = genAttrs [ "black" "isort" "commitizen" ] (_: {
|
||||
enable = true;
|
||||
});
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
devShell = pkgs.mkShell {
|
||||
shellHook = ''
|
||||
${git-hooks.shellHook}
|
||||
${workflows.shellHook}
|
||||
if [ ! -d .static ]; then
|
||||
mkdir .static
|
||||
fi
|
||||
'';
|
||||
|
||||
env = {
|
||||
CREDENTIALS_DIRECTORY = builtins.toString ./.credentials;
|
||||
DJANGO_SETTINGS_MODULE = "gestioasso.settings.local";
|
||||
|
||||
GESTIOCOF_DEBUG = true;
|
||||
GESTIOCOF_STATIC_ROOT = builtins.toString ./.static;
|
||||
|
||||
GESTIOBDS_DEBUG = true;
|
||||
GESTIOBDS_STATIC_ROOT = builtins.toString ./.static;
|
||||
};
|
||||
|
||||
packages = [
|
||||
(python3.withPackages (
|
||||
ps: with ps; [
|
||||
django
|
||||
pillow
|
||||
authens
|
||||
channels
|
||||
configparser
|
||||
django-autocomplete-light
|
||||
django-bootstrap-form
|
||||
django-cas-ng
|
||||
django-cors-headers
|
||||
django-djconfig
|
||||
django-hCaptcha
|
||||
django-js-reverse
|
||||
django-widget-tweaks
|
||||
icalendar
|
||||
loadcredential
|
||||
python-dateutil
|
||||
statistics
|
||||
wagtail-modeltranslation
|
||||
wagtail
|
||||
wagtailmenus
|
||||
|
||||
django-debug-toolbar
|
||||
ipython
|
||||
black
|
||||
flake8
|
||||
isort
|
||||
]
|
||||
))
|
||||
pkgs.npins
|
||||
] ++ git-hooks.enabledPackages;
|
||||
|
||||
passthru = mapAttrs (name: value: pkgs.mkShell (value // { inherit name; })) {
|
||||
pre-commit.shellHook = git-hooks.shellHook;
|
||||
};
|
||||
};
|
||||
|
||||
preferLocalBuild = true;
|
||||
}
|
|
@ -4,6 +4,7 @@ Active toutes les applications (de GestioCOF et de GestioBDS).
|
|||
|
||||
Surcharge les settings définis dans common.py
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from . import bds_prod
|
||||
|
|
|
@ -6,7 +6,6 @@ Charge des données de test dans la BDD
|
|||
- Petits cours
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import random
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from gestioncof.models import Event
|
||||
from shared.tests.mixins import (
|
||||
CSVResponseMixin,
|
||||
ViewTestCaseMixin as BaseViewTestCaseMixin,
|
||||
)
|
||||
from shared.tests.mixins import CSVResponseMixin
|
||||
from shared.tests.mixins import ViewTestCaseMixin as BaseViewTestCaseMixin
|
||||
|
||||
from .utils import create_member, create_staff, create_user
|
||||
|
||||
|
|
|
@ -8,11 +8,9 @@ from django.contrib import messages
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.views import (
|
||||
LoginView as DjangoLoginView,
|
||||
LogoutView as DjangoLogoutView,
|
||||
redirect_to_login,
|
||||
)
|
||||
from django.contrib.auth.views import LoginView as DjangoLoginView
|
||||
from django.contrib.auth.views import LogoutView as DjangoLogoutView
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.mail import send_mail
|
||||
from django.http import Http404, HttpResponse, HttpResponseForbidden
|
||||
|
@ -23,7 +21,8 @@ from django.utils import timezone
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import FormView, TemplateView
|
||||
from django_cas_ng.views import LogoutView as CasLogoutView
|
||||
from icalendar import Calendar, Event as Vevent
|
||||
from icalendar import Calendar
|
||||
from icalendar import Event as Vevent
|
||||
|
||||
from bda.models import Spectacle, Tirage
|
||||
from gestioncof.autocomplete import cof_autocomplete
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime, timedelta, timezone as tz
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timezone as tz
|
||||
from decimal import Decimal
|
||||
from unittest import mock
|
||||
|
||||
|
|
|
@ -105,12 +105,8 @@ from kfet.statistic import SCALE_DICT, DayScale, MonthScale, WeekScale, scale_ur
|
|||
from shared.views import AutocompleteView
|
||||
|
||||
from .auth import KFET_GENERIC_TRIGRAMME
|
||||
from .auth.views import ( # noqa
|
||||
AccountGroupCreate,
|
||||
AccountGroupUpdate,
|
||||
account_group,
|
||||
login_generic,
|
||||
)
|
||||
from .auth.views import AccountGroupUpdate # noqa
|
||||
from .auth.views import AccountGroupCreate, account_group, login_generic
|
||||
|
||||
|
||||
def put_cleaned_data_in_dict(dict, form):
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
{
|
||||
"pins": {
|
||||
"git-hooks": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
"type": "GitHub",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix"
|
||||
},
|
||||
"branch": "master",
|
||||
"revision": "a5a961387e75ae44cc20f0a57ae463da5e959656",
|
||||
"url": "https://github.com/cachix/git-hooks.nix/archive/a5a961387e75ae44cc20f0a57ae463da5e959656.tar.gz",
|
||||
"hash": "0pfpiz3z2l5l3h9ml1z75zn11jbq2qhb1ph8jn277ds6x8dl0mnw"
|
||||
},
|
||||
"kat-pkgs": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
|
@ -11,6 +23,20 @@
|
|||
"url": null,
|
||||
"hash": "0204f91vxa5qglihpfkf3j5w3k7v98wry861xf2skl024faf9idf"
|
||||
},
|
||||
"nix-actions": {
|
||||
"type": "GitRelease",
|
||||
"repository": {
|
||||
"type": "Git",
|
||||
"url": "https://git.dgnum.eu/DGNum/nix-actions"
|
||||
},
|
||||
"pre_releases": false,
|
||||
"version_upper_bound": null,
|
||||
"release_prefix": null,
|
||||
"version": "v0.3.0",
|
||||
"revision": "15a5f4cd9909cad78c8be852d176def42d5ab3cd",
|
||||
"url": null,
|
||||
"hash": "16gssfs2qxy1nqnfqpbn076i79zna295jzix897346ic3gy11610"
|
||||
},
|
||||
"nix-pkgs": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
|
@ -18,9 +44,9 @@
|
|||
"url": "https://git.hubrecht.ovh/hubrecht/nix-pkgs"
|
||||
},
|
||||
"branch": "main",
|
||||
"revision": "ac4ff5a34789ae3398aff9501735b67b6a5a285a",
|
||||
"revision": "a9133ed1b96f1e01a9fc1a12dc2602c41c5f70cd",
|
||||
"url": null,
|
||||
"hash": "16n37f74p6h30hhid98vab9w5b08xqj4qcshz2kc1jh67z5n49p6"
|
||||
"hash": "17wah3x9fflw1699c5jvsi06i2rbb33bxkglwyjhjnnjz7zag871"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"type": "Channel",
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
[tool.black]
|
||||
# Automatically ignore files in .gitignore (opened at this time):
|
||||
# https://github.com/ambv/black/issues/475
|
||||
exclude = '''
|
||||
/(
|
||||
\.pyc
|
||||
| venv
|
||||
)/
|
||||
'''
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
|
||||
[tool.coverage.run]
|
||||
source = [
|
||||
"bda",
|
||||
"bds",
|
||||
"clubs",
|
||||
"events",
|
||||
"gestioasso",
|
||||
"gestioncof",
|
||||
"kfet",
|
||||
"petitscours",
|
||||
"shared",
|
||||
]
|
||||
omit = [
|
||||
"*migrations*",
|
||||
"*test*.py",
|
||||
]
|
||||
branch = true
|
||||
|
||||
[tool.coverage.report]
|
||||
precision = 2
|
||||
show_missing = true
|
||||
|
|
41
setup.cfg
41
setup.cfg
|
@ -1,41 +0,0 @@
|
|||
[coverage:run]
|
||||
source =
|
||||
bda
|
||||
bds
|
||||
clubs
|
||||
events
|
||||
gestioasso
|
||||
gestioncof
|
||||
kfet
|
||||
petitscours
|
||||
shared
|
||||
omit =
|
||||
*migrations*
|
||||
*test*.py
|
||||
branch = true
|
||||
|
||||
[coverage:report]
|
||||
precision = 2
|
||||
show_missing = true
|
||||
|
||||
[flake8]
|
||||
exclude = migrations
|
||||
max-line-length = 88
|
||||
ignore =
|
||||
# whitespace before ':' (not PEP8-compliant for slicing)
|
||||
E203,
|
||||
# lambda expression
|
||||
E731,
|
||||
# line break before binary operator (not PEP8-compliant)
|
||||
W503
|
||||
|
||||
[isort]
|
||||
# For black compat: https://github.com/ambv/black#how-black-wraps-lines
|
||||
combine_as_imports = true
|
||||
default_section = THIRDPARTY
|
||||
force_grid_wrap = 0
|
||||
include_trailing_comma = true
|
||||
known_first_party = bda,bds,clubs,cof,events,gestioncof,kfet,petitscours,shared
|
||||
line_length = 88
|
||||
multi_line_output = 3
|
||||
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
82
shell.nix
82
shell.nix
|
@ -1,81 +1 @@
|
|||
{
|
||||
sources ? import ./npins,
|
||||
pkgs ? import sources.nixpkgs { },
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
kat-pkgs = import sources.kat-pkgs { inherit pkgs; };
|
||||
|
||||
python3 = pkgs.python3.override {
|
||||
packageOverrides = final: prev: {
|
||||
inherit (nix-pkgs)
|
||||
authens
|
||||
django-bootstrap-form
|
||||
django-cas-ng
|
||||
loadcredential
|
||||
;
|
||||
|
||||
inherit (kat-pkgs.python3Packages)
|
||||
django-djconfig
|
||||
django-hCaptcha
|
||||
wagtail-modeltranslation
|
||||
wagtailmenus
|
||||
;
|
||||
};
|
||||
};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
shellHook = ''
|
||||
if [ ! -d .static ]; then
|
||||
mkdir .static
|
||||
fi
|
||||
'';
|
||||
|
||||
env = {
|
||||
CREDENTIALS_DIRECTORY = builtins.toString ./.credentials;
|
||||
DJANGO_SETTINGS_MODULE = "gestioasso.settings.local";
|
||||
|
||||
GESTIOCOF_DEBUG = true;
|
||||
GESTIOCOF_STATIC_ROOT = builtins.toString ./.static;
|
||||
|
||||
GESTIOBDS_DEBUG = true;
|
||||
GESTIOBDS_STATIC_ROOT = builtins.toString ./.static;
|
||||
};
|
||||
|
||||
packages = [
|
||||
(python3.withPackages (
|
||||
ps: with ps; [
|
||||
django
|
||||
pillow
|
||||
authens
|
||||
channels
|
||||
configparser
|
||||
django-autocomplete-light
|
||||
django-bootstrap-form
|
||||
django-cas-ng
|
||||
django-cors-headers
|
||||
django-djconfig
|
||||
django-hCaptcha
|
||||
django-js-reverse
|
||||
django-widget-tweaks
|
||||
icalendar
|
||||
loadcredential
|
||||
python-dateutil
|
||||
statistics
|
||||
wagtail-modeltranslation
|
||||
wagtail
|
||||
wagtailmenus
|
||||
|
||||
django-debug-toolbar
|
||||
ipython
|
||||
black
|
||||
flake8
|
||||
isort
|
||||
]
|
||||
))
|
||||
pkgs.npins
|
||||
];
|
||||
|
||||
allowSubstitutes = false;
|
||||
}
|
||||
(import ./. { }).devShell
|
||||
|
|
39
workflows/migrations-check.nix
Normal file
39
workflows/migrations-check.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{ nix-actions, ... }:
|
||||
|
||||
let
|
||||
apps = [
|
||||
"bda"
|
||||
"bds"
|
||||
"clubs"
|
||||
"cofcms"
|
||||
"events"
|
||||
"gestioncof"
|
||||
"kfet"
|
||||
"kfetauth"
|
||||
"kfetcms"
|
||||
"open"
|
||||
"petitscours"
|
||||
"shared"
|
||||
];
|
||||
in
|
||||
|
||||
{
|
||||
name = "Check for missing migrations";
|
||||
on = [ "pull_request" ];
|
||||
|
||||
jobs.migrations_check = {
|
||||
runs-on = "nix";
|
||||
steps = [
|
||||
(nix-actions.steps.checkout { })
|
||||
{
|
||||
name = "Setup dev secrets...";
|
||||
run = # bash
|
||||
"cp gestioasso/settings/secret_example.py gestioasso/settings/secret.py";
|
||||
}
|
||||
{
|
||||
name = "Check that all migrations exist";
|
||||
run = ''nix-shell --run "python manage.py makemigrations --dry-run --check ${builtins.concatStringsSep " " apps}"'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
29
workflows/pre-commit.nix
Normal file
29
workflows/pre-commit.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
||||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
name = "Run pre-commit on all files";
|
||||
on = [
|
||||
"push"
|
||||
"pull_request"
|
||||
];
|
||||
|
||||
jobs.pre-commit = {
|
||||
runs-on = "nix";
|
||||
steps =
|
||||
[ { uses = "actions/checkout@v3"; } ]
|
||||
++ (builtins.map
|
||||
(stage: {
|
||||
name = "Check stage ${stage}";
|
||||
run = "nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage ${stage} --show-diff-on-failure'";
|
||||
})
|
||||
[
|
||||
"pre-commit"
|
||||
"pre-push"
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue