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

feat: initial commit #1

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
16 changes: 16 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The below is pulled from upstream and slightly modified
# https://github.com/webiny/action-conventional-commits/blob/master/README.md#usage

name: Conventional Commits

on:
pull_request:

jobs:
build:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: webiny/action-conventional-commits@v1.3.0
24 changes: 24 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: go-test

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

jobs:
go-test:
name: go-test
strategy:
matrix:
go-version: [1.21.x, 1.22.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: go-test
run: go test ./...
33 changes: 33 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file was copied from the following URL and modified:
# https://github.com/golangci/golangci-lint-action/blob/master/README.md#how-to-use

name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54 # current version at time of commit
args: --timeout=10m
# Only show new issues in a PR but show all issues for pushes
only-new-issues: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
143 changes: 143 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: publish

on:
push:
branches:
- 'main'
tags:
- 'v*.*.*'

concurrency: ${{ github.ref }}

jobs:
create-draft-release:
runs-on: ubuntu-latest
outputs:
RELEASE_ID: ${{ steps.create-release.outputs.result }}
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/github-script@v7
id: create-release
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
try {
const response = await github.rest.repos.createRelease({
draft: true,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});

return response.data.id;
} catch (error) {
core.setFailed(error.message);
}

# TODO: uncomment this when we have useful CLI bits
# build-binaries:
# strategy:
# matrix:
# os: [linux, darwin]
# arch: [amd64, arm64]
# runs-on: ubuntu-latest
# needs: [create-draft-release]
# steps:
# - run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
# - uses: actions/checkout@v4
# - uses: actions/setup-go@v5
# with:
# go-version: 1.21.x
# - name: Build binary
# run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build
# - name: Upload release asset
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# _filename=ouroboros-mock-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}
# mv ouroboros-mock ${_filename}
# curl \
# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: application/octet-stream" \
# --data-binary @${_filename} \
# https://uploads.github.com/repos/${{ github.repository_owner }}/ouroboros-mock/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename}
#
# build-images:
# runs-on: ubuntu-latest
# needs: [create-draft-release]
# steps:
# - run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
# - uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: blinklabs
# password: ${{ secrets.DOCKER_PASSWORD }} # uses token
# - name: Login to GHCR
# uses: docker/login-action@v3
# with:
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# registry: ghcr.io
# - id: meta
# uses: docker/metadata-action@v5
# with:
# images: |
# blinklabs/ouroboros-mock
# ghcr.io/${{ github.repository }}
# tags: |
# # Only version, no revision
# type=match,pattern=v(.*)-(.*),group=1
# # branch
# type=ref,event=branch
# # semver
# type=semver,pattern={{version}}
# - name: Build images
# uses: docker/build-push-action@v5
# with:
# outputs: "type=registry,push=true"
# platforms: linux/amd64,linux/arm64
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# # Update Docker Hub from README
# - name: Docker Hub Description
# uses: peter-evans/dockerhub-description@v4
# with:
# username: blinklabs
# password: ${{ secrets.DOCKER_PASSWORD }}
# repository: blinklabs/ouroboros-mock
# readme-filepath: ./README.md
# short-description: "Go library and CLI framework for mocking Ouroboros connections"

finalize-release:
runs-on: ubuntu-latest
# TODO: uncomment these when we have useful CLI bits
needs: [create-draft-release] #, build-binaries, build-images]
steps:
- uses: actions/github-script@v7
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-draft-release.outputs.RELEASE_ID }},
draft: false,
});
} catch (error) {
core.setFailed(error.message);
}

# This updates the documentation on pkg.go.dev and the latest version available via the Go module proxy
- name: Pull new module version
uses: andrewslotin/go-proxy-pull-action@v1.1.0
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

# Go workspace file
go.work

# Program binaries
/ouroboros-mock
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Blink Labs
#
* @agaffney @verbotenj @wolf31o2
80 changes: 80 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Contacting individual members, contributors, or leaders privately, outside designated community mechanisms, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at abuse@blinklabs.io. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at <https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ghcr.io/blinklabs-io/go:1.21.6-1 AS build

WORKDIR /code
COPY . .
RUN make build

FROM cgr.dev/chainguard/glibc-dynamic AS ouroboros-mock
COPY --from=build /code/ouroboros-mock /bin/
ENTRYPOINT ["ouroboros-mock"]
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Determine root directory
ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

# Gather all .go files for use in dependencies below
GO_FILES=$(shell find $(ROOT_DIR) -name '*.go')

# Gather list of expected binaries
BINARIES=$(shell cd $(ROOT_DIR)/cmd && ls -1)

# Extract Go module name from go.mod
GOMODULE=$(shell grep ^module $(ROOT_DIR)/go.mod | awk '{ print $$2 }')

# Set version strings based on git tag and current ref
GO_LDFLAGS=-ldflags "-s -w"

.PHONY: build mod-tidy clean format golines test

# Alias for building program binary
build: $(BINARIES)

mod-tidy:
# Needed to fetch new dependencies and add them to go.mod
go mod tidy

clean:
rm -f $(BINARIES)

format:
go fmt ./...

golines:
golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags .

test: mod-tidy
go test -v -race ./...

# Build our program binaries
# Depends on GO_FILES to determine when rebuild is needed
$(BINARIES): mod-tidy $(GO_FILES)
CGO_ENABLED=0 \
go build \
$(GO_LDFLAGS) \
-o $(@) \
./cmd/$(@)
7 changes: 7 additions & 0 deletions cmd/ouroboros-mock/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("ouroboros-mock")
}
Loading