Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Travis with GitHub Actions #847

Merged
merged 32 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
84e857d
GitHub CI actions
kremalicious Jun 15, 2021
3504a9a
add coverage job
kremalicious Jun 15, 2021
a136baf
test run tweaks
kremalicious Jun 15, 2021
ad05a44
windows build fix
kremalicious Jun 15, 2021
80241ea
barge tweaks
kremalicious Jun 15, 2021
59b9257
deal with env vars
kremalicious Jun 15, 2021
fbfaa2e
add npm publish job
kremalicious Jun 15, 2021
ca9e6ad
trial & error
kremalicious Jun 16, 2021
3c78fc9
remove Travis
kremalicious Jun 16, 2021
fc68491
publish as single workflow
kremalicious Jun 16, 2021
8b0df42
handle Docker Hub login
kremalicious Jun 16, 2021
83b49ae
maybe preparing ~/.ocean is needed
kremalicious Jun 16, 2021
08d8346
downgrade barge contracts, run with barge defaults
kremalicious Jun 16, 2021
1a14b3a
put back ADDRESS_FILE env var
kremalicious Jun 17, 2021
db58463
AQUARIUS_URI test
kremalicious Jun 17, 2021
5d2f094
ddo creation test logging
kremalicious Jun 17, 2021
62bbf0a
make failing DDO creation test actually fail
kremalicious Jun 17, 2021
1b9c4a6
separate unit/integration Asset tests
kremalicious Jun 17, 2021
9db0d30
set AQUARIUS_URI again
kremalicious Jun 17, 2021
572b49a
readme updates
kremalicious Jun 17, 2021
c583ba0
prepare ~/.ocean folder
kremalicious Jun 17, 2021
147e6e8
separate tests into multiple jobs
kremalicious Jun 17, 2021
81bc475
address.json debugging
kremalicious Jun 18, 2021
0f2ad6e
windows build fixes
kremalicious Jun 18, 2021
83f6f6c
address.json trials
kremalicious Jun 18, 2021
d23bed1
env var expansion workaround
kremalicious Jun 18, 2021
1d7cebc
cleanup
kremalicious Jun 18, 2021
fb46b0c
debug coverage output
kremalicious Jun 18, 2021
833c1fb
fix coverage
kremalicious Jun 19, 2021
7e26d8c
bump codeclimate-action
kremalicious Jun 21, 2021
152ba1f
use barge instead of ganache (#855)
alexcos20 Jun 22, 2021
588d1c8
barge detach workaround
kremalicious Jun 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: 'CI'

on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
- run: npm ci
- run: npm run lint

test_unit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
- run: npm ci
- run: npm run build:metadata

- name: Run Ganache
run: |
docker pull trufflesuite/ganache-cli:latest
docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest --mnemonic "taxi music thumb unique chat sand crew more leg another off lamp"
sleep 5

- run: npm run test:unit:cover
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/

test_integration:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-integration-${{ env.cache-name }}-
- run: npm ci
- run: npm run build:metadata

# Env var expansion workaround
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set ADDRESS_FILE
run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV

- name: Checkout Barge
uses: actions/checkout@v2
with:
repository: 'oceanprotocol/barge'
path: 'barge'

- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}
run: |
echo "Login to Docker Hub";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run Barge
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log &
cd .. && ./scripts/waitforcontracts.sh

- run: npm run test:integration:cover
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/

build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['15', '16']

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}-
- run: npm ci
- run: npm run build

coverage:
runs-on: ubuntu-latest
needs: [test_unit, test_integration]
if: success()
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage

- uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{ github.workspace }}/unit/lcov.info:lcov
${{ github.workspace }}/integration/lcov.info:lcov
21 changes: 21 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Publish'

on:
push:
tags:
- '**'

jobs:
npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
> JavaScript library to privately & securely publish, exchange, and consume data.

