bashcov 3.1.3 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/flake.lock ADDED
@@ -0,0 +1,139 @@
1
+ {
2
+ "nodes": {
3
+ "devshell": {
4
+ "inputs": {
5
+ "nixpkgs": [
6
+ "nixpkgs"
7
+ ],
8
+ "systems": "systems"
9
+ },
10
+ "locked": {
11
+ "lastModified": 1688380630,
12
+ "narHash": "sha256-8ilApWVb1mAi4439zS3iFeIT0ODlbrifm/fegWwgHjA=",
13
+ "owner": "numtide",
14
+ "repo": "devshell",
15
+ "rev": "f9238ec3d75cefbb2b42a44948c4e8fb1ae9a205",
16
+ "type": "github"
17
+ },
18
+ "original": {
19
+ "owner": "numtide",
20
+ "repo": "devshell",
21
+ "type": "github"
22
+ }
23
+ },
24
+ "flake-compat": {
25
+ "flake": false,
26
+ "locked": {
27
+ "lastModified": 1673956053,
28
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
29
+ "owner": "edolstra",
30
+ "repo": "flake-compat",
31
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
32
+ "type": "github"
33
+ },
34
+ "original": {
35
+ "owner": "edolstra",
36
+ "repo": "flake-compat",
37
+ "type": "github"
38
+ }
39
+ },
40
+ "flake-parts": {
41
+ "inputs": {
42
+ "nixpkgs-lib": "nixpkgs-lib"
43
+ },
44
+ "locked": {
45
+ "lastModified": 1688466019,
46
+ "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
47
+ "owner": "hercules-ci",
48
+ "repo": "flake-parts",
49
+ "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec",
50
+ "type": "github"
51
+ },
52
+ "original": {
53
+ "owner": "hercules-ci",
54
+ "repo": "flake-parts",
55
+ "type": "github"
56
+ }
57
+ },
58
+ "nixpkgs": {
59
+ "locked": {
60
+ "lastModified": 1689137672,
61
+ "narHash": "sha256-QZoHxr0a73x6rQcAo5CiwYpysHbSnk7lAR8/16um7mM=",
62
+ "owner": "NixOS",
63
+ "repo": "nixpkgs",
64
+ "rev": "98da3dd0de6660d4abed7bb74e748694bd803413",
65
+ "type": "github"
66
+ },
67
+ "original": {
68
+ "owner": "NixOS",
69
+ "ref": "nixos-23.05",
70
+ "repo": "nixpkgs",
71
+ "type": "github"
72
+ }
73
+ },
74
+ "nixpkgs-lib": {
75
+ "locked": {
76
+ "dir": "lib",
77
+ "lastModified": 1688049487,
78
+ "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=",
79
+ "owner": "NixOS",
80
+ "repo": "nixpkgs",
81
+ "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9",
82
+ "type": "github"
83
+ },
84
+ "original": {
85
+ "dir": "lib",
86
+ "owner": "NixOS",
87
+ "ref": "nixos-unstable",
88
+ "repo": "nixpkgs",
89
+ "type": "github"
90
+ }
91
+ },
92
+ "root": {
93
+ "inputs": {
94
+ "devshell": "devshell",
95
+ "flake-compat": "flake-compat",
96
+ "flake-parts": "flake-parts",
97
+ "nixpkgs": "nixpkgs",
98
+ "treefmt-nix": "treefmt-nix"
99
+ }
100
+ },
101
+ "systems": {
102
+ "locked": {
103
+ "lastModified": 1681028828,
104
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
105
+ "owner": "nix-systems",
106
+ "repo": "default",
107
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
108
+ "type": "github"
109
+ },
110
+ "original": {
111
+ "owner": "nix-systems",
112
+ "repo": "default",
113
+ "type": "github"
114
+ }
115
+ },
116
+ "treefmt-nix": {
117
+ "inputs": {
118
+ "nixpkgs": [
119
+ "nixpkgs"
120
+ ]
121
+ },
122
+ "locked": {
123
+ "lastModified": 1689070229,
124
+ "narHash": "sha256-99VU2FTkEdO3/1Qr78fHWWlN5GaOGLaXDi26PNiUf+I=",
125
+ "owner": "numtide",
126
+ "repo": "treefmt-nix",
127
+ "rev": "3c54278bf7b8642eba174a22ca02d5552c21dc0b",
128
+ "type": "github"
129
+ },
130
+ "original": {
131
+ "owner": "numtide",
132
+ "repo": "treefmt-nix",
133
+ "type": "github"
134
+ }
135
+ }
136
+ },
137
+ "root": "root",
138
+ "version": 7
139
+ }
data/flake.nix ADDED
@@ -0,0 +1,225 @@
1
+ {
2
+ description = "Code coverage tool for Bash";
3
+
4
+ inputs = {
5
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
6
+
7
+ devshell.url = "github:numtide/devshell";
8
+ devshell.inputs.nixpkgs.follows = "nixpkgs";
9
+
10
+ flake-compat.url = "github:edolstra/flake-compat";
11
+ flake-compat.flake = false;
12
+
13
+ flake-parts.url = "github:hercules-ci/flake-parts";
14
+
15
+ treefmt-nix.url = "github:numtide/treefmt-nix";
16
+ treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
17
+ };
18
+
19
+ outputs = inputs @ {
20
+ self,
21
+ devshell,
22
+ flake-parts,
23
+ treefmt-nix,
24
+ ...
25
+ }:
26
+ flake-parts.lib.mkFlake {inherit inputs;} ({lib, ...}: {
27
+ systems = [
28
+ "aarch64-darwin"
29
+ "aarch64-linux"
30
+ "x86_64-darwin"
31
+ "x86_64-linux"
32
+ ];
33
+
34
+ imports = [
35
+ devshell.flakeModule
36
+ flake-parts.flakeModules.easyOverlay
37
+ treefmt-nix.flakeModule
38
+ ];
39
+
40
+ perSystem = {
41
+ config,
42
+ pkgs,
43
+ self',
44
+ system,
45
+ ...
46
+ }: let
47
+ newestRuby = let
48
+ rubies = lib.filterAttrs (name: value: let
49
+ hasRubyEngine = builtins.tryEval (value ? rubyEngine);
50
+ in
51
+ lib.hasPrefix "ruby" name && hasRubyEngine.success && hasRubyEngine.value)
52
+ pkgs;
53
+
54
+ recentRubies =
55
+ lib.foldlAttrs (
56
+ acc: name: value: let
57
+ v = toString value.version;
58
+ in
59
+ acc ++ (lib.optional (lib.versionAtLeast v "3" && lib.versionOlder v "4") {inherit name value;})
60
+ ) []
61
+ rubies;
62
+
63
+ sortedRubies = lib.sort (x: y: lib.versionAtLeast (toString x.value.version) (toString y.value.version)) recentRubies;
64
+ in
65
+ if (lib.length sortedRubies) > 0
66
+ then lib.head sortedRubies
67
+ else {
68
+ name = "ruby";
69
+ value = pkgs.ruby;
70
+ };
71
+
72
+ ruby = newestRuby.value;
73
+ rubyName = newestRuby.name;
74
+ in {
75
+ # `nix run '.#devshell' -- update-deps`, etc.
76
+ apps.devshell = self'.devShells.default.flakeApp;
77
+
78
+ checks = {
79
+ inherit (config.packages) bashcov;
80
+ };
81
+
82
+ devshells.default = {
83
+ imports = [
84
+ # Ruby support, including prerequisites for compiling native
85
+ # extensions.
86
+ "${inputs.devshell}/extra/language/ruby.nix"
87
+ ];
88
+
89
+ commands = [
90
+ {
91
+ name = "fmt";
92
+ category = "linting";
93
+ help = "Format the Nix code in this project";
94
+ command = ''
95
+ exec ${config.treefmt.build.wrapper}/bin/treefmt "$@"
96
+ '';
97
+ }
98
+
99
+ {
100
+ package = ruby;
101
+ category = "development";
102
+ }
103
+
104
+ {
105
+ package = pkgs.bundix;
106
+ category = "maintenance";
107
+ }
108
+
109
+ {
110
+ name = "update-deps";
111
+ category = "maintenance";
112
+ help = "Update dependencies with Bundler and Bundix";
113
+ command = ''
114
+ export NIX_PATH="nixpkgs=${toString pkgs.path}''${NIX_PATH:+:''${NIX_PATH}}"
115
+ lockfile="''${PRJ_ROOT:-.}/Gemfile.nix.lock"
116
+ bundle lock --lockfile "$lockfile"
117
+ exec bundix --ruby ${lib.escapeShellArg rubyName} --lockfile="$lockfile" "$@"
118
+ '';
119
+ }
120
+
121
+ {
122
+ name = "update-deps-conservative";
123
+ category = "maintenance";
124
+ help = "Update dependencies with Bundler and Bundix (if necessary)";
125
+
126
+ # If `nix build` succeeds, then presume that the lockfiles do not
127
+ # need to be updated. If `nix build` fails after updating the
128
+ # lockfile, out-of-date dependencies weren't to blame for the
129
+ # build failure.
130
+ command = ''
131
+ export NIX_PATH="nixpkgs=${toString pkgs.path}''${NIX_PATH:+:''${NIX_PATH}}"
132
+ nix build && exit
133
+ if update-deps; then
134
+ nix build || {
135
+ rc="$?"
136
+ git restore "''${PRJ_ROOT}/Gemfile.nix.lock" "''${PRJ_ROOT}/gemset.nix" || rc="$?"
137
+ exit "$rc"
138
+ }
139
+ fi
140
+ '';
141
+ }
142
+ ];
143
+ };
144
+
145
+ overlayAttrs = {
146
+ inherit (config.packages) bashcov;
147
+ };
148
+
149
+ packages = {
150
+ bashcov = pkgs.callPackage ({
151
+ lib,
152
+ bash,
153
+ buildRubyGem,
154
+ makeWrapper,
155
+ ruby,
156
+ gems,
157
+ doCheck ? true, # Whether to run RSpec and Cucumber Rake tasks.
158
+ }: let
159
+ inherit (gems'.gems.bashcov) version;
160
+ gems' = gems.override {inherit ruby;};
161
+ gemName = gems'.gems.bashcov.name;
162
+ in
163
+ assert lib.assertMsg (gems'.gems ? bashcov) "bashcov: gem set must contain `bashcov`";
164
+ buildRubyGem {
165
+ inherit doCheck gemName version ruby;
166
+
167
+ name = "${gemName}-${version}";
168
+
169
+ src = self;
170
+
171
+ nativeBuildInputs = [bash makeWrapper];
172
+ propagatedBuildInputs = [gems'];
173
+
174
+ checkPhase = ''
175
+ ${config.packages.gems.wrappedRuby}/bin/rake cucumber spec
176
+ '';
177
+
178
+ # Replace shebangs like "#!/usr/bin/env bash" with Nix store
179
+ # paths. Note that we need to do this for `./bin/bashcov`
180
+ # itself, as otherwise running `bashcov` from Cucumber features
181
+ # during the check phase will fail because `/usr/bin/env` does
182
+ # not exist in the build sandbox.
183
+ doPatch = true;
184
+ postPatch = ''
185
+ patchShebangs ./bin ./features ./spec
186
+ '';
187
+
188
+ # Ensure that Bashcov can find Bash, but make this Bash
189
+ # low-precedence by placing its /bin/ at the end of PATH.
190
+ postInstall = ''
191
+ wrapProgram $out/bin/bashcov --suffix PATH : ${bash}/bin
192
+ '';
193
+ }) {
194
+ inherit ruby;
195
+ inherit (config.packages) gems;
196
+ };
197
+
198
+ default = config.packages.bashcov;
199
+
200
+ gems = pkgs.callPackage ({
201
+ bundlerEnv,
202
+ ruby,
203
+ }:
204
+ bundlerEnv {
205
+ inherit ruby;
206
+ pname = "bashcov";
207
+ gemdir = self;
208
+ lockfile = ./Gemfile.nix.lock;
209
+ version = "3.0.2";
210
+ postBuild = ''
211
+ for gem in $out/${ruby.gemPath}/bundler/gems/*; do
212
+ ln -sfrT "$gem" $out/${ruby.gemPath}/gems/"''${gem##*/}"
213
+ done
214
+ '';
215
+ }) {inherit ruby;};
216
+ };
217
+
218
+ treefmt = {
219
+ programs.alejandra.enable = true;
220
+ flakeFormatter = true;
221
+ projectRootFile = "flake.nix";
222
+ };
223
+ };
224
+ });
225
+ }