Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Sep 29, 2023
0 parents commit b56bfc8
Show file tree
Hide file tree
Showing 104 changed files with 25,581 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
<!-- Steps to reproduce the behavior: -->

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**
<!--If applicable, add screenshots to help explain your problem. -->

**OS details**
<!--
- OS: [e.g. Mac/Linux etc]
- Version [e.g. 22]
-->

**Additional context**
<!-- Add any other context about the problem here. -->
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Fixes # .

### Motivation
<!--
Does this solve a bug? Enable a new use-case? Improve an existing behavior? Concrete examples are helpful here.
-->

### Solution
<!--
What is the solution here from a high level. What are the key technical decisions and why were they made?
-->

### Open questions
<!--
(optional) Any open questions or feedback on design desired?
-->
58 changes: 58 additions & 0 deletions .github/actions/test-coverage/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'Go coverage report'
description: 'This action updates adds an HTML coverage report and SVG badge to your wiki'
branding:
color: blue
icon: award

inputs:
report:
description: Generate an HTML coverage report.
default: true
chart:
description: Generate a coverage over time chart.
default: false
amend:
description: Amend wiki, avoiding spurious commits.
default: false
go-version:
description: The Go version to download (if necessary) and use.
default: '1.21'

runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Checkout wiki
uses: actions/checkout@v3
with:
repository: ${{github.repository}}.wiki
token: ${{ github.token }}
path: ./.github/wiki/

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{inputs.go-version}}

- name: Generate coverage report
shell: bash
env:
INPUT_CHART: ${{inputs.chart}}
INPUT_REPORT: ${{inputs.report}}
run: |
${{github.action_path}}/coverage.sh ./.github/wiki/
- name: Push to wiki
shell: bash
run: |
cd ./.github/wiki/
git add --all
git diff-index --quiet HEAD && exit
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
git remote set-url --push origin https://${{ github.token }}@github.com/Layr-Labs/eigensdk-go.wiki.git
test ${{inputs.amend}} == "true" && \
git commit --amend --no-edit && git push --force-with-lease || \
git commit -m "Update coverage" && git push https://${{ github.token }}@github.com/Layr-Labs/eigensdk-go.wiki.git
101 changes: 101 additions & 0 deletions .github/actions/test-coverage/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# This code is sourced from the go-coverage-report Repository by ncruces.
# Original code: https://github.com/ncruces/go-coverage-report
#
# MIT License
#
# Copyright (c) 2023 Nuno Cruces
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#!/usr/bin/env bash
set -euo pipefail

# This is a simple script to generate an HTML coverage report,
# and SVG badge for your Go project.
#
# It's meant to be used manually or as a pre-commit hook.
#
# Place it some where in your code tree and execute it.
# If your tests pass, next to the script you'll find
# the coverage.html report and coverage.svg badge.
#
# You can add the badge to your README.md as such:
# [![Go Coverage](PATH_TO/coverage.svg)](https://raw.githack.com/URL/coverage.html)
#
# Visit https://raw.githack.com/ to find the correct URL.
#
# To have the script run as a pre-commmit hook,
# symlink the script to .git/hooks/pre-commit:
#
# ln -s PATH_TO/coverage.sh .git/hooks/pre-commit
#
# Or, if you have other pre-commit hooks,
# call it from your main hook.

# Get the script's directory after resolving a possible symlink.
SCRIPT_DIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")"

OUT_DIR="${1-$SCRIPT_DIR}"
OUT_FILE="$(mktemp)"

# Get coverage for all packages in the current directory; store next to script.
go test -short ./... -coverprofile "$OUT_FILE"

if [[ "${INPUT_REPORT-true}" == "true" ]]; then
# Create an HTML report; store next to script.
go tool cover -html="$OUT_FILE" -o "$OUT_DIR/coverage.html"
fi

# Extract total coverage: the decimal number from the last line of the function report.
COVERAGE=$(go tool cover -func="$OUT_FILE" | tail -1 | grep -Eo '[0-9]+\.[0-9]')

echo "coverage: $COVERAGE% of statements"

date "+%s,$COVERAGE" >> "$OUT_DIR/coverage.log"
sort -u -o "$OUT_DIR/coverage.log" "$OUT_DIR/coverage.log"

# Pick a color for the badge.
if awk "BEGIN {exit !($COVERAGE >= 90)}"; then
COLOR=brightgreen
elif awk "BEGIN {exit !($COVERAGE >= 80)}"; then
COLOR=green
elif awk "BEGIN {exit !($COVERAGE >= 70)}"; then
COLOR=yellowgreen
elif awk "BEGIN {exit !($COVERAGE >= 60)}"; then
COLOR=yellow
elif awk "BEGIN {exit !($COVERAGE >= 50)}"; then
COLOR=orange
else
COLOR=red
fi

# Download the badge; store next to script.
curl -s "https://img.shields.io/badge/coverage-$COVERAGE%25-$COLOR" > "$OUT_DIR/coverage.svg"

if [[ "${INPUT_CHART-false}" == "true" ]]; then
# Download the chart; store next to script.
curl -s -H "Content-Type: text/plain" --data-binary "@$OUT_DIR/coverage.log" \
https://go-coverage-report.nunocruces.workers.dev/chart/ > \
"$OUT_DIR/coverage-chart.svg"
fi

# When running as a pre-commit hook, add the report and badge to the commit.
if [[ -n "${GIT_INDEX_FILE-}" ]]; then
git add "$OUT_DIR/coverage.html" "$OUT_DIR/coverage.svg"
fi
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
22 changes: 22 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: lint

on:
push:
branches:
- master
pull_request:

jobs:
Lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 3m
25 changes: 25 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: test-coverage

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: Update coverage badge
uses: ./.github/actions/test-coverage
with:
chart: true
amend: true
19 changes: 19 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: unit-tests

on:
push:
branches:
- master
pull_request:

jobs:
Test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: make tests
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# IDE related
.idea/

# Tests
coverage.html
coverage.out

# Misc
**/.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contracts/lib/eigenlayer-contracts"]
path = contracts/lib/eigenlayer-contracts
url = https://github.com/Layr-Labs/eigenlayer-contracts.git
Loading

0 comments on commit b56bfc8

Please sign in to comment.