graphwerk 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7af64b8123b10c0d175ca2b59b321cd0a5140ce3216dfc1d2bd5851f362b5642
4
- data.tar.gz: 05c51382e40bc20ebf51deb955a2bf6b715ee3992f7ceb379d638233cfe998c9
3
+ metadata.gz: 14fe65bc2ddbecc3e621774f3ce56173f837ef84c8967e66238b4e1914f86134
4
+ data.tar.gz: c5a2218164c40cce1fa5c9131e581754fdd7797b1ae3e96d024b25701f249c0a
5
5
  SHA512:
6
- metadata.gz: 1cef57b21fe954604e46777f4a35a8200c0bf33f4b0b7a36345faf6a38eb1af2ddbe86462cb79a9bd3ddf90fa3fc7845168b317f59fbd717f1f54e1cda5e88e8
7
- data.tar.gz: fdd4b9b472b4ea595f0e13929448459a7524d10e2edf9efa2f5ef77afc77df2c61e1fe99af2f6bb66b2178974c954e9a823d02301fa71beacaaec8c1228f9bff
6
+ metadata.gz: 84160d2620769c3347b418a4a583b1b9226f564eb7d1cb4159e985ed4451fa98da6d020f353058fe0615a103d1860156215ffae6c9c9c185df0c7ce5a2185827
7
+ data.tar.gz: 18a3046303f1c74d48bb87638ba43a978fdaa7189543154da95a4565d5b2ba80e389aa002e0b6610e3d0c4f7b90f4ab4b193b3bc1f2e427466fc9779db5f727f
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: Continuous Integration
3
+ on:
4
+ push:
5
+ branches-ignore:
6
+ - refs/tags/*_staging
7
+ - refs/tags/*_production
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-18.04
11
+ steps:
12
+ - name: Checkout branch
13
+ uses: actions/checkout@v2
14
+ - name: Extract branch name
15
+ shell: bash
16
+ run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
17
+ id: extract_branch
18
+ - name: Cache gems
19
+ uses: actions/cache@v2
20
+ with:
21
+ path: vendor/bundle
22
+ key: "${{ runner.OS }}-gem-cache-${{ hashFiles('**/*.gemspec')
23
+ }}"
24
+ restore-keys: "${{ runner.OS }}-gem-cache-\n"
25
+ - uses: "cachix/install-nix-action@8d6d5e949675fbadb765c6b1a975047fa5f09b27"
26
+ with:
27
+ extra_nix_config: |
28
+ post-build-hook = /etc/nix/upload-to-cache.sh
29
+ substituters = https://cache.nixos.org/
30
+ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
31
+ nix_path: nixpkgs=channel:nixos-21.05
32
+ - name: Run CI through nix-shell
33
+ env:
34
+ GEMFURY_DEPLOY_TOKEN: ${{ secrets.GEMFURY_DEPLOY_TOKEN }}
35
+ run: nix-shell --run "chmod 755 ./run_ci.sh && ./run_ci.sh"
36
+ - name: Post to Slack if build fails
37
+ if: failure() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
38
+ || github.ref == 'refs/heads/stable')
39
+ uses: pullreminders/slack-action@a5a262c896a1cc80dcbae59ba95513e2dfb21439
40
+ env:
41
+ SLACK_BOT_TOKEN: "${{ secrets.SLACK_BOT_TOKEN }}"
42
+ with:
43
+ args: '{\"channel\":\"C33574SJJ\",\"text\":\"* ${{ github.repository }} BUILD
44
+ FAILURE*\", \"attachments\": [{ \"fallback\": \"Failure summary\", \"color\":
45
+ \"#ff0000\", \"fields\": [{\"title\": \"Branch\", \"value\":\"${{ steps.extract_branch.outputs.branch
46
+ }}\"}, {\"title\": \"Who broke it\", \"value\":\"${{ github.actor }}\"},
47
+ { \"title\": \"Build output\", \"value\": \"https://github.com/${{ github.repository
48
+ }}/commit/${{ github.sha }}/checks\", \"short\": false }]}]}'
data/.gitignore CHANGED
@@ -20,3 +20,5 @@
20
20
  .DS_Store
21
21
 
22
22
  .ruby-gemset
23
+ .direnv
24
+ .envrc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 1.2.1
2
+
3
+ * Add some nicer error messages when dependencies are not found
4
+ * Use Tapioca for RBI generation
5
+ * Use Nix for development environment and CI (Bellroy standard)
6
+
1
7
  1.2.0
2
8
 
3
9
  * Deprecated references are now drawn on the output graph.