[![npm](https://img.shields.io/npm/v/@oceanprotocol/lib.svg)](https://www.npmjs.com/package/@oceanprotocol/lib)
[![Build Status](https://travis-ci.com/oceanprotocol/ocean.js.svg?token=soMi2nNfCZq19zS1Rx4i&branch=main)](https://travis-ci.com/oceanprotocol/ocean.js)
[![Build Status](https://github.com/oceanprotocol/ocean.js/workflows/CI/badge.svg)](https://github.com/oceanprotocol/ocean.js/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/6381c81b8ac568a53537/maintainability)](https://codeclimate.com/github/oceanprotocol/ocean.js/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/6381c81b8ac568a53537/test_coverage)](https://codeclimate.com/github/oceanprotocol/ocean.js/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier)
Expand Down Expand Up @@ -120,7 +120,7 @@ This batteries-included flow includes metadata, multiple services for one datato

If you have any difficulties with the quickstarts, or if you have further questions about how to use ocean.js please reach out to us on [Discord](https://discord.gg/TnXjkR5).

If you notice any bugs or issues with Ocean.js please [open an issue on github](https://github.com/oceanprotocol/ocean.js/issues/new?assignees=&labels=bug&template=bug_report.md&title=).
If you notice any bugs or issues with ocean.js please [open an issue on github](https://github.com/oceanprotocol/ocean.js/issues/new?assignees=&labels=bug&template=bug_report.md&title=).

## 🦑 Development

Expand All @@ -147,7 +147,7 @@ npm run format

## 👩‍🔬 Testing

Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via Travis.
Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via the `coverage` GitHub Actions job.

Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a `ganache-cli` instance:

Expand All @@ -160,7 +160,7 @@ cd barge

You can then proceed to run in another terminal.

Let ocean.js know where to pickup the smartcontract addresses:
Let ocean.js know where to pickup the smart contract addresses, which has been written out by Barge in this location:

```
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
Expand All @@ -169,7 +169,7 @@ export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
Build metadata:

```
npm run build
npm run build:metadata
```

Executing linting, type checking, unit, and integration tests with coverage reporting all in one go:
Expand Down Expand Up @@ -225,7 +225,7 @@ The task does the following:
- creates a Git tag
- commits and pushes everything
- creates a GitHub release with commit messages as description
- Git tag push will trigger Travis to do a npm release
- Git tag push will trigger a GitHub Action workflow to do a npm release

For the GitHub releases steps a GitHub personal access token, exported as `GITHUB_TOKEN` is required. [Setup](https://github.com/release-it/release-it#github-releases)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"start": "npm run clean && npm run build:metadata && tsc -w",
"build": "npm run clean && npm run build:metadata && microbundle build --format umd,cjs,es --compress --target node --tsconfig tsconfig.json",
"build:tsc": "tsc --sourceMap",
"build:metadata": "./scripts/get-metadata.js > src/metadata.json",
"build:metadata": "node ./scripts/get-metadata.js > src/metadata.json",
"clean": "rm -rf ./dist/ ./doc/ ./.nyc_output",
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check",
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix",
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
"type-check": "npm run build:metadata && tsc --noEmit",
"doc:json": "./scripts/typedoc.js",
"doc:json": "node ./scripts/typedoc.js",
"run": "ts-node",
"release": "release-it --non-interactive",
"changelog": "auto-changelog -p",
Expand Down
9 changes: 4 additions & 5 deletions scripts/waitforcontracts.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
if [ "${DEPLOY_CONTRACTS}" = "true" ]; then
while [ ! -f "${HOME}/.ocean/ocean-contracts/artifacts/ready" ]; do
sleep 2
done
fi
while [ ! -f "${HOME}/.ocean/ocean-contracts/artifacts/ready" ]; do
sleep 2
done

cat "barge/start_ocean.log"
ls -lh "${HOME}/.ocean/ocean-contracts/"
ls -lh "${HOME}/.ocean/ocean-contracts/artifacts/"
Expand Down
Loading