Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
potatosalad committed Jul 25, 2023
0 parents commit a262064
Show file tree
Hide file tree
Showing 267 changed files with 61,161 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) WhatsApp LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE.md file in the root directory of this source tree.

# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
line_length: 132
]
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on: [push, pull_request]

env:
MIX_ENV: test

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- elixir: 1.15.4
otp: 26.0.2
rebar3: 3.22.0
lint: true

- elixir: 1.14.5
otp: 25.2.3
rebar3: 3.22.0

steps:
- uses: actions/checkout@v3

- name: Setup Beam
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
rebar3-version: ${{ matrix.rebar3 }}

- name: Erlang Tests
run: |
rebar3 ct
- name: Retrieve Mix Dependencies Cache
uses: actions/cache@v3
id: mix-cache
with:
path: deps
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}

- name: Install Mix Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Check Formatting
if: ${{ matrix.lint }}
run: mix format --check-formatted

- name: Elixir Tests
run: mix test

- name: Logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: ct-logs-${{ matrix.otp }}-${{ matrix.elixir }}
path: _build/test/logs/
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# The directory Mix will write compiled artifacts to.
/_build/
/apps/erldist_filter/_build/
/apps/erldist_filter_test/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/
/apps/erldist_filter/deps/
/apps/erldist_filter_test/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/
/apps/erldist_filter/doc/
/apps/erldist_filter_test/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
erldist_filter-*.tar
erldist_filter_test-*.tar

# Temporary files, for example, from tests.
/tmp/

# rebar3 and erlang.mk related files.
.rebar3
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
.idea
.vscode
*.iml
rebar3.crashdump
*~
/.elixir_ls/
/.erlang.mk/
/apps/erldist_filter/c_src/env.mk
/apps/erldist_filter/priv/*.dll
/apps/erldist_filter/priv/*.dylib
/apps/erldist_filter/priv/*.so
/erlfmt
/rebar3
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 1.0.0 (2023-??-??)

* Initial release.
80 changes: 80 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, 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.

## 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 within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
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.

This Code of Conduct also applies outside the project spaces when there is a
reasonable belief that an individual's behavior may have a negative impact on
the project or its community.

## 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

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing to `erldist_filter`

We want to make contributing to this project as easy and transparent as possible.

## Our Development Process

`erldist_filter` is currently developed in Meta's internal repositories and then exported out to GitHub by a Meta team member; however, we invite you to submit pull requests as described below.

## Pull Requests

We actively welcome your pull requests.

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Meta's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues

We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.

Meta has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.

## Coding Style

Please run `make format` before submitting your changes.

## License

By contributing to `erldist_filter`, you agree that your contributions will be licensed under the MIT license found in the LICENSE.md file in the root directory of this source tree.
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIT License
===========

Copyright (c) Meta Platforms, Inc. and affiliates.

Copyright (c) WhatsApp LLC

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.
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) WhatsApp LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE.md file in the root directory of this source tree.

PROJECT = erldist_filter
PROJECT_DESCRIPTION = erldist_filter
PROJECT_VERSION = 1.0.0

include erlang.mk

.PHONY: erlfmt erlfmt-check distclean-erlfmt format

# Configuration.
ERLFMT_VERSION ?= 1.2.0

ERLFMT ?= $(CURDIR)/erlfmt
export ERLFMT

ERLFMT_URL ?= https://github.com/WhatsApp/erlfmt/archive/refs/tags/v$(ERLFMT_VERSION).tar.gz
ERLFMT_OPTS ?=
ERLFMT_BUILD_DIR ?= $(CURDIR)/_erlfmt_build
ERLFMT_CODE_ARCHIVE = $(ERLFMT_VERSION).tar.gz

ERLFMT_REBAR3_URL ?= https://s3.amazonaws.com/rebar3/rebar3
ERLFMT_REBAR3 ?= rebar3

# Core targets.

help::
$(verbose) printf "%s\n" "" \
"erlfmt targets:" \
" erlfmt Run erlfmt or download the default otherwise" \
" elrfmt-check Run erlfmt --check"

distclean:: distclean-erlfmt

# Plugin-specific targets.

$(ERLFMT):
$(verbose) mkdir -p $(ERLFMT_BUILD_DIR)
ifeq ($(shell command -v $(ERLFMT_REBAR3)),)
$(verbose) echo "Downloading Rebar3 from: "$(ERLFMT_REBAR3_URL)
$(verbose) $(call core_http_get,$(ERLFMT_BUILD_DIR)/rebar3,$(ERLFMT_REBAR3_URL))
$(verbose) chmod +x $(ERLFMT_BUILD_DIR)/rebar3
$(eval ERLFMT_REBAR3 := $(ERLFMT_BUILD_DIR)/rebar3)
else
$(verbose) echo "Using Rebar3: "$(ERLFMT_REBAR3)
endif
$(verbose) echo "Downloading erlfmt from: "$(ERLFMT_URL)
$(verbose) $(call core_http_get,$(ERLFMT_BUILD_DIR)/$(ERLFMT_CODE_ARCHIVE),$(ERLFMT_URL))
$(verbose) cd $(ERLFMT_BUILD_DIR) && \
tar -xzf $(ERLFMT_CODE_ARCHIVE) && \
cd erlfmt-$(ERLFMT_VERSION) && \
$(ERLFMT_REBAR3) as release escriptize
$(gen_verbose) cp $(ERLFMT_BUILD_DIR)/erlfmt-$(ERLFMT_VERSION)/_build/release/bin/erlfmt $(ERLFMT)
$(verbose) chmod +x $(ERLFMT)
$(verbose) rm -rf $(ERLFMT_BUILD_DIR)/erlfmt-$(ERLFMT_VERSION)
$(verbose) rm $(ERLFMT_BUILD_DIR)/$(ERLFMT_CODE_ARCHIVE)
$(verbose) rm -f $(ERLFMT_BUILD_DIR)/rebar3
$(verbose) rm -rf $(ERLFMT_BUILD_DIR)

erlfmt: $(ERLFMT)
$(verbose) $(ERLFMT) --verbose --write --require-pragma --print-width=120 'apps/**/{src,include,test}/**/*.{hrl,erl,app.src}' 'apps/**/rebar.config' rebar.config

erlfmt-check: $(ERLFMT)
$(verbose) $(ERLFMT) --check --require-pragma --print-width=120 'apps/**/{src,include,test}/**/*.{hrl,erl,app.src}' 'apps/**/rebar.config' rebar.config

distclean-erlfmt:
$(gen_verbose) rm -rf $(ERLFMT)

format: $(ERLFMT)
$(verbose) $(MAKE) -C $(CURDIR)/apps/erldist_filter/c_src format
$(verbose) $(MAKE) erlfmt
$(verbose) mix format
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `erldist_filter`

[![Build Status](https://github.com/WhatsApp/erldist_filter/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/WhatsApp/erldist_filter/actions)

`erldist_filter` NIF for filtering and logging [Erlang Dist Protocol](https://www.erlang.org/doc/apps/erts/erl_dist_protocol.html) messages.

See the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.

## License

`erldist_filter` is MIT licensed, as found in the [LICENSE](LICENSE.md) file.
Loading

0 comments on commit a262064

Please sign in to comment.