data/Gemfile CHANGED
@@ -10,5 +10,4 @@ group :development, :test do
10
10
  gem 'rb-fsevent', require: false
11
11
  gem 'rb-readline'
12
12
  gem 'rspec'
13
- gem 'shoulda-matchers', require: false
14
13
  end
data/bin/tapioca ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("tapioca", "tapioca")
data/graphwerk.gemspec CHANGED
@@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'sorbet'
35
35
  spec.add_development_dependency 'rspec-sorbet'
36
+ spec.add_development_dependency 'tapioca'
36
37
  end
@@ -104,6 +104,9 @@ module Graphwerk
104
104
  sig { params(package: Presenters::Package).void }
105
105
  def draw_dependencies(package)
106
106
  package.dependencies.each do |dependency|
107
+ unless @nodes[dependency]
108
+ abort "Unable to add edge `#{package.name}`->`#{dependency}`"
109
+ end
107
110
  @graph.add_edges(@nodes[package.name], @nodes[dependency], color: package.color)
108
111
  end
109
112
  end
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: ignore
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Graphwerk
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Graphwerk
5
- VERSION = '1.2.0'
5
+ VERSION = '1.2.1'
6
6
  end
data/nix/sources.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "nixpkgs": {
3
+ "branch": "nixos-21.05",
4
+ "description": "Nix packages collection",
5
+ "homepage": "https://github.com/NixOS/nixpkgs",
6
+ "owner": "NixOS",
7
+ "repo": "nixpkgs",
8
+ "rev": "e85f0175e3effe9ba191d66c09e8f1b7d6362d5e",
9
+ "sha256": "1qr2hmymbzwj8jrz6smcgc04scgwp2v5070x22k4fvh261g1n4zw",
10
+ "type": "tarball",
11
+ "url": "https://github.com/NixOS/nixpkgs/archive/e85f0175e3effe9ba191d66c09e8f1b7d6362d5e.tar.gz",
12
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13
+ }
14
+ }
data/nix/sources.nix ADDED
@@ -0,0 +1,174 @@
1
+ # This file has been generated by Niv.
2
+
3
+ let
4
+
5
+ #
6
+ # The fetchers. fetch_<type> fetches specs of type <type>.
7
+ #
8
+
9
+ fetch_file = pkgs: name: spec:
10
+ let
11
+ name' = sanitizeName name + "-src";
12
+ in
13
+ if spec.builtin or true then
14
+ builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15
+ else
16
+ pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
17
+
18
+ fetch_tarball = pkgs: name: spec:
19
+ let
20
+ name' = sanitizeName 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 = name: spec:
28
+ let
29
+ ref =
30
+ if spec ? ref then spec.ref else
31
+ if spec ? branch then "refs/heads/${spec.branch}" else
32
+ if spec ? tag then "refs/tags/${spec.tag}" else
33
+ abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
34
+ in
35
+ builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
36
+
37
+ fetch_local = spec: spec.path;
38
+
39
+ fetch_builtin-tarball = name: throw
40
+ ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
41
+ $ niv modify ${name} -a type=tarball -a builtin=true'';
42
+
43
+ fetch_builtin-url = name: throw
44
+ ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
45
+ $ niv modify ${name} -a type=file -a builtin=true'';
46
+
47
+ #
48
+ # Various helpers
49
+ #
50
+
51
+ # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
52
+ sanitizeName = name:
53
+ (
54
+ concatMapStrings (s: if builtins.isList s then "-" else s)
55
+ (
56
+ builtins.split "[^[:alnum:]+._?=-]+"
57
+ ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
58
+ )
59
+ );
60
+
61
+ # The set of packages used when specs are fetched using non-builtins.
62
+ mkPkgs = sources: system:
63
+ let
64
+ sourcesNixpkgs =
65
+ import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
66
+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
67
+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
68
+ in
69
+ if builtins.hasAttr "nixpkgs" sources
70
+ then sourcesNixpkgs
71
+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
72
+ import <nixpkgs> {}
73
+ else
74
+ abort
75
+ ''
76
+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
77
+ add a package called "nixpkgs" to your sources.json.
78
+ '';
79
+
80
+ # The actual fetching function.
81
+ fetch = pkgs: name: spec:
82
+
83
+ if ! builtins.hasAttr "type" spec then
84
+ abort "ERROR: niv spec ${name} does not have a 'type' attribute"
85
+ else if spec.type == "file" then fetch_file pkgs name spec
86
+ else if spec.type == "tarball" then fetch_tarball pkgs name spec
87
+ else if spec.type == "git" then fetch_git name spec
88
+ else if spec.type == "local" then fetch_local spec
89
+ else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
90
+ else if spec.type == "builtin-url" then fetch_builtin-url name
91
+ else
92
+ abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
93
+
94
+ # If the environment variable NIV_OVERRIDE_${name} is set, then use
95
+ # the path directly as opposed to the fetched source.
96
+ replace = name: drv:
97
+ let
98
+ saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
99
+ ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
100
+ in
101
+ if ersatz == "" then drv else
102
+ # this turns the string into an actual Nix path (for both absolute and
103
+ # relative paths)
104
+ if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
105
+
106
+ # Ports of functions for older nix versions
107
+
108
+ # a Nix version of mapAttrs if the built-in doesn't exist
109
+ mapAttrs = builtins.mapAttrs or (
110
+ f: set: with builtins;
111
+ listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
112
+ );
113
+
114
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
115
+ range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
116
+
117
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
118
+ stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
119
+
120
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
121
+ stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
122
+ concatMapStrings = f: list: concatStrings (map f list);
123
+ concatStrings = builtins.concatStringsSep "";
124
+
125
+ # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
126
+ optionalAttrs = cond: as: if cond then as else {};
127
+
128
+ # fetchTarball version that is compatible between all the versions of Nix
129
+ builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
130
+ let
131
+ inherit (builtins) lessThan nixVersion fetchTarball;
132
+ in
133
+ if lessThan nixVersion "1.12" then
134
+ fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
135
+ else
136
+ fetchTarball attrs;
137
+
138
+ # fetchurl version that is compatible between all the versions of Nix
139
+ builtins_fetchurl = { url, name ? null, sha256 }@attrs:
140
+ let
141
+ inherit (builtins) lessThan nixVersion fetchurl;
142
+ in
143
+ if lessThan nixVersion "1.12" then
144
+ fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
145
+ else
146
+ fetchurl attrs;
147
+
148
+ # Create the final "sources" from the config
149
+ mkSources = config:
150
+ mapAttrs (
151
+ name: spec:
152
+ if builtins.hasAttr "outPath" spec
153
+ then abort
154
+ "The values in sources.json should not have an 'outPath' attribute"
155
+ else
156
+ spec // { outPath = replace name (fetch config.pkgs name spec); }
157
+ ) config.sources;
158
+
159
+ # The "config" used by the fetchers
160
+ mkConfig =
161
+ { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
162
+ , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
163
+ , system ? builtins.currentSystem
164
+ , pkgs ? mkPkgs sources system
165
+ }: rec {
166
+ # The sources, i.e. the attribute set of spec name to spec
167
+ inherit sources;
168
+
169
+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
170
+ inherit pkgs;
171
+ };
172
+
173
+ in
174
+ mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
data/run_ci.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+ rm -f Gemfile.lock
4
+ bundle install
5
+ bundle exec srb tc
6
+ bundle exec rspec spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giles
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: tapioca
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description:
154
168
  email:
