Skip to content

Commit

Permalink
Merge pull request #358 from input-output-hk/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
  • Loading branch information
rhyslbw authored Sep 17, 2020
2 parents 98524ca + 622701d commit c1ba20a
Show file tree
Hide file tree
Showing 1,997 changed files with 420 additions and 344 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Lint and test
env:
CI: true
run: |
yarn --offline --frozen-lockfile --non-interactive
yarn lint
yarn static:build
yarn test
yarn static:serve -l 4000 &
yarn test:e2e
34 changes: 0 additions & 34 deletions .github/workflows/tests.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarn-offline-mirror "./packages-cache"
yarn-offline-mirror-pruning true
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

## 1.1.0
### Features
- [Split slots & blocks into separate columns](https://github.com/input-output-hk/cardano-explorer-app/pull/338)
- [Add package.json version to footer](https://github.com/input-output-hk/cardano-explorer-app/pull/348)
### Chores
- [Dynamically calc Byron epochs length](https://github.com/input-output-hk/cardano-explorer-app/pull/334)
- [Update to latest react-polymorph](https://github.com/input-output-hk/cardano-explorer-app/pull/351)
- [yarn offline cache](https://github.com/input-output-hk/cardano-explorer-app/pull/356)
## 1.0.2
### Fixes
- [#334](https://github.com/input-output-hk/cardano-explorer-app/issues/334)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ See [environment](source/environment.ts) for defaults.
- `DEBUG`

## Build
This project uses an offline package cache to enable reproducible builds.
```console
yarn && yarn static:build
yarn --offline && yarn static:build
```
## Deploy
The static bundle can be deployed using a standard web server. A simple [Node.js program](deploy/index.js)
Expand Down
5 changes: 1 addition & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
}:

let pkgs = import ./nix/pkgs.nix { }; in pkgs.packages
(import ./nix/pkgs.nix {}).packages
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const withImages = require('next-images');
const withPrefresh = require('@prefresh/next');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const DefinePlugin = require('webpack').DefinePlugin;
require('dotenv').config();

const DEBUG = process.env.DEBUG;
const packageJson = require('./package.json');
const SUPPORTED_LOCALES = ['en', 'de', 'ja'];

module.exports = withPlugins(
Expand Down Expand Up @@ -69,6 +71,14 @@ module.exports = withPlugins(
})
);

config.plugins.push(
new DefinePlugin({
'process.env': {
PACKAGE_HOMEPAGE: `"${packageJson.homepage}"`,
PACKAGE_VERSION: `"${packageJson.version}"`
}
}));

// Support GraphQL literals
config.module.rules.push({
test: /\.(graphql|gql)$/,
Expand Down
70 changes: 70 additions & 0 deletions nix/cardano-explorer-app.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{ stdenv
, nix-inclusive
, nodejs
, nodePackages
, runtimeShell
, sources
, yarn
}:

let
packageJSON = builtins.fromJSON (builtins.readFile ../package.json);

src = stdenv.mkDerivation {
pname = "${packageJSON.name}-src";
version = packageJSON.version;
buildInputs = [ yarn nodejs ];
src = nix-inclusive ./.. [
../yarn.lock
../.yarnrc
../package.json
../packages-cache
../tsconfig.json
../source
../cypress
../.storybook
../codegen.yml
../.babelrc
../stories
../cypress.json
../jest.config.js
../next.config.js
../postcss.config.js
../tslint.json
../wallaby.conf.js
];
buildCommand = ''
export HOME=$NIX_BUILD_TOP
mkdir -p $out
cp -r $src/. $out/
chmod -R u+w $out
cd $out
export CYPRESS_INSTALL_BINARY=0
yarn --offline --frozen-lockfile --non-interactive
'';
};

in stdenv.mkDerivation {
pname = packageJSON.name;
version = packageJSON.version;
inherit src;
buildInputs = [ nodejs yarn ];
buildCommand = ''
mkdir -p $out
cp -r $src/. $out/
chmod -R u+w $out
patchShebangs $out
cd $out
yarn build
find . -name node_modules -type d -print0 | xargs -0 rm -rf
yarn --production --offline --frozen-lockfile --non-interactive
mkdir -p $out/bin
cat <<EOF > $out/bin/${packageJSON.name}
#!${runtimeShell}
exec ${nodejs}/bin/node $out/packages/server/dist/index.js
EOF
chmod +x $out/bin/${packageJSON.name}
'';
} // { inherit src; }
47 changes: 12 additions & 35 deletions nix/packages.nix
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
{ lib, pkgs }:

let
src = lib.cleanSourceWith {
filter = lib.cleanSourceFilter;
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
sansPrefix = lib.removePrefix (toString ../.) name;
in_blacklist =
lib.hasPrefix "/node_modules" sansPrefix ||
lib.hasPrefix "/build" sansPrefix;
in_whitelist =
(type == "directory") ||
(lib.hasSuffix ".yml" name) ||
#(lib.hasSuffix ".js" name) ||
(lib.hasSuffix ".ts" name) ||
#(lib.hasSuffix ".tsx" name) ||
(lib.hasSuffix ".json" name) ||
#(lib.hasSuffix ".graphql" name) ||
#(lib.hasPrefix "/source/public/assets" sansPrefix) ||
(lib.hasPrefix "/source" sansPrefix) ||
baseName == ".babelrc" ||
baseName == "package.json" ||
baseName == "next.config.js" ||
baseName == "yarn.lock" ||
(lib.hasPrefix "/deploy" sansPrefix);
in (
(!in_blacklist) && in_whitelist
);
src = ../.;
};
};
nodePackages = pkgs.callPackage ./node-packages {};
packages = self: {
inherit src;
whitelist = pkgs.runCommand "whitelist.json" { buildInputs = [ nodePackages.persistgraphql ]; } ''
persistgraphql ${src} $out
sources = import ./sources.nix;
allowList = pkgs.runCommand "allowList.json" { buildInputs = [ nodePackages.persistgraphql ]; } ''
persistgraphql ${self.cardano-explorer-app.src} $out
'';
static = self.callPackage ./static.nix {};
yarn-static = self.callPackage ./yarn2nix.nix {};
nodejs = pkgs.nodejs-12_x;
nix-inclusive = pkgs.callPackage "${self.sources.nix-inclusive}/inclusive.nix" {};
static = self.callPackage ./static.nix {
src = self.cardano-explorer-app;
};
yarn-static = self.callPackage ./yarn2nix.nix {
inherit (pkgs.yarn2nix-moretea) importOfflineCache mkYarnNix;
};
inherit (self.yarn-static.passthru) offlinecache;
cardano-explorer-app = self.callPackage ./cardano-explorer-app.nix {};
};
in pkgs.lib.makeScope pkgs.newScope packages
17 changes: 5 additions & 12 deletions nix/pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{ sources ? import ./sources.nix
}:
{ sources ? import ./sources.nix }:

let
# TODO: filter src to just the files needed to build
src = ../.;
iohkNix = import sources.iohk-nix {};
overlay = self: super: {
inherit (import sources.niv {}) niv;
packages = self.callPackage ./packages.nix { };
node = super.nodejs-12_x;
inherit (import sources.yarn2nix { pkgs = self; }) yarn2nix mkYarnModules mkYarnPackage importOfflineCache mkYarnNix fixup_yarn_lock;
packages = self.callPackages ./packages.nix { };
};
in
import sources.nixpkgs {
overlays = [ overlay ];
config = {};
}
import iohkNix.nixpkgs { overlays = [ overlay ]; config = {}; }
46 changes: 11 additions & 35 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,22 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "76864277730cca14d42db7965bf4a8b42d7d5997",
"sha256": "1jc41r44lh5nwwb7453kcn1hh3dx90qb0qkmnmh1hrwpgq3l5mv5",
"rev": "edfa1fdbe68fe0023b1a9a231bb41e7a757cb829",
"sha256": "09366r2kprvaxx38y9qk05zxqcgkh89x34n6ck1hkvncjg6r9bfc",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/76864277730cca14d42db7965bf4a8b42d7d5997.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/edfa1fdbe68fe0023b1a9a231bb41e7a757cb829.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "iohk",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "input-output-hk",
"repo": "niv",
"rev": "89da7b2e7ae0779fd351618fc74df1b1da5e6214",
"sha256": "0jn88ahv6mycxdkzihy1v0dz2110q0d42q4ggyj68l2lyba6y0yy",
"type": "tarball",
"url": "https://github.com/input-output-hk/niv/archive/89da7b2e7ae0779fd351618fc74df1b1da5e6214.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-19.09",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "d011e4749457af484adf2e90062c83a44ad072a4",
"sha256": "1nvhya0v98agidgxv83sb7xyb559qagx9f6iqknpxhxsv09j2qsp",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/d011e4749457af484adf2e90062c83a44ad072a4.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"yarn2nix": {
"nix-inclusive": {
"branch": "master",
"description": "Generate nix expressions from a yarn.lock file",
"homepage": null,
"owner": "moretea",
"repo": "yarn2nix",
"rev": "9e7279edde2a4e0f5ec04c53f5cd64440a27a1ae",
"sha256": "0zz2lrwn3y3rb8gzaiwxgz02dvy3s552zc70zvfqc0zh5dhydgn7",
"description": "Simple inclusive file selection implementation for Nix",
"homepage": "",
"owner": "input-output-hk",
"repo": "nix-inclusive",
"rev": "11d05e4f1ca04fd250a9734e27970ad73bbd872d",
"sha256": "0j0cfs5vpsnbk0bnz0bhfajgjhchd82cfhjp5qxkb68iqi9mg7z1",
"type": "tarball",
"url": "https://github.com/moretea/yarn2nix/archive/9e7279edde2a4e0f5ec04c53f5cd64440a27a1ae.tar.gz",
"url": "https://github.com/input-output-hk/nix-inclusive/archive/11d05e4f1ca04fd250a9734e27970ad73bbd872d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
10 changes: 4 additions & 6 deletions nix/static.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, yarn, nodejs, fixup_yarn_lock, offlinecache
{ stdenv, yarn, nodejs, offlinecache
, cardanoEra ? "byron"
, cardanoNetwork ? "mainnet"
, graphqlApiProtocol ? "https"
Expand All @@ -22,16 +22,14 @@ stdenv.mkDerivation {
GA_TRACKING_ID = gaTrackingId;
buildCommand = ''
export HOME=$PWD/yarn_home
unpackPhase
cd $sourceRoot
${fixup_yarn_lock}/bin/fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror ${offlinecache}
export CYPRESS_INSTALL_BINARY=0
yarn config set yarn-offline-mirror ${offlinecache}
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts
export PATH="$PATH:node_modules/.bin"
patchShebangs node_modules/
NODE_ENV=production yarn --offline run build
yarn --offline run next export source --outdir $out
yarn run next export source --outdir $out
'';
}
4 changes: 0 additions & 4 deletions nix/yarn2nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ in mkYarnPackage {
packageJSON = ../package.json;
yarnLock = ../yarn.lock;
src = src;
extraBuildInputs = [
#breakpointHook strace bashInteractive
];
yarnPreBuild = ''
mkdir -p $HOME/.node-gyp/${nodejs.version}
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
Expand All @@ -24,7 +21,6 @@ in mkYarnPackage {
yarn --offline run build
yarn run next export source --outdir $out
#ln -s $node_modules $out/node_modules
yarn export
ls -lh deps/cardano-explorer-app/build/static
Expand Down
Loading

0 comments on commit c1ba20a

Please sign in to comment.