Skip to content

Commit

Permalink
feat: meta agent configuration (newrelic#13)
Browse files Browse the repository at this point in the history
* Create project structure

* Make AgentConfig generic and add integration test for serde_json deserialization

* Remove old Go pipeline checks

* Add newline in files

* Codespell settings

* Define Convertible trait

* Fix Codespell configuration

* Change privacy and visibility

* Remove integration test

* ci: update dependabot to cargo

* ci: move push_pr in favor of check

* ci: add code coverage

* ci: add safety pipeline

* ci: add testing pipeline

* ci: clippy beta toolchain

* ci: add newrelic/caos as code owners

* refactor: apply cargo fmt

* ci: remove minimal versions check

* feat: move to public and lib based

* ci: remove rebase check

Enforced through Github configuration

* fix: allow dependabot updates

* Add Custom Value deserialization in the test and comments

* feat: implement deserialize for enum (newrelic#11)

---------

Co-authored-by: alvarocabanas <[email protected]>
  • Loading branch information
rogercoll and alvarocabanas authored May 17, 2023
1 parent b90406d commit 42299a9
Show file tree
Hide file tree
Showing 22 changed files with 456 additions and 106 deletions.
Empty file removed .codespellignore
Empty file.
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
check-filenames =
check-hidden =
ignore-words-list = crate
skip = ./.git,./Cargo.toml
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence.

* @newrelic/caos
22 changes: 22 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ref: https://docs.codecov.com/docs/codecovyml-reference
coverage:
# Hold ourselves to a high bar
range: 85..100
round: down
precision: 1
status:
# ref: https://docs.codecov.com/docs/commit-status
project:
default:
# Avoid false negatives
threshold: 1%
target: 85%

# Test files aren't important for coverage
ignore:
- "tests"
- "examples"

comment:
layout: "reach, diff, flags, files"
require_changes: false
21 changes: 4 additions & 17 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 3
labels:
- dependencies
- package-ecosystem: docker
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
open-pull-requests-limit: 3
labels:
- dependencies
- package-ecosystem: github-actions
directory: "/"
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
open-pull-requests-limit: 3
labels:
- dependencies
86 changes: 86 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
permissions:
contents: read
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

name: checks
jobs:
codespell:
name: codespell
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Codespell test
uses: codespell-project/actions-codespell@master
fmt:
runs-on: ubuntu-latest
name: stable / fmt
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt --check
run: cargo fmt --check
clippy:
runs-on: ubuntu-latest
name: ${{ matrix.toolchain }} / clippy
permissions:
contents: read
checks: write
strategy:
fail-fast: false
matrix:
toolchain: [stable, beta]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: cargo clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
doc:
runs-on: ubuntu-latest
name: nightly / doc
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: cargo doc
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --cfg docsrs
msrv:
runs-on: ubuntu-latest
strategy:
matrix:
msrv: [1.69.0]
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install ${{ matrix.msrv }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: cargo +${{ matrix.msrv }} check
run: cargo check
34 changes: 34 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: coverage
jobs:
coverage:
runs-on: ubuntu-latest
name: ubuntu / stable / coverage
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo llvm-cov
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
86 changes: 0 additions & 86 deletions .github/workflows/push_pr.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/safety.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: safety
jobs:
miri:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: |
echo "NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV
- name: Install ${{ env.NIGHTLY }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY }}
components: miri
- name: cargo miri test
run: cargo miri test
env:
MIRIFLAGS: ""
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
permissions:
contents: read
on:
# TODO: validate when to trigger the pipeline
push:
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: test
jobs:
required:
runs-on: ubuntu-latest
name: ubuntu / ${{ matrix.toolchain }}
strategy:
matrix:
toolchain: [stable, beta]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo test --locked
run: cargo test --locked --all-features --all-targets
- name: cargo test --doc
run: cargo test --locked --all-features --doc
os-check:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo test
run: cargo test --locked --all-features --all-targets
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "meta-agent"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
config = "0.13.1"
serde = { version = "1.0.160", features = [ "derive" ]}
serde_json = "1.0.96"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@

WIP universal supervisor, powered by OpAMP.

## Sample default static config (/tmp/static.yaml)

```yaml
op_amp: http://newserver.comm
agents:
nr_otel_collector/gateway:
nr_infra_agent:
uuid_dir: /bin/sudoo
```
3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

Empty file removed go.sum
Empty file.
Loading

0 comments on commit 42299a9

Please sign in to comment.