Skip to content

Commit afbab40

Browse files
committed
Format with the latest black; Update CI to Python 3.9; Test robotframework == 4.1.3
1 parent 36ed263 commit afbab40

40 files changed

+9750
-1851
lines changed

.github/workflows/smoketest.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
robotframework-version: [rf31, rf32, rf40]
10+
robotframework-version: [rf32, rf40, rf41, rf50]
1111
steps:
12-
- uses: actions/checkout@v2.3.4
13-
- uses: cachix/install-nix-action@v12
12+
- uses: actions/checkout@v2.4.0
13+
- uses: cachix/install-nix-action@v16
1414
with:
1515
nix_path: nixpkgs=channel:nixos-unstable
16-
- uses: cachix/cachix-action@v8
16+
- uses: cachix/cachix-action@v10
1717
with:
1818
name: robots-from-jupyter
19-
- run: nix-shell setup.nix -A shell --argstr robotframework ${{ matrix.robotframework-version }} --run "make test && python -m robotkernel.install && jupyter nbconvert --execute tests/Smoketest.ipynb && nbrobot -v BROWSER:headlessfirefox -F ipynb tests atest"
19+
# If you chose signing key for write access
20+
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
21+
# If you chose API tokens for write access OR if you have a private cache
22+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
23+
- run: nix-shell setup.nix -A shell --argstr robotframework ${{ matrix.robotframework-version }} --run "make test"
24+
- run: nix-shell setup.nix -A shell --argstr robotframework ${{ matrix.robotframework-version }} --run "python -m robotkernel.install"
25+
- run: nix-shell setup.nix -A shell --argstr robotframework ${{ matrix.robotframework-version }} --run "jupyter nbconvert --execute tests/Smoketest.ipynb --to notebook"
26+
- run: nix-shell setup.nix -A shell --argstr robotframework ${{ matrix.robotframework-version }} --run "nbrobot -v BROWSER:headlessfirefox -F ipynb tests atest"
27+
- run: nix-shell --run "echo OK"

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
REF_NIXPKGS = branches nixos-20.03
22

3-
PYTHON ?= python37
4-
ROBOTFRAMEWORK ?= rf32
3+
PYTHON ?= python39
4+
ROBOTFRAMEWORK ?= rf40
55
NIX_OPTIONS ?= --argstr python $(PYTHON) --argstr robotframework $(ROBOTFRAMEWORK)
66

77
.PHONY: all
@@ -19,7 +19,7 @@ env: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix
1919

2020
.PHONY: test
2121
test: check
22-
pytest tests
22+
PYTHONPATH=$(PYTHONPATH):$(PWD)/src pytest tests
2323
# pytest --cov=robotkernel tests
2424

2525
.PHONY: check
@@ -42,7 +42,7 @@ coverage: htmlcov
4242
.PHONY: format
4343
format:
4444
black -t py37 src tests
45-
isort -rc -y src tests
45+
isort src tests
4646

4747
###
4848

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{ python ? "python37" }:
1+
{ python ? "python39" }:
22
(import ./setup.nix { inherit python; }).package

nix/default.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# https://github.com/nmattia/niv
2+
{ sources ? import ./sources.nix
3+
, nixpkgs ? sources."nixpkgs"
4+
}:
5+
6+
let
7+
8+
nixpkgs_20_09 = import sources."nixpkgs-20.09" {};
9+
nixpkgs_unstable = import sources."nixpkgs-unstable" {};
10+
11+
overlay = _: pkgs: {
12+
pip2nix = nixpkgs_20_09.callPackage ./pkgs/pip2nix {};
13+
inherit (nixpkgs_unstable) geckodriver;
14+
};
15+
16+
pkgs = import nixpkgs {
17+
overlays = [ overlay ];
18+
};
19+
20+
in pkgs

nix/pkgs/pip2nix/default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ pkgs }:
2+
3+
(import ((import ./nix/sources.nix).pip2nix + "/release.nix") {
4+
inherit pkgs;
5+
}).pip2nix

nix/pkgs/pip2nix/nix/sources.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pip2nix": {
3+
"branch": "master",
4+
"description": "Freeze pip-installable packages into Nix expressions",
5+
"homepage": "",
6+
"owner": "nix-community",
7+
"repo": "pip2nix",
8+
"rev": "3ded07fcb8a4a491f36f1b8aac9c9c9c402d99fe",
9+
"sha256": "0wqdfb9hbpqzs3z4x07a9z1hdl663xdyik7vm06z3pkb8i20kxq8",
10+
"type": "tarball",
11+
"url": "https://github.com/nix-community/pip2nix/archive/3ded07fcb8a4a491f36f1b8aac9c9c9c402d99fe.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
}
14+
}

