Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Use Web3.js 1.7, tools.build, deps.edn
Browse files Browse the repository at this point in the history
  • Loading branch information
madis committed Apr 29, 2022
1 parent 8226b4a commit 057b946
Show file tree
Hide file tree
Showing 17 changed files with 8,731 additions and 5,175 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ target/
tests-output/
browser-tests-output/
.lein-failures
out
yarn-error.log
.shadow-cljs
.cpcache
Session.vim*
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 12.22.3
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,34 @@ npx truffle develop
npx truffle migrate --network ganache
```

#### compile cljs and run nodejs tests
```bash
lein doo node "nodejs-tests" once
```
# New build, test and release commands

### compile webpack
```bash
npx webpack
```
As this library is meant to work both in browsers and on Node.js (server), it must be tested on both as well.
Additionally CI runs the tests slightly different way, so that's the 3rd test environment.
- it's still in browser, but CI gets success vs failure depending on the
- browser process exit code so a bit of extra work is needed to get it out from JS (Karma is used for that)

#### compile cljs and run browser tests
```bash
lein doo chrome "tests" once
```
## Node.js

1. Build: `npx shadow-cljs compile test-node`
2. Tests: `node out/node-tests.js`

## Browser

1. Build: `npx shadow-cljs watch test-browser`
2. Tests: http://d0x-vm:6502

## CI (Headless Chrome, Karma)

1. Build: `npx shadow-cljs compile test-ci`
2. Tests: ```CHROME_BIN=`which chromium-browser` npx karma start karma.conf.js --single-run```

#### inspect on headless chrome on another chrome instance

1. Run headless chrome: `chromium-browser --headless --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --allowed-origins="*" https://chromium.org`
2. Open `chrome://inspect/#devices` and configure remote target with *IP ADDRESS* (hostname doesn't work)

## Build & release with `deps.edn` and `tools.build`

1. Build: `clj -T:build jar`
2. Release: `clj -T:build deploy`
29 changes: 29 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(ns build
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))

(def lib 'is.mad/cljs-web3-next) ; ends up as <group-id>/<artifact-id> in pom.xml
; (def version (format "1.2.%s" (b/git-count-revs nil)))
(def version "0.0.2")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))

(defn clean [_]
(b/delete {:path "target"}))

(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))

(defn deploy [_]
(dd/deploy {:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
38 changes: 38 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{:paths ["src" "test"]
:mvn/repos {"central" {:url "https://repo1.maven.org/maven2/"}
"clojars" {:url "https://clojars.org/repo"}}
:deps
{thheller/shadow-cljs {:mvn/version "2.18.0"}
org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220301"}

camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.0"}
district0x/bignumber {:mvn/version "1.0.3"}
binaryage/oops {:mvn/version "0.7.2"}}
:aliases
{:dev
{:extra-deps
{org.clojure/data.json {:mvn/version "0.2.6"},
org.clojure/clojure {:mvn/version "1.10.3"},
day8.re-frame/test {:mvn/version "0.1.5"},
day8.re-frame/http-fx {:mvn/version "0.1.4"},
day8.re-frame/async-flow-fx {:mvn/version "0.0.8"},
district0x/district-ui-smart-contracts {:mvn/version "1.0.9"},
district0x/district-ui-web3 {:mvn/version "1.0.1"},
district0x/async-helpers {:mvn/version "0.1.3"},
cljs-ajax/cljs-ajax {:mvn/version "0.7.2"},
org.clojure/tools.nrepl {:mvn/version "0.2.13"},
district0x/district-ui-web3-accounts {:mvn/version "1.0.3"},
district0x/re-frame-spec-interceptors {:mvn/version "1.0.1"},
com.cemerick/piggieback {:mvn/version "0.2.2"},
re-frame/re-frame {:mvn/version "0.10.2"},
org.clojure/core.async {:mvn/version "0.4.500"}}}

:build {:deps {io.github.clojure/tools.build {:tag "v0.8.1" :sha "7d40500"}
slipset/deps-deploy {:mvn/version "RELEASE"}}
:ns-default build}
:deploy {:replace-deps {slipset/deps-deploy {:mvn/version "RELEASE"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote :artifact "target/test-lib-0.0.2.jar"}}},
}
17 changes: 17 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
// The directory where the output file lives
basePath: 'out',
// The file itself
files: ['karma-tests.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
})
};
Loading

0 comments on commit 057b946

Please sign in to comment.