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

add linters #195

Merged
merged 20 commits into from
Dec 19, 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
63 changes: 16 additions & 47 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,54 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"extends": ["config:recommended"],
"branchPrefix": "grafanarenovatebot/",
"username": "GrafanaRenovateBot",
"gitAuthor": "GrafanaRenovateBot <[email protected]>",
"platformCommit": true,
"platformCommit": "enabled",
"dependencyDashboard": false,
"platform": "github",
"forkProcessing": "enabled",
"repositories": [
"grafana/docker-otel-lgtm"
],
"repositories": ["grafana/docker-otel-lgtm"],
"packageRules": [
{
"matchUpdateTypes": [
"major"
],
"labels": [
"update-major"
]
"matchUpdateTypes": ["major"],
"labels": ["update-major"]
},
{
"matchUpdateTypes": [
"minor"
],
"labels": [
"update-minor"
]
"matchUpdateTypes": ["minor"],
"labels": ["update-minor"]
},
{
"matchUpdateTypes": [
"patch"
],
"labels": [
"automerge-patch"
]
"matchUpdateTypes": ["patch"],
"labels": ["automerge-patch"]
},
{
"matchUpdateTypes": [
"digest"
],
"labels": [
"update-digest"
]
"matchUpdateTypes": ["digest"],
"labels": ["update-digest"]
},
{
"matchPackageNames": [
"open-telemetry/opentelemetry-collector-releases"
],
"matchPackageNames": ["open-telemetry/opentelemetry-collector-releases"],
"allowedVersions": "!/cmd/"
},
{
"matchPackageNames": [
"grafana/loki"
],
"matchPackageNames": ["grafana/loki"],
"allowedVersions": "!/operator/"
},
{
"matchPackageNames": [
"grafana/tempo"
],
"matchPackageNames": ["grafana/tempo"],
"allowedVersions": "!/rc/"
}
],
"vulnerabilityAlerts": {
"enabled": true,
"labels": [
"automerge-security-update"
]
"labels": ["automerge-security-update"]
},
"osvVulnerabilityAlerts": true,
"customManagers": [
{
"customType": "regex",
"description": "Update _VERSION variables in Dockerfiles",
"fileMatch": [
"(^|/|\\.)Dockerfile$",
"(^|/)Dockerfile\\.[^/]*$"
],
"fileMatch": ["(^|/|\\.)Dockerfile$", "(^|/)Dockerfile\\.[^/]*$"],
"matchStrings": [
"# renovate: datasource=(?<datasource>[a-z-]+?)(?: depName=(?<depName>.+?))? packageName=(?<packageName>.+?)(?: versioning=(?<versioning>[a-z-]+?))?\\s(?:ENV|ARG) .+?_VERSION=(?<currentValue>.+?)\\s"
]
Expand Down
22 changes: 22 additions & 0 deletions .github/super-linter.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FILTER_REGEX_EXCLUDE=mvnw
IGNORE_GITIGNORED_FILES=true
JAVA_FILE_NAME=google_checks.xml
# disable kubernetes linter - complains about resource limits, etc
VALIDATE_CHECKOV=false
VALIDATE_GIT_COMMITLINT=false
# we have many duplicate code in our codebase for demo purposes
VALIDATE_JSCPD=false

FIX_ENV=true
FIX_GO=true
FIX_GOOGLE_JAVA_FORMAT=true
FIX_GO_MODULES=true
FIX_JSON=true
FIX_JSON_PRETTIER=true
FIX_MARKDOWN=true
FIX_MARKDOWN_PRETTIER=true
FIX_PYTHON_BLACK=true
FIX_PYTHON_ISORT=true
FIX_PYTHON_PYINK=true
FIX_SHELL_SHFMT=true
FIX_YAML_PRETTIER=true
7 changes: 6 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Acceptance Tests

on: [pull_request]
Expand All @@ -8,6 +9,8 @@ jobs:
steps:
- name: Check out
uses: actions/checkout@v4
with:
path: main
- name: Check out oats
uses: actions/checkout@v4
with:
Expand All @@ -17,11 +20,13 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: "1.23"
cache-dependency-path: oats/go.sum
- name: Build Image for integration tests
working-directory: ./main
run: ./build-lgtm.sh
- name: Run acceptance tests
working-directory: ./main
run: ./scripts/run-acceptance-tests.sh
- name: upload log file
uses: actions/upload-artifact@v4
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/markdown-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: markdown-link-check

on:
pull_request:
paths:
- "**.md"

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: lycheeverse/lychee-action@v2
with:
# remove version after next release of lychee-action
lycheeVersion: latest
args: --include-fragments .
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Release

on:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
name: Renovate
on:
schedule:
- cron: '0 */4 * * *'
- cron: "0 */4 * * *"
jobs:
renovate:
permissions:
Expand All @@ -19,8 +20,8 @@ jobs:
app_id: ${{ secrets.RENOVATEGRAFANABOT_ID }}
private_key: ${{ secrets.RENOVATEGRAFANABOT_PEM }}
- name: Self-hosted Renovate
uses: renovatebot/[email protected]
uses: renovatebot/[email protected]
with:
renovate-version: 37.5.3@sha256:613fe86ea2730c062a42bf097a02563e35cb0d8df4fef08d2c4e50b8cd2ccdbc
configurationFile: .github/renovate.json
token: '${{ steps.generate-token.outputs.token }}'
token: "${{ steps.generate-token.outputs.token }}"
30 changes: 30 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Lint

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-24.04

permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Load super-linter configuration
run: grep -v '^#' .github/super-linter.env | grep -v 'FIX_' >> "$GITHUB_ENV"

- name: Super-linter
uses: super-linter/[email protected]
env:
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.idea
.idea/
venv/
.venv
/container/grafana/*
/container/loki/*
/container/prometheus/*
.lycheecache
*.iml
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters:
# disable: metalinter
11 changes: 11 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Default state for all rules
default: true

# allow long lines for tables and code blocks
MD013:
code_blocks: false
tables: false
line_length: 120

MD024:
allow_different_nesting: true
2 changes: 2 additions & 0 deletions .yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
extends: relaxed
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Contributing

## Building locally

`./build-lgtm.sh` will build the docker image locally.

## Linting

- Markdown lint: `markdownlint -f -i container -i examples/python/venv .` (`-f` fixes simple violations, requires [markdownlint](https://github.com/DavidAnson/markdownlint#markdownlint))
- Markdown link checker: `lychee .` (requires [lychee](https://github.com/lycheeverse/lychee))
- Run all checks: `./scripts/lint.sh`

## Acceptance Tests

Acceptance test cases are defined in `oats.yaml` files in the examples directory. The test cases are run by [oats].
The declarative yaml tests are described in <https://github.com/grafana/oats/blob/main/yaml>.

If a test case fails (lets say "examples/jdbc/spring-boot-reactive-2"), follows these steps:

1. Check out the [oats] repo
1. Check out the [oats] repository
2. Go to the oats folder
3. `cd yaml`
4. Install ginkgo: `go install github.com/onsi/ginkgo/v2/ginkgo`
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# docker-otel-lgtm

[![Super-Linter](https://github.com/grafana/docker-otel-lgtm/actions/workflows/super-linter.yml/badge.svg)](https://github.com/marketplace/actions/super-linter)

An OpenTelemetry backend in a Docker image.

![Components included in the Docker image: OpenTelemetry collector, Prometheus, Tempo, Loki, Grafana](img/overview.png)

The `grafana/otel-lgtm` Docker image is an open source backend for OpenTelemetry that’s intended for development, demo, and testing environments. If you are looking for a production-ready, out-of-the box solution to monitor applications and minimize MTTR (mean time to resolution) with OpenTelemetry and Prometheus, you should try [Grafana Cloud Application Observability](https://grafana.com/products/cloud/application-observability/).
The `grafana/otel-lgtm` Docker image is an open source backend for OpenTelemetry that’s intended for development, demo,
and testing environments.
If you are looking for a production-ready, out-of-the box solution to monitor applications and minimize
MTTR (mean time to resolution) with OpenTelemetry and Prometheus,
you should try [Grafana Cloud Application Observability](https://grafana.com/products/cloud/application-observability/).

## Documentation

* Blog post: [An OpenTelemetry backend in a Docker image: Introducing grafana/otel-lgtm](https://grafana.com/blog/2024/03/13/an-opentelemetry-backend-in-a-docker-image-introducing-grafana/otel-lgtm/)
- Blog post: [An OpenTelemetry backend in a Docker image: Introducing grafana/otel-lgtm](https://grafana.com/blog/2024/03/13/an-opentelemetry-backend-in-a-docker-image-introducing-grafana/otel-lgtm/)

## Get the Docker image

Expand All @@ -31,7 +37,7 @@ The Docker image is available on Docker hub: <https://hub.docker.com/r/grafana/o
You can enable logging for troubleshooting:

| Environment Variable | Enable Logging in |
|------------------------|-------------------------|
| ---------------------- | ----------------------- |
| ENABLE_LOGS_GRAFANA | Grafana |
| ENABLE_LOGS_LOKI | Loki |
| ENABLE_LOGS_PROMETHEUS | Prometheus |
Expand All @@ -43,11 +49,11 @@ This has nothing to do with the application logs, which are collected by OpenTel

#### Persist data across container instantiation

The various components in the repo are configured to write their data to the /data
The various components in the repository are configured to write their data to the /data
directory. If you need to persist data across containers being created and destroyed,
you can mount a volume to the /data directory. Note that this image is intended for
development, demo, and testing environments and persisting data to an external volume
doesn't change that. However, this feature could be useful in certain cases for
doesn't change that. However, this feature could be useful in certain cases for
some users even in testing situations.

## Run lgtm in kubernetes
Expand Down Expand Up @@ -113,12 +119,12 @@ Every example implements a rolldice service, which returns a random number betwe
Each example uses a different application port (to be able to run all applications at the same time).

| Example | Service URL |
|---------|---------------------------------------|
| ------- | ------------------------------------- |
| Java | `curl http://localhost:8080/rolldice` |
| Go | `curl http://localhost:8081/rolldice` |
| Python | `curl http://localhost:8082/rolldice` |
| dotnet | `curl http://localhost:8083/rolldice` |

## Related Work

* Metrics, Logs, Traces and Profiles in Grafana: <https://github.com/grafana/intro-to-mltp>
- Metrics, Logs, Traces and Profiles in Grafana: <https://github.com/grafana/intro-to-mltp>
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Releasing

1. Go to https://github.com/grafana/docker-otel-lgtm/releases/new
1. Go to <https://github.com/grafana/docker-otel-lgtm/releases/new>
2. Click on "Choose a tag", enter the tag name (e.g. `v0.1.0`), and click "Create a new tag".
3. Click on "Generate release notes" to auto-generate the release notes based on the commits since the last release.
4. Click on "Publish release".
2 changes: 1 addition & 1 deletion build-lgtm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

RELEASE=${1:-latest}

docker buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:${RELEASE}
docker buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:"${RELEASE}"
9 changes: 6 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM redhat/ubi9
# hadolint global ignore=DL3059
FROM redhat/ubi9:9.5

# renovate: datasource=github-releases depName=grafana packageName=grafana/grafana
ENV GRAFANA_VERSION=v11.4.0
Expand All @@ -20,7 +21,8 @@ ENV TARGETARCH=${TARGETARCH}
RUN mkdir /otel-lgtm
WORKDIR /otel-lgtm

RUN yum install -y unzip jq procps dos2unix
# hadolint ignore=DL3033
RUN yum install -y unzip jq procps dos2unix && yum clean all

RUN bash -c 'ARCHIVE=grafana-"${GRAFANA_VERSION:1}".linux-"${TARGETARCH}".tar.gz && \
curl -sOL https://dl.grafana.com/oss/release/"${ARCHIVE}" && \
Expand Down Expand Up @@ -68,6 +70,7 @@ COPY run-tempo.sh .
COPY otelcol-config.yaml .
COPY run-otelcol.sh .
COPY run-all.sh .
# hadolint ignore=SC2038,DL4006
RUN find . -maxdepth 1 -type f | xargs dos2unix

CMD /otel-lgtm/run-all.sh
CMD ["/otel-lgtm/run-all.sh"]
Loading
Loading