Skip to content

Commit

Permalink
adding coverage
Browse files Browse the repository at this point in the history
- starting tests
  • Loading branch information
Phillip Miller committed Oct 26, 2021
1 parent d3c31a6 commit 2f5b722
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 18 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/codacy-coverage-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: codacy-coverage-reporter

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

jobs:
codacy-coverage-reporter:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

# Setup Go
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: |
go version
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go get -u github.com/jstemmer/go-junit-report
sudo apt-get update -y || true
# Run build of the application
- name: Run build
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
# Run Tests and Coverage
- name: Run Tests and Coverage
run: |
go test -v -coverprofile=coverage.out ./... | tee test.out
cat test.out | go-junit-report > coverage/${{ runner.OS }}-report.xml
gocov convert coverage.out | gocov-xml > coverage/${{ runner.OS }}-report.xml
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage/${{ runner.OS }}-report.xml
84 changes: 84 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '38 4 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
go-version: [1.17.x]
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

- name: Checkout code
uses: actions/checkout@main

- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
run-gosec: "true"
run-staticcheck: "true"
upload: true
max-allowed-issues: 2147483647
13 changes: 6 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# This is a basic workflow

name: Go
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
tags:
- '*'
pull_request:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The "build" workflow
build:
# The type of runner that the job will run on
strategy:
matrix:
go-version: [1.17]
Expand Down Expand Up @@ -51,7 +47,10 @@ jobs:
# Run build of the application
- name: Run build
run: go build -v .
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
# Run vet & lint on the code
- name: Run vet & lint
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [v1.0.4](https://github.com/mr-pmillz/coinmon-go/tree/v1.0.4) (2021-10-16)

[Full Changelog](https://github.com/mr-pmillz/coinmon-go/compare/v1.0.3...v1.0.4)

## [v1.0.3](https://github.com/mr-pmillz/coinmon-go/tree/v1.0.3) (2021-10-16)

[Full Changelog](https://github.com/mr-pmillz/coinmon-go/compare/v1.0.2...v1.0.3)
Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
# Coinmon-go

[![Donate](https://img.shields.io/badge/Donate-PayPal-yellow.svg)](https://www.paypal.com/donate?business=YR6C4WB5CDZZL&no_recurring=0&item_name=contribute+to+open+source&currency_code=USD)
[![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/3Cd54T1EB6WHRcechq1dRCGF6vY2HHhkdk)](https://en.cryptobadges.io/donate/3Cd54T1EB6WHRcechq1dRCGF6vY2HHhkdk)
[![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0x064AA753EF36e5641E2Ee3C9BbC117F6aFe35F62)](https://en.cryptobadges.io/donate/0x064AA753EF36e5641E2Ee3C9BbC117F6aFe35F62)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/12750b2a6fa44b429f8a3f64d3e7f1b6)](https://www.codacy.com/gh/mr-pmillz/coinmon-go/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mr-pmillz/coinmon-go&utm_campaign=Badge_Grade)
[![Go Report Card](https://goreportcard.com/badge/github.com/mr-pmillz/coinmon-go)](https://goreportcard.com/report/github.com/mr-pmillz/coinmon-go)
![GitHub all releases](https://img.shields.io/github/downloads/mr-pmillz/coinmon-go/total?style=social)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/mr-pmillz/coinmon-go/CI?style=plastic)
![GitHub repo size](https://img.shields.io/github/repo-size/mr-pmillz/coinmon-go?style=plastic)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/mr-pmillz/coinmon-go?style=plastic)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/mr-pmillz/coinmon-go?style=plastic)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/mr-pmillz/coinmon-go?style=plastic)

Table of Contents
=================

* [Coinmon\-go](#coinmon-go)
* [Install](#install)
* [Usage](#usage)

Get live Crypto Currency prices in the terminal with the quickness

## Install

If you have a version of golang >= 16.X you can install with

```shell
go install github.com/mr-pmillz/coinmon-go@latest
```

If using an older version of golang

```shell
go get github.com/mr-pmillz/coinmon-go@latest
```

```bash
go build
```
Expand All @@ -25,14 +56,14 @@ Options:
./coinmon-go -t 20
```

<img src="https://github.com/mr-pmillz/coinmon-go/blob/master/img/top20.png" />
![top20.png](https://github.com/mr-pmillz/coinmon-go/blob/master/img/top20.png?raw=true)

- Get Specified Coins

```bash
./coinmon-go --find bitcoin,ethereum,cardano,uniswap,dogecoin,chainlink,monero,filecoin,tron,bittorrent
```

<img src="https://github.com/mr-pmillz/coinmon-go/blob/master/img/find.png" />
![find.png](https://github.com/mr-pmillz/coinmon-go/blob/master/img/find.png?raw=true)

- By default, `./coinmon-go` with no arguments will just return the top 10 coins by market cap
Empty file added coverage/.gitkeep
Empty file.
17 changes: 14 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
module coinmon-go
module github.com/mr-pmillz/coinmon-go

go 1.16
go 1.17

require (
github.com/mkideal/cli v0.2.7
github.com/olekukonko/tablewriter v0.0.5
golang.org/x/text v0.3.6
golang.org/x/text v0.3.7
)

require (
github.com/labstack/gommon v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mkideal/expr v0.1.0 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
"coinmon-go/utils"
"encoding/json"
"fmt"
"github.com/mr-pmillz/coinmon-go/utils"
"net/http"
"os"
"strconv"
Expand Down Expand Up @@ -36,10 +36,10 @@ type Data struct {
Rank string `json:"rank"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Supply string `json:"supply"`
Supply string `json:"supply,omitempty"`
MaxSupply string `json:"maxSupply,omitempty"`
MarketCapUSD string `json:"marketCapUsd"`
VolumeUSD24Hr string `json:"volumeUsd24Hr"`
MarketCapUSD string `json:"marketCapUsd,omitempty"`
VolumeUSD24Hr string `json:"volumeUsd24Hr,omitempty"`
PriceUSD string `json:"priceUsd"`
ChangePercent24Hr string `json:"changePercent24Hr"`
Vwap24Hr string `json:"vwap24Hr"`
Expand Down
Loading

0 comments on commit 2f5b722

Please sign in to comment.