155
169
  - samuel.giles@bellroy.com
@@ -157,10 +171,10 @@ executables: []
157
171
  extensions: []
158
172
  extra_rdoc_files: []
159
173
  files:
174
+ - ".github/workflows/ci.yml"
160
175
  - ".github/workflows/rspec.yml"
161
176
  - ".gitignore"
162
177
  - ".rspec"
163
- - ".ruby-version"
164
178
  - CHANGELOG.md
165
179
  - Gemfile
166
180
  - LICENSE.txt
@@ -168,6 +182,7 @@ files:
168
182
  - Rakefile
169
183
  - bin/console
170
184
  - bin/setup
185
+ - bin/tapioca
171
186
  - graphwerk.gemspec
172
187
  - lib/graphwerk.rb
173
188
  - lib/graphwerk/builders/graph.rb
@@ -178,6 +193,9 @@ files:
178
193
  - lib/graphwerk/railtie.rb
179
194
  - lib/graphwerk/tasks/rails.rake
180
195
  - lib/graphwerk/version.rb
196
+ - nix/sources.json
197
+ - nix/sources.nix
198
+ - run_ci.sh
181
199
  homepage: https://github.com/tricycle/graphwerk
182
200
  licenses:
183
201
  - MIT
@@ -197,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
215
  - !ruby/object:Gem::Version
198
216
  version: '0'
199
217
  requirements: []
200
- rubygems_version: 3.0.3
218
+ rubygems_version: 3.2.16
201
219
  signing_key:
202
220
  specification_version: 4
203
221
  summary: Visualise dependencies between your application and it's Packwerk packages
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.6.6