nix/pkgs/pip2nix/nix/sources.nix

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# niv: no_update
2+
# This file has been generated by Niv.
3+
4+
let
5+
6+
#
7+
# The fetchers. fetch_<type> fetches specs of type <type>.
8+
#
9+
10+
fetch_file = pkgs: spec:
11+
if spec.builtin or true then
12+
builtins_fetchurl { inherit (spec) url sha256; }
13+
else
14+
pkgs.fetchurl { inherit (spec) url sha256; };
15+
16+
fetch_tarball = pkgs: name: spec:
17+
let
18+
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
19+
# sanitize the name, though nix will still fail if name starts with period
20+
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
21+
in
22+
if spec.builtin or true then
23+
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
24+
else
25+
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
26+
27+
fetch_git = spec:
28+
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
29+
30+
fetch_local = spec: spec.path;
31+
32+
fetch_builtin-tarball = name: throw
33+
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
34+
$ niv modify ${name} -a type=tarball -a builtin=true'';
35+
36+
fetch_builtin-url = name: throw
37+
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
38+
$ niv modify ${name} -a type=file -a builtin=true'';
39+
40+
#
41+
# Various helpers
42+
#
43+
44+
# The set of packages used when specs are fetched using non-builtins.
45+
mkPkgs = sources:
46+
let
47+
sourcesNixpkgs =
48+
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
49+
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
50+
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
51+
in
52+
if builtins.hasAttr "nixpkgs" sources
53+
then sourcesNixpkgs
54+
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
55+
import <nixpkgs> {}
56+
else
57+
abort
58+
''
59+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
60+
add a package called "nixpkgs" to your sources.json.
61+
'';
62+
63+
# The actual fetching function.
64+
fetch = pkgs: name: spec:
65+
66+
if ! builtins.hasAttr "type" spec then
67+
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
68+
else if spec.type == "file" then fetch_file pkgs spec
69+
else if spec.type == "tarball" then fetch_tarball pkgs name spec
70+
else if spec.type == "git" then fetch_git spec
71+
else if spec.type == "local" then fetch_local spec
72+
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
73+
else if spec.type == "builtin-url" then fetch_builtin-url name
74+
else
75+
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
76+
77+
# If the environment variable NIV_OVERRIDE_${name} is set, then use
78+
# the path directly as opposed to the fetched source.
79+
replace = name: drv:
80+
let
81+
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
82+
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
83+
in
84+
if ersatz == "" then drv else ersatz;
85+
86+
# Ports of functions for older nix versions
87+
88+
# a Nix version of mapAttrs if the built-in doesn't exist
89+
mapAttrs = builtins.mapAttrs or (
90+
f: set: with builtins;
91+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
92+
);
93+
94+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
95+
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
96+
97+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
98+
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
99+
100+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
101+
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
102+
concatStrings = builtins.concatStringsSep "";
103+
104+
# fetchTarball version that is compatible between all the versions of Nix
105+
builtins_fetchTarball = { url, name, sha256 }@attrs:
106+
let
107+
inherit (builtins) lessThan nixVersion fetchTarball;
108+
in
109+
if lessThan nixVersion "1.12" then
110+
fetchTarball { inherit name url; }
111+
else
112+
fetchTarball attrs;
113+
114+
# fetchurl version that is compatible between all the versions of Nix
115+
builtins_fetchurl = { url, sha256 }@attrs:
116+
let
117+
inherit (builtins) lessThan nixVersion fetchurl;
118+
in
119+
if lessThan nixVersion "1.12" then
120+
fetchurl { inherit url; }
121+
else
122+
fetchurl attrs;
123+
124+
# Create the final "sources" from the config
125+
mkSources = config:
126+
mapAttrs (
127+
name: spec:
128+
if builtins.hasAttr "outPath" spec
129+
then abort
130+
"The values in sources.json should not have an 'outPath' attribute"
131+
else
132+
spec // { outPath = replace name (fetch config.pkgs name spec); }
133+
) config.sources;
134+
135+
# The "config" used by the fetchers
136+
mkConfig =
137+
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
138+
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
139+
, pkgs ? mkPkgs sources
140+
}: rec {
141+
# The sources, i.e. the attribute set of spec name to spec
142+
inherit sources;
143+
144+
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
145+
inherit pkgs;
146+
};
147+
148+
in
149+
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

nix/sources.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"niv": {
3+
"branch": "master",
4+
"description": "Easy dependency management for Nix projects",
5+
"homepage": "https://github.com/nmattia/niv",
6+
"owner": "nmattia",
7+
"repo": "niv",
8+
"rev": "9cb7ef336bb71fd1ca84fc7f2dff15ef4b033f2a",
9+
"sha256": "1ajyqr8zka1zlb25jx1v4xys3zqmdy3prbm1vxlid6ah27a8qnzh",
10+
"type": "tarball",
11+
"url": "https://github.com/nmattia/niv/archive/9cb7ef336bb71fd1ca84fc7f2dff15ef4b033f2a.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"nixpkgs": {
15+
"branch": "release-21.11",
16+
"description": "Nix Packages collection",
17+
"homepage": "",
18+
"owner": "NixOS",
19+
"repo": "nixpkgs",
20+
"rev": "4afca382d80b68bff9e154a97210e5a7bf5df8b3",
21+
"sha256": "0yf9g5bd69fz8h3ij83481pwhq8nsjddxr010bd8ya3hi1kn6w25",
22+
"type": "tarball",
23+
"url": "https://github.com/NixOS/nixpkgs/archive/4afca382d80b68bff9e154a97210e5a7bf5df8b3.tar.gz",
24+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+
},
26+
"nixpkgs-20.09": {
27+
"branch": "nixos-20.09",
28+
"description": "Nix Packages collection",
29+
"homepage": "",
30+
"owner": "nixos",
31+
"repo": "nixpkgs",
32+
"rev": "1c1f5649bb9c1b0d98637c8c365228f57126f361",
33+
"sha256": "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl",
34+
"type": "tarball",
35+
"url": "https://github.com/nixos/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz",
36+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+
},
38+
"nixpkgs-unstable": {
39+
"branch": "master",
40+
"description": "Nix Packages collection",
41+
"homepage": "",
42+
"owner": "NixOS",
43+
"repo": "nixpkgs",
44+
"rev": "03b52fe38897fc5705a9045ab04be68d6d49f702",
45+
"sha256": "0pv0770bnnlpd3m9x92kgc5zl0vaq0qx46wair4i536p88n2d1aq",
46+
"type": "tarball",
47+
"url": "https://github.com/NixOS/nixpkgs/archive/03b52fe38897fc5705a9045ab04be68d6d49f702.tar.gz",
48+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
49+
}
50+
}

0 commit comments

Comments
 (0)