Skip to content

Commit

Permalink
Initial draft
Browse files Browse the repository at this point in the history
  • Loading branch information
arikkfir committed Jul 2, 2022
1 parent 527033c commit 7fd702e
Show file tree
Hide file tree
Showing 20 changed files with 756 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers 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, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
62 changes: 62 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## Contributing

[fork]: /fork
[pr]: /compare
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in
this project you agree to abide by its terms.

## Development environment

1. You should probably have a Go-capable IDE
1. Usually either of GoLand or VSCode (but you can use any other IDE of course)
2. Ensure you have Go SDK 1.17+ installed & working
3. Ensure you have Docker installed & working
4. Verify they work by:
```shell
$ docker version
$ go version
```

## Issues and PRs

If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all
and any contributions. If you have questions, too, we'd love to hear them.

We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look
at the links below if you're not sure how to open a PR.

### Submitting a pull request

1. [Fork][fork] and clone the repository.
2. Verify it works & all tests are passing on your machine by:
```shell
$ go test ./...
```
3. Create a new branch:
```shell
$ git checkout -b my-branch-name
```
4. Make your change, add tests, and make sure the tests still pass.
- If you're modifying or adding functions (under `/cmd/functions`) you should invoke the
`/scripts/build-function-images.sh` to regenerate their Docker image locally.
5. Push to your fork and [submit a pull request][pr].
6. Pat your self on the back and wait for your pull request to be reviewed and merged 👏

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent
upon each other, you should probably submit them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

Work in Progress (WIP) PRs are also welcome to get feedback early on, or if there is something blocked you.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: arikkfir # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
29 changes: 29 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
changelog:
exclude:
labels:
- ignore
categories:
- title: Breaking Changes 🛠
labels:
- breaking-change
- title: Enhancements 🎉
labels:
- enhancement
- title: Bug Fixes 🐛
labels:
- bug
- title: Testing
labels:
- testing
- title: Build & CI
labels:
- ci
- title: Documentation
labels:
- documentation
- title: IDE
labels:
- ide
- title: Other Changes
labels:
- "*"
46 changes: 46 additions & 0 deletions .github/workflows/build-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Commit

on:
push:
branches:
- main
pull_request:
types:
- synchronize
- opened
- reopened

defaults:
run:
shell: bash -eu {0}

env:
GO_VERSION: "1.18"

jobs:

test:
name: Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: golang-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.sha }}
restore-keys: |
golang-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
golang-${{ runner.os }}-
- run: go mod download
- run: go vet
- run: |
go test -v -vet=off -race -shuffle ${SHUFFLE_SEED} -coverprofile=coverage.out -covermode=atomic ./pkg
env:
SHUFFLE_SEED: ${{ github.run_number }}
- uses: codecov/codecov-action@v3
if: always()
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/pyper.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,71 @@
# pyper
YAML pipeline

![Maintainer](https://img.shields.io/badge/maintainer-arikkfir-blue)
![GoVersion](https://img.shields.io/github/go-mod/go-version/arikkfir/pyper.svg)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/arikkfir/pyper)
[![GoReportCard](https://goreportcard.com/badge/github.com/arikkfir/pyper)](https://goreportcard.com/report/github.com/arikkfir/pyper)
[![codecov](https://codecov.io/gh/arikkfir/pyper/branch/main/graph/badge.svg?token=QP3OAILB25)](https://codecov.io/gh/arikkfir/pyper)

Pipeline for YAML nodes in Golang.

## Status

This is currently alpha, with some features still in development, and not full test coverage. We're on it! 💪

## Example

This program does the following:
- Creates a pipeline input that just provides a YAML from a constant
- More realistic examples would pipe YAML from a file or a stream
- Creates a pipeline of two steps:
- Accepts only nodes whose `include` property equals `true`
- Sends those nodes to a node channel
- Pipes nodes sent to the node channel into `stderr`

```go
package main

import (
"context"
"github.com/arikkfir/pyper/pkg"
"gopkg.in/yaml.v3"
"os"
"strings"
)

const yml = `
key: value1
include: true
---
key: value2
include: false
---
key: value3
include: true`

func main() {
input := pyper.MustReaderInput(strings.NewReader(yml))
nodes := make(chan *yaml.Node, 1000)
processor := pyper.MustFilterProcessor(
"$[?(@.include==true)]",
pyper.MustChannelSendProcessor(nodes),
)
if err := pyper.Pipe(context.Background(), []pyper.PipeInput{input}, processor); err != nil {
panic(err)
}
close(nodes)
if err := pyper.EncodeYAMLFromChannel(nodes, 2, os.Stderr); err != nil {
panic(err)
}
}
```

This will print the following:

```yaml
key: value1
include: true
---
key: value3
include: true
```
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/arikkfir/pyper

go 1.18

require (
github.com/vmware-labs/yaml-jsonpath v0.3.2
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 // indirect
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
golang.org/x/sys v0.0.0-20220701225701-179beb0bd1a1 // indirect
golang.org/x/text v0.3.2 // indirect
)
Loading

0 comments on commit 7fd702e

Please sign in to comment.