File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 nix run .#checks.x86_64-linux.${feat%%.feature}.driver
3535 echo "::endgroup::"
3636 done
37+ - name : Save results
38+ uses : actions/upload-artifact@v7
39+ if : always()
40+ with :
41+ name : allure-output
42+ path : allure_output
43+
44+ push-reports :
45+ name : Upload HTML reports to Pages
46+ needs : run-tests
47+ if : always()
48+ runs-on : ubuntu-latest
49+ permissions :
50+ contents : write
51+ pages : write
52+ steps :
53+ - name : Checkout code
54+ uses : actions/checkout@v3
55+ - name : Fetch report
56+ uses : actions/download-artifact@v8
57+ with :
58+ name : allure-output
59+ path : allure_output
60+ - name : Deploy report to GitHub Pages
61+ uses : PavanMudigonda/html-reporter-github-pages@v1.5.21
62+ with :
63+ test_results : allure_output
64+ allure_report_generate_flag : true
65+ keep_reports : 10
66+ gh_pages : pages_reports
67+ workflow_name : ${{ github.workflow }}
Original file line number Diff line number Diff line change 11{ pkgs ? import <nixpkgs> { }
2- , system ? builtins . currentSystem
32, runTest ? pkgs . testers . nixosTest
43, defaultConfig ?
54 { ... } : { imports = [ ../vm.nix ] ; }
1716let
1817 lib = pkgs . lib ;
1918
19+ # Run a test and generate an HTML report
20+ behaveReport = test :
21+ ( pkgs . callPackage ./report.nix { inherit test ; } ) ;
22+
2023 # Run a single Behave feature file
21- behaveTest = featureName : as : runTest
22- ( import ./template.nix ( { inherit defaultConfig pkgs featureName ; } // as ) ) ;
24+ behaveTest = featureName : as :
25+ let testDrv = runTest
26+ ( import ./template.nix ( { inherit defaultConfig pkgs featureName ; } // as ) ) ;
27+ in testDrv // { report = behaveReport testDrv ; } ;
2328
29+ # Gather and generate tests for all feature files
2430 allBehaveTests =
2531 let allBehaveFiles =
2632 lib . filterAttrs ( k : v : lib . hasSuffix ".feature" k && v == "regular" )
Original file line number Diff line number Diff line change 22from pathlib import Path
33from behave import fixture , use_fixture
44
5+ import allure
56import cv2
67
78class NixOSNamespace (SimpleNamespace ):
@@ -57,6 +58,9 @@ def screenshot(self):
5758 featname = Path (self ._context .config .paths [0 ]).name [:- len (".feature" )]
5859 filename = f"scr-{ featname } -{ self ._context .scenario .line } _{ self ._last_scr_id } .png"
5960 self .machine .screenshot (filename )
61+
62+ with open (filename , 'rb' ) as imfile :
63+ allure .attach (imfile .read (), name = filename , attachment_type = allure .attachment_type .PNG )
6064 return cv2 .imread (filename )
6165
6266@fixture
Original file line number Diff line number Diff line change 1+ { pkgs , lib , stdenv , allure
2+ # A NixOS Behave test (with a .driver output) to run
3+ , test
4+ , ...} :
5+
6+ stdenv . mkDerivation {
7+ name = "${ test . name } -report" ;
8+ src = pkgs . emptyDirectory ;
9+
10+ nativeBuildInputs = [
11+ allure
12+ ] ;
13+
14+ buildPhase = ''
15+ ${ lib . getExe test . driver } || true
16+ '' ;
17+
18+ installPhase = ''
19+ mkdir -p $out
20+ allure generate allure_output -o $out
21+ '' ;
22+ }
Original file line number Diff line number Diff line change 77 name = featureName ;
88 nodes = { machine = defaultConfig ; } ;
99
10- extraPythonPackages = p : with p ; [ behave opencv-python ] ;
10+ extraPythonPackages = p : with p ; [ behave opencv-python allure-behave ] ;
1111
1212 skipTypeCheck = true ;
1313
1616 from behave.__main__ import run_behave
1717
1818 conf = Configuration("${ testsDir } /features/${ featureName } ", userdata = driver.test_symbols())
19- conf.capture_stdout = False
20- conf.capture_stderr = False
19+ conf.format = [ "allure_behave.formatter:AllureFormatter", "pretty" ]
20+ conf.outputs = []
21+ conf.setup_outputs(['allure_output'])
2122 start_all()
2223 exit(run_behave(conf))
2324 '' ;
You can’t perform that action at this time.
0 commit comments