Skip to content

Commit

Permalink
In the beginning there was only Darkness
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed May 24, 2021
1 parent 4cb1e05 commit d505636
Show file tree
Hide file tree
Showing 139 changed files with 35,756 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "06:27"
timezone: "Europe/Warsaw"

- package-ecosystem: "gomod"
directory: "/pkg"
schedule:
interval: "daily"
time: "06:27"
timezone: "Europe/Warsaw"
115 changes: 115 additions & 0 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Dev builds

on:
push:
branches:
- main
- 'release-v[0-9]+.[0-9]+'

jobs:

test:
name: Test
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'darwin_amd64', 'linux_amd64', 'linux_arm64']
steps:
- uses: actions/checkout@v2.3.4
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v2
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-pkg-
- name: Run tests
run: make gotest

lint:
name: Lint (golangci-lint)
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'linux_amd64' ]
steps:
- uses: actions/checkout@v2.3.4
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v2
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-lint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-lint-
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $(go env GOPATH)/bin v1.40.1
- name: Run golangci-lint
run: make golint

build:
name: Build
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'darwin_amd64', 'linux_amd64', 'linux_arm64']
steps:
- uses: actions/checkout@v2.3.4
- name: Fetch current branch
run: ./ci/fetch_current_branch.sh
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v2
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-
- name: Install opentelemetry-collector-builder
run: make install
working-directory: ./otelcolbuilder
- name: Build
run: make otelcol-sumo-${{matrix.arch_os}}
working-directory: ./otelcolbuilder
- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-${{matrix.arch_os}} | \
grep -E "/(receiver|exporter|processor|extension)/" | \
tee otelcol-sumo-${{matrix.arch_os}}_modules.txt
- name: Store binary as action artifact
uses: actions/upload-artifact@v2
with:
name: otelcol-sumo-${{matrix.arch_os}}
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}
if-no-files-found: error
- name: Store list of included modules as action artifact
uses: actions/upload-artifact@v2
with:
name: otelcol-sumo-${{matrix.arch_os}}_modules.txt
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}_modules.txt
if-no-files-found: error
115 changes: 115 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: PRs checks

on:
pull_request:
branches:
- main
- 'release-v[0-9]+.[0-9]+'

jobs:
markdownlint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Install markdownlint
run: gem install mdl
- name: Markdownlint check
run: make markdownlint

yamllint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- name: Install yamllint
run: pip install yamllint
- name: yamllint
run: make yamllint

test:
name: Test
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'darwin_amd64', 'linux_amd64', 'linux_arm64']
steps:
- uses: actions/checkout@v2.3.4
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v2
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-pkg-
- name: Run tests
run: make gotest

lint:
name: Lint (golangci-lint)
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'linux_amd64' ]
steps:
- uses: actions/checkout@v2.3.4
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.40
working-directory: pkg
skip-go-installation: true
skip-pkg-cache: false
skip-build-cache: false

build:
name: Build
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.16' ]
arch_os: [ 'darwin_amd64', 'linux_amd64', 'linux_arm64']
steps:
- uses: actions/checkout@v2.3.4
- name: Fetch current branch
run: ./ci/fetch_current_branch.sh
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v2
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-
- name: Install opentelemetry-collector-builder
run: make install
working-directory: ./otelcolbuilder
- name: Build
run: make otelcol-sumo-${{matrix.arch_os}}
working-directory: ./otelcolbuilder
- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-${{matrix.arch_os}} | \
grep -E "/(receiver|exporter|processor|extension)/"
33 changes: 33 additions & 0 deletions .markdownlint/style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Documentation regarding rules used below can be found at:
# https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md
rule 'MD002'
rule 'MD003'
rule 'MD004', :style => :dash
rule 'MD005'
rule 'MD006'
rule 'MD007'
rule 'MD009'
rule 'MD010'
rule 'MD011'
rule 'MD012'
rule 'MD013', :line_length => 140
rule 'MD014'
rule 'MD018'
rule 'MD019'
rule 'MD020'
rule 'MD021'
rule 'MD022'
rule 'MD023'
rule 'MD024'
rule 'MD026'
rule 'MD027'
rule 'MD028'
rule 'MD029'
rule 'MD030'
rule 'MD031'
rule 'MD032'
rule 'MD035'
rule 'MD037'
rule 'MD038'
rule 'MD039'
rule 'MD046'
13 changes: 13 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends: relaxed

