Skip to content

Commit

Permalink
use github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Feb 28, 2020
1 parent ccc229e commit e2ee395
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 142 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Test"
on:
push:
branches:
- master
tags:
- "*"
pull_request:
types: [opened, reopened, synchronize]
jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 11, 12]
env:
TEST: "unit"
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v1
- run: bash ./scripts/install.sh
- run: bash ./scripts/ci.sh
build_and_lint:
runs-on: ${{ matrix.os }}
env:
TEST: "build_and_lint"
steps:
- uses: actions/setup-node@v1
with:
node-version: 10
- uses: actions/checkout@v1
- run: bash ./scripts/install.sh
- run: bash ./scripts/ci.sh
e2e:
runs-on: ubuntu-latest
strategy:
matrix:
testCmd:
[
"unit_and_e2e_clients",
"e2e_ganache",
"e2e_mosaic",
"e2e_ens",
"e2e_browsers",
]
env:
TEST: ${{ matrix.testCmd }}
CI: true
DISPLAY: :99.0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
- uses: actions/checkout@v1
- run: bash ./scripts/install.sh
- run: bash ./scripts/ci.sh
e2e_windows:
runs-on: windows-latest
env:
TEST: "e2e_windows"
CI: true
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
- uses: actions/checkout@v1
- run: bash ./scripts/install.sh
- run: bash ./scripts/ci.sh
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ coverage
scripts
.gitignore
.editorconfig
.travis.yml
.npmignore
.DS_Store
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# web3.js - Ethereum JavaScript API

