Giter VIP home page Giter VIP logo

stargazers-cmc's Introduction

stargazers-cmc

This is a Go-lang app that gets the Stars count from the following git repositories using go-github library to consume the github Rest api. It uses Github OAuth Tokens for auntentication.

  • 996icu/996.ICU
  • freeCodeCamp/freeCodeCamp
  • EbookFoundation/free-programming-books

The output of the app is sent to the stdout in YAML format with a top level mapping called Stargazers.

Local run and expected output:

To try this app locally, please export a env variable called GH_AUTH_TOKEN with your OAuth Token before run it, like this:

❯ export GH_AUTH_TOKEN="ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
❯ cd src/
❯ go run .
Stargazers:
    996icu/996.ICU: 261663
    EbookFoundation/free-programming-books: 229805
    freeCodeCamp/freeCodeCamp: 343607

The output should be similar to the one shown before, numbers may change.

Tests:

There are two unit tests to be passed:

  1. TestGetNameAndStartCount: check if the app is correctly retrieving the information from one repo at a time.
  2. TestGetRepoStarsList: check if the app is correclty retrieving the total amount of repositires data.

Test can be excecuted with the following command, it also requieres the GH_AUTH_TOKEN variable to be defined before running it:

❯ cd src/
❯ go test -v
=== RUN   TestGetNameAndStartCount
--- PASS: TestGetNameAndStartCount (1.20s)
=== RUN   TestGetRepoStarsList
--- PASS: TestGetRepoStarsList (0.23s)
PASS
ok  	github.com/CarlosMC/stargazers-cmc	1.632s

Docker Image

A Docker image has been built so you can run the containerized app with Docker.

Build the image with the following command:

docker build -t carlosmc/stargazers-cmc:1.0.X .

The Docker image also requires the GH_AUTH_TOKEN variable to be defined before running it.

You can export and pass it directly from command line like this:

❯ export GH_AUTH_TOKEN="ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
❯ docker run --rm -e GH_AUTH_TOKEN=$GH_AUTH_TOKEN carlosmc/stargazers-cmc

or you can save the variable into a file (added to .gitignore) for further usage and pass it to Docker with --env-file option:

❯ echo 'GH_AUTH_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' > .env
❯ docker run --rm --env-file .env carlosmc/stargazers-cmc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.