rules:
comments: enable
comments-indentation: disable

line-length:
max: 170
level: warning

indentation:
level: warning
indent-sequences: consistent
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
all: markdownlint yamllint

markdownlint: mdl

mdl:
mdl --style .markdownlint/style.rb \
README.md

yamllint:
yamllint -c .yamllint.yaml \
otelcolbuilder/.otelcol-builder.yaml

# ALL_MODULES includes ./* dirs (excludes . dir and example with go code)
ALL_MODULES := $(shell find ./pkg -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./' )

.PHONY: gotest
gotest:
$(MAKE) for-all CMD="make test"

.PHONY: golint
golint:
$(MAKE) for-all CMD="make lint"

.PHONY: for-all
for-all:
@echo "running $${CMD} in root"
@set -e; for dir in $(ALL_MODULES); do \
(cd "$${dir}" && \
echo "running $${CMD} in $${dir}" && \
$${CMD} ); \
done
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# sumologic-otel-collector
SumoLogic Distro for OpenTelemetry Collector

[![Default branch build](https://github.com/SumoLogic/sumologic-otel-collector/actions/workflows/dev_builds.yml/badge.svg)](https://github.com/SumoLogic/sumologic-otel-collector/actions/workflows/dev_builds.yml)

SumoLogic Distro of [OpenTelemetry Collector][otc_link] built with
[opentelemetry-collector-builder][otc_builder_link].

[otc_link]: https://github.com/open-telemetry/opentelemetry-collector
[otc_builder_link]: https://github.com/open-telemetry/opentelemetry-collector-builder

## How to build

```
$ cd otelcolbuilder && make build
opentelemetry-collector-builder \
--config .otelcol-builder.yaml \
--output-path ./cmd \
--name otelcol-sumo
2021-05-24T16:29:03.494+0200 INFO cmd/root.go:99 OpenTelemetry Collector distribution builder {"version": "dev", "date": "unknown"}
2021-05-24T16:29:03.498+0200 INFO builder/main.go:90 Sources created {"path": "./cmd"}
2021-05-24T16:29:03.612+0200 INFO builder/main.go:126 Getting go modules
2021-05-24T16:29:03.957+0200 INFO builder/main.go:107 Compiling
2021-05-24T16:29:09.770+0200 INFO builder/main.go:113 Compiled {"binary": "./cmd/otelcol-sumo"}
```

In order to build for a different platform one can use `otelcol-sumo-${platform}_${arch}`
make targets e.g.:

```
$ cd otelcolbuilder && make otelcol-sumo-linux_arm64
GOOS=linux GOARCH=arm64 /Library/Developer/CommandLineTools/usr/bin/make build BINARY_NAME=otelcol-sumo-linux_arm64
opentelemetry-collector-builder \
--config .otelcol-builder.yaml \
--output-path ./cmd \
--name otelcol-sumo-linux_arm64
2021-05-24T16:32:11.963+0200 INFO cmd/root.go:99 OpenTelemetry Collector distribution builder {"version": "dev", "date": "unknown"}
2021-05-24T16:32:11.965+0200 INFO builder/main.go:90 Sources created {"path": "./cmd"}
2021-05-24T16:32:12.066+0200 INFO builder/main.go:126 Getting go modules
2021-05-24T16:32:12.376+0200 INFO builder/main.go:107 Compiling
2021-05-24T16:32:37.326+0200 INFO builder/main.go:113 Compiled {"binary": "./cmd/otelcol-sumo-linux_arm64"}
```
Loading

0 comments on commit d505636

Please sign in to comment.