Set up nix flakes
All checks were successful
Test / test (push) Successful in 1m3s

This commit is contained in:
polyfloyd 2025-07-17 16:58:03 +02:00
parent 9d16212e2e
commit f0f46427d3
5 changed files with 126 additions and 16 deletions

View file

@ -2,30 +2,27 @@ name: Test
on: on:
push: push:
branches:
- main
pull_request: pull_request:
branches:
- main
schedule: schedule:
- cron: '0 0 1 * *' # Monthly - cron: '0 0 1 * *' # Monthly
env: env:
SLIGRO_USERNAME: ${{ secrets.SLIGRO_USERNAME }} SLIGRO_USERNAME: ${{ secrets.SLIGRO_USERNAME }}
SLIGRO_PASSWORD: ${{ secrets.SLIGRO_PASSWORD }} SLIGRO_PASSWORD: ${{ secrets.SLIGRO_PASSWORD }}
defaults:
run:
shell: nix develop --command {0}
jobs: jobs:
pytest: test:
runs-on: docker runs-on: nix
container:
image: alpine:latest
steps: steps:
- run: apk add nodejs py3-pip ruff
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: pip install -r requirements.txt --break-system-packages
- name: Populate /nix/store
run: echo done
- run: pytest - run: pytest
- run: ruff check - run: ruff check

61
flake.lock generated Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1752480373,
"narHash": "sha256-JHQbm+OcGp32wAsXTE/FLYGNpb+4GLi5oTvCxwSoBOA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "62e0f05ede1da0d54515d4ea8ce9c733f12d9f08",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

53
flake.nix Normal file
View file

@ -0,0 +1,53 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = system; };
pyprojecttoml = nixpkgs.lib.importTOML ./pyproject.toml;
supermarktconnector = pkgs.python3Packages.buildPythonPackage {
pname = "supermarktconnector";
version = "0.8.1-2";
format = "setuptools";
src = pkgs.fetchFromGitHub {
owner = "bartmachielsen";
repo = "SupermarktConnector";
rev = "393c8698a34393f233a0bef45022954bfabe4247";
hash = "sha256-OuCcwh58HdEsA2h6WGEgKDcyw4RH4NzHlVr7kY3DEHE=";
};
};
in rec {
packages.default = pkgs.python3Packages.buildPythonPackage {
pname = pyprojecttoml.project.name;
version = pyprojecttoml.project.version;
pyproject = true;
src = self;
dependencies = with pkgs.python3Packages; [ pyquery pytest requests ]
++ [supermarktconnector];
nativeBuildInputs = with pkgs.python3Packages; [ setuptools ];
nativeCheckInputs = with pkgs.python3Packages; [ pytest ]
++ [ pkgs.ruff ];
dontCheck = true; # Makes network requests.
checkPhase = ''
runHook preCheck
ruff check
runHook postCheck
'';
};
packages.editable = pkgs.python3Packages.mkPythonEditablePackage {
inherit (packages.default) name version dependencies;
root = "$PWD/src";
passthru = { inherit (packages.default) nativeCheckInputs; };
};
}
);
}

3
pyproject.toml Normal file
View file

@ -0,0 +1,3 @@
[project]
name = "revbank-inflatinator"
version = "0.0.1"

View file

@ -1,4 +0,0 @@
pyquery
pytest
requests
supermarktconnector