[![Join the chat at https://gitter.im/ethereum/web3.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/web3.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![npm](https://img.shields.io/npm/dm/web3.svg)](https://www.npmjs.com/package/web3) [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url]
[![Join the chat at https://gitter.im/ethereum/web3.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/web3.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![npm](https://img.shields.io/npm/dm/web3.svg)](https://www.npmjs.com/package/web3) [![Build Status][actions-image]][actions-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url]
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)

This is the Ethereum [JavaScript API][docs]
Expand Down Expand Up @@ -53,11 +53,13 @@ Or via jsDelivr CDN
```html
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
```

UNPKG

```html
<script src="https://unpkg.com/web3@latest/dist/web3.min.js"></script>
```

## Usage

```js
Expand All @@ -77,9 +79,9 @@ console.log(web3);
Additionally you can set a provider using `web3.setProvider()` (e.g. WebsocketProvider):

```js
web3.setProvider('ws://localhost:8546');
web3.setProvider("ws://localhost:8546");
// or
web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546'));
web3.setProvider(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
```

There you go, now you can use it:
Expand All @@ -95,8 +97,8 @@ We support types within the repo itself. Please open an issue here if you find a
You can use `web3.js` as follows:

```typescript
import Web3 from 'web3';
const web3 = new Web3('ws://localhost:8546');
import Web3 from "web3";
const web3 = new Web3("ws://localhost:8546");
```

If you are using the types in a `commonjs` module like for example a node app you just have to enable `esModuleInterop` in your `tsconfig` compile option, also enable `allowSyntheticDefaultImports` for typesystem compatibility:
Expand Down Expand Up @@ -170,8 +172,8 @@ The contribution guidelines are provided in [CONTRIBUTIONS](./CONTRIBUTIONS.md)
[docs]: http://web3js.readthedocs.io/
[npm-image]: https://badge.fury.io/js/web3.png
[npm-url]: https://npmjs.org/package/web3
[travis-image]: https://travis-ci.org/ethereum/web3.js.svg
[travis-url]: https://travis-ci.org/ethereum/web3.js
[actions-image]: https://github.com/ethereum/web3.js/workflows/Test/badge.svg
[actions-url]: https://github.com/ethereum/web3.js/actions
[dep-image]: https://david-dm.org/ethereum/web3.js.svg
[dep-url]: https://david-dm.org/ethereum/web3.js
[dep-dev-image]: https://david-dm.org/ethereum/web3.js/dev-status.svg
Expand Down
138 changes: 68 additions & 70 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,73 @@
{
"namespace": "ethereum",
"name": "web3",
"version": "1.2.6",
"description": "Ethereum JavaScript API",
"license": "LGPL-3.0",
"main": [
"./dist/web3.min.js"
],
"moduleType": "global",
"dependencies": {
"bn.js": ">=4.11.6"
},
"repository": {
"type": "git",
"url": "git://github.com/ethereum/web3.js.git"
},
"homepage": "https://github.com/ethereum/web3.js",
"bugs": {
"url": "https://github.com/ethereum/web3.js/issues"
},
"keywords": [
"Ethereum",
"JavaScript",
"RPC",
"Swarm",
"Whisper",
"Smart Contracts",
"API"
],
"authors": [
{
"name": "Fabian Vogelsteller",
"email": "fabian@ethereum.org",
"homepage": "http://frozeman.de"
"namespace": "ethereum",
"name": "web3",
"version": "1.2.6",
"description": "Ethereum JavaScript API",
"license": "LGPL-3.0",
"main": ["./dist/web3.min.js"],
"moduleType": "global",
"dependencies": {
"bn.js": ">=4.11.6"
},
{
"name": "Marek Kotewicz",
"email": "marek@parity.io",
"url": "https://github.com/debris"
"repository": {
"type": "git",
"url": "git://github.com/ethereum/web3.js.git"
},
{
"name": "Marian Oancea",
"url": "https://github.com/cubedro"
"homepage": "https://github.com/ethereum/web3.js",
"bugs": {
"url": "https://github.com/ethereum/web3.js/issues"
},
{
"name": "Gav Wood",
"email": "g@parity.io",
"homepage": "http://gavwood.com"
},
{
"name": "Jeffery Wilcke",
"email": "jeffrey.wilcke@ethereum.org",
"url": "https://github.com/obscuren"
}
],
"ignore": [
"test",
"packages",
"src",
"node_modules",
"package.json",
"package.js",
".versions",
".bowerrc",
".editorconfig",
".gitignore",
".jshintrc",
".npmignore",
".travis.yml",
"gulpfile.js",
"index.js",
"**/*.txt"
]
"keywords": [
"Ethereum",
"JavaScript",
"RPC",
"Swarm",
"Whisper",
"Smart Contracts",
"API"
],
"authors": [
{
"name": "Fabian Vogelsteller",
"email": "fabian@ethereum.org",
"homepage": "http://frozeman.de"
},
{
"name": "Marek Kotewicz",
"email": "marek@parity.io",
"url": "https://github.com/debris"
},
{
"name": "Marian Oancea",
"url": "https://github.com/cubedro"
},
{
"name": "Gav Wood",
"email": "g@parity.io",
"homepage": "http://gavwood.com"
},
{
"name": "Jeffery Wilcke",
"email": "jeffrey.wilcke@ethereum.org",
"url": "https://github.com/obscuren"
}
],
"ignore": [
"test",
"packages",
"src",
"node_modules",
"package.json",
"package.js",
".versions",
".bowerrc",
".editorconfig",
".gitignore",
".jshintrc",
".npmignore",
".github",
"gulpfile.js",
"index.js",
"**/*.txt"
]
}
68 changes: 31 additions & 37 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,61 @@
process.env.MOZ_HEADLESS = 1;

if (!process.env.TRAVIS){
process.env.CHROME_BIN = require('puppeteer').executablePath();
if (!process.env.GITHUB_ACTION) {
process.env.CHROME_BIN = require("puppeteer").executablePath();
}

// BROWSER_BUNDLE_TEST is set for an un-browserified check that both bundles load correctly.
// BROWSER_BUNDLE_TEST is not set for the e2e unit tests, which check that bundle internals are ok.
function getTestFiles(){
switch (process.env.BROWSER_BUNDLE_TEST){
case 'publishedDist': return ["packages/web3/dist/web3.min.js", "test/e2e.minified.js"]
case 'gitRepoDist': return ["dist/web3.min.js", "test/e2e.minified.js"]
default: return ["test/**/e2e*.js"]
function getTestFiles() {
switch (process.env.BROWSER_BUNDLE_TEST) {
case "publishedDist":
return ["packages/web3/dist/web3.min.js", "test/e2e.minified.js"];
case "gitRepoDist":
return ["dist/web3.min.js", "test/e2e.minified.js"];
default:
return ["test/**/e2e*.js"];
}
}

// Only loads browserified preprocessor for the logic unit tests so we can `require` stuff.
function getPreprocessors(){
if (!process.env.BROWSER_BUNDLE_TEST){
return { 'test/**/e2e*.js': [ 'browserify' ] }
function getPreprocessors() {
if (!process.env.BROWSER_BUNDLE_TEST) {
return { "test/**/e2e*.js": ["browserify"] };
}
}

module.exports = function (config) {
module.exports = function(config) {
var configuration = {
frameworks: [
'mocha',
'browserify'
],
frameworks: ["mocha", "browserify"],
files: getTestFiles(),
preprocessors: getPreprocessors(),
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-mocha',
'karma-browserify',
'karma-spec-reporter'
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-mocha",
"karma-browserify",
"karma-spec-reporter"
],
reporters: ['spec'],
port: 9876, // karma web server port
reporters: ["spec"],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: [
'ChromeHeadless',
'FirefoxHeadless'
],
browsers: ["ChromeHeadless", "FirefoxHeadless"],
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless'],
base: "Firefox",
flags: ["-headless"]
},
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
Chrome_ci: {
base: "Chrome",
flags: ["--no-sandbox"]
}
},
}
};

if(process.env.TRAVIS) {
configuration.browsers = [
'Chrome_travis_ci',
'FirefoxHeadless'
];
if (process.env.GITHUB_ACTION) {
configuration.browsers = ["Chrome_ci", "FirefoxHeadless"];
}

config.set(configuration);
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# -----------------------------
# Travis CI matrix job selector
# CI matrix job selector
# -----------------------------

# Exit immediately on error
Expand Down
1 change: 1 addition & 0 deletions scripts/e2e.mosaic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ echo "Installing updated web3 via virtual registry "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

git submodule update --init --recursive
yarn config set network-timeout 600000 -g
yarn --registry http://localhost:4873

yarn add web3@e2e --registry http://localhost:4873
Expand Down
Loading

0 comments on commit e2ee395

Please sign in to comment.