gcloudfunc

package module
v0.0.0-...-89c2124 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

Leaderboard

Leaderboard aggregates data by GitHub user on:

  • merged PRs (Pull Requests)
  • open and merged PRs
  • PR reviews
  • PR review comments

on anz-bank/go-course.

Development

This projects consist of a backend written in go and a frontend build with ReactJS.

The GitHub API is not directly queried by frontend because of rate limiting and performance as well as user experience and authentication concerns.

Backend

Code location: backend Language: go

The backend is concerned with PR data retrieval from GitHub API v4 (GraphQL) and transformation into aggregated, chartable data.

Prerequisites
Make

Build, test, lint and check coverage for this project with

cd backend
make

Produce a coverage report with

make cover

Run the project with

make run

Alternatively execute the commands given in the Makefile separately in your terminal.

Frontend

Code location: frontend Language: ReactJS

The frontend visualises PR stats as a series of bar charts. It retrieves the underlying processed and aggregated PR data as JSON and renders somewhat interactive SVG bar charts.

Prerequisites
Make

Build, test and lint the frontend with

cd frontend
make

Alternatively execute the commands given in the Makefile. The details of the yarn commands can be found in package.json.

Run in development mode

Start stubbed backend service in one terminal

make serve-stub

Run frontend in ReactJS development mode with in separate terminal

make start
View coverage report in file watch mode
make cover
Serve build output
make serve-build

CI

CI (Continuous Integration) runs on Google Cloudbuilds and is configured in cloudbuilds.yaml. The linked Google Cloud build project is gotraining, request access from @juliaogris if needed.

Builds can bet triggered locally with:

gcloud builds submit

.gcloudignore holds files not to be uploaded to Cloudbuilds (.git, frontend/node_modules).

Deployment

The build output of frontend has been manually deployed to Google Cloud storage bucket leader.go-course.org. The backend is deployed as Google Cloud function with HTTP trigger:

gcloud functions deploy LeaderboardHTTP \
    --runtime go111 \
    --timeout=300 \
    --trigger-http \
    --set-env-vars=GITHUB_TOKEN=$GITHUB_TOKEN

It is also deployed as Google Cloud function with PubSub event trigger to be used with Google Cloud Scheduler:

gcloud functions deploy LeaderboardEvent \
    --runtime go111 \
    --timeout=300 \
    --trigger-topic=schedule \
    --set-env-vars=GITHUB_TOKEN=$GITHUB_TOKEN

$GITHUB_TOKEN must contain a valid GitHub access token.

The linked Google Cloud build project is gotraining, request access from @juliaogris if needed.

Acknowledgement

This was @camh-anz's idea. Thank you!

Documentation

Overview

Package gcloudfunc contains the Google Cloud Function to generate the leaderboard stats when triggered by a webhook.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeaderboardEvent

func LeaderboardEvent(ctx context.Context, _ interface{}) error

LeaderboardEvent writes GitHub repo stats as JSON data for leaderboard charts to GCloud Storage bucket. This function is triggered by an PubSub event, intend for usage with Google Cloud Scheduler (cron job). (https://cloud.google.com/functions/docs/writing/background)

func LeaderboardHTTP

func LeaderboardHTTP(w http.ResponseWriter, r *http.Request)

LeaderboardHTTP writes GitHub repo stats as JSON data for leaderboard charts to GCloud Storage bucket. This function is triggered by HTTP request, (https://cloud.google.com/functions/docs/writing/http). It doesn't care about parameters or response body (except for errors).

Types

This section is empty.

Directories

Path Synopsis
backend
pkg/leader
Package leader produces a leaderboard summary from a github repository's pull requests as a JSON file.
Package leader produces a leaderboard summary from a github repository's pull requests as a JSON file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL