Skip to content

Commit 30bdd34

Browse files
Your Namemarkshleifer-coralogix
authored andcommitted
implemented linters in ci
1 parent a4db518 commit 30bdd34

33 files changed

Lines changed: 9096 additions & 74 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
CHART_DIR="${CHART_DIR:-otel-integration/k8s-helm}"
5+
GOLDEN_DIR="${GOLDEN_DIR:-${CHART_DIR}/tests/golden}"
6+
RELEASE_NAME="${HELM_GOLDEN_RELEASE_NAME:-render-check}"
7+
DOMAIN="${HELM_GOLDEN_DOMAIN:-eu2.coralogix.com}"
8+
CLUSTER_NAME="${HELM_GOLDEN_CLUSTER_NAME:-golden-render}"
9+
UPDATE_GOLDEN=false
10+
11+
cases=(
12+
"tail-sampling:tail-sampling-values.yaml"
13+
"windows:values-windows.yaml"
14+
"eks-fargate:values-eks-fargate.yaml"
15+
"ebpf-profiler:values-ebpf-profiler.yaml"
16+
)
17+
18+
usage() {
19+
cat <<'EOF'
20+
Usage: .github/scripts/check-helm-golden-renders.sh [--update]
21+
22+
Renders high-risk otel-integration Helm presets and compares them with the
23+
checked-in golden files.
24+
25+
--update Regenerate the checked-in golden files instead of diffing them.
26+
EOF
27+
}
28+
29+
while (($#)); do
30+
case "$1" in
31+
--update)
32+
UPDATE_GOLDEN=true
33+
;;
34+
-h|--help)
35+
usage
36+
exit 0
37+
;;
38+
*)
39+
echo "Unknown argument: $1" >&2
40+
usage >&2
41+
exit 1
42+
;;
43+
esac
44+
shift
45+
done
46+
47+
require_cmd() {
48+
local cmd="$1"
49+
if ! command -v "$cmd" >/dev/null 2>&1; then
50+
echo "Missing required command: $cmd" >&2
51+
exit 1
52+
fi
53+
}
54+
55+
render_case() {
56+
local name="$1"
57+
local values_file="$2"
58+
local output_file="$3"
59+
60+
helm template "$RELEASE_NAME" "$CHART_DIR" \
61+
-f "${CHART_DIR}/values.yaml" \
62+
-f "${CHART_DIR}/${values_file}" \
63+
--set-string "global.domain=${DOMAIN}" \
64+
--set-string "global.clusterName=${CLUSTER_NAME}" |
65+
sed -e 's/[[:blank:]]*$//' \
66+
| awk '
67+
/^$/ { blanks++; next }
68+
/^---$/ { blanks = 0; print; next }
69+
{
70+
while (blanks > 0) {
71+
print "";
72+
blanks--;
73+
}
74+
print;
75+
}
76+
END {
77+
while (blanks > 0) {
78+
print "";
79+
blanks--;
80+
}
81+
}
82+
' \
83+
> "$output_file"
84+
}
85+
86+
require_cmd helm
87+
require_cmd diff
88+
require_cmd sed
89+
require_cmd awk
90+
91+
helm repo add --force-update open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts >/dev/null
92+
helm repo add --force-update coralogix-charts-virtual https://cgx.jfrog.io/artifactory/coralogix-charts-virtual >/dev/null
93+
helm repo add --force-update coralogix-charts https://cgx.jfrog.io/artifactory/coralogix-charts >/dev/null
94+
helm repo update >/dev/null
95+
helm dependency build "$CHART_DIR"
96+
97+
if [ "$UPDATE_GOLDEN" = true ]; then
98+
mkdir -p "$GOLDEN_DIR"
99+
fi
100+
101+
tmpdir="$(mktemp -d)"
102+
trap 'rm -rf "$tmpdir"' EXIT
103+
104+
failed=0
105+
for case in "${cases[@]}"; do
106+
name="${case%%:*}"
107+
values_file="${case#*:}"
108+
actual="${tmpdir}/${name}.yaml"
109+
expected="${GOLDEN_DIR}/${name}.yaml"
110+
111+
if [ "$UPDATE_GOLDEN" = true ]; then
112+
render_case "$name" "$values_file" "$expected"
113+
echo "Rendered ${expected}"
114+
continue
115+
fi
116+
117+
if [ ! -f "$expected" ]; then
118+
echo "Missing golden render: $expected" >&2
119+
failed=1
120+
continue
121+
fi
122+
123+
render_case "$name" "$values_file" "$actual"
124+
125+
if ! diff -u "$expected" "$actual"; then
126+
echo "Golden render mismatch for ${name}. Re-render with .github/scripts/check-helm-golden-renders.sh --update after reviewing the manifest change." >&2
127+
failed=1
128+
fi
129+
done
130+
131+
exit "$failed"

.github/workflows/chart-version-bump-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- uses: dorny/paths-filter@v2
1616
id: filter
1717
with:
18+
predicate-quantifier: every
1819
filters: | # Determine where the chart change occured and run the appropriate check.
1920
logs-fluent-bit-coralogix:
2021
- 'logs/fluent-bit/k8s-helm/coralogix/**'
@@ -30,6 +31,8 @@ jobs:
3031
- 'otel-infrastructure-collector/k8s-helm/**'
3132
otel-integration:
3233
- 'otel-integration/k8s-helm/**'
34+
- '!otel-integration/k8s-helm/tests/**'
35+
- '!otel-integration/k8s-helm/e2e-test/**'
3336
metrics-prometheus-agent:
3437
- 'metrics/prometheus-agent/**'
3538
metrics-prometheus-operator:

.github/workflows/checks.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
otel-windows-standalone/CHANGELOG.md
5353
5454
check-changelog-updates:
55-
if: github.event.label.name != 'skip changelog'
55+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip changelog') }}
5656
runs-on: ubuntu-latest
5757
name: Check changelog update
5858
steps:
@@ -62,6 +62,7 @@ jobs:
6262
- uses: dorny/paths-filter@v2
6363
id: filter
6464
with:
65+
predicate-quantifier: every
6566
filters: | # Determine where the change occured and run the appropriate check.
6667
logs-fluent-bit-coralogix:
6768
- 'logs/fluent-bit/k8s-helm/coralogix/**'
@@ -79,6 +80,8 @@ jobs:
7980
- 'otel-infrastructure-collector/k8s-helm/**'
8081
otel-integration:
8182
- 'otel-integration/k8s-helm/**'
83+
- '!otel-integration/k8s-helm/tests/**'
84+
- '!otel-integration/k8s-helm/e2e-test/**'
8285
metrics-prometheus-agent:
8386
- 'metrics/prometheus-agent/**'
8487
metrics-prometheus-operator:

.github/workflows/otel-infra-helm-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
with:
1919
create-kind-cluster: "true"
2020
- name: Setup Secret
21-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
21+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
2222
- name: Run chart-testing (install)
2323
run: ct lint-and-install --namespace default --charts otel-infrastructure-collector/k8s-helm
24-

.github/workflows/otel-integration-e2e-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
chmod +x ./get_host_endpoint.sh
3636
./get_host_endpoint.sh
3737
- name: Setup Secret
38-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
38+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
3939
- name: Install chart for testing
4040
env:
4141
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -125,7 +125,7 @@ jobs:
125125
chmod +x ./get_host_endpoint.sh
126126
./get_host_endpoint.sh
127127
- name: Setup Secret
128-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
128+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
129129
- name: Install chart for supervisor testing
130130
env:
131131
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -205,7 +205,7 @@ jobs:
205205
chmod +x ./get_host_endpoint.sh
206206
./get_host_endpoint.sh
207207
- name: Setup Secret
208-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
208+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
209209
- name: Install chart for tail-sampling test
210210
env:
211211
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -267,7 +267,7 @@ jobs:
267267
chmod +x ./get_host_endpoint.sh
268268
./get_host_endpoint.sh
269269
- name: Setup Secret
270-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
270+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
271271
- name: Install chart for span-metrics test
272272
env:
273273
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -327,7 +327,7 @@ jobs:
327327
chmod +x ./get_host_endpoint.sh
328328
./get_host_endpoint.sh
329329
- name: Setup Secret
330-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
330+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
331331
- name: Install cert-manager
332332
run: |
333333
helm repo add jetstack https://charts.jetstack.io

.github/workflows/otel-integration-helm-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
with:
1919
create-kind-cluster: "true"
2020
- name: Setup Secret
21-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
21+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
2222
- name: Run chart-testing (install)
2323
run: ct lint-and-install --namespace default --charts otel-integration/k8s-helm
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Security and Hygiene
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
GITLEAKS_VERSION: 8.24.3
11+
SHELLCHECK_VERSION: 0.10.0
12+
HADOLINT_VERSION: 2.12.0
13+
14+
jobs:
15+
gitleaks:
16+
runs-on: ubuntu-latest
17+
name: gitleaks PR secret scan
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install gitleaks
22+
run: |
23+
set -euo pipefail
24+
mkdir -p "${RUNNER_TEMP}/bin"
25+
curl -sSfL \
26+
-o "${RUNNER_TEMP}/gitleaks.tar.gz" \
27+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
28+
tar -xzf "${RUNNER_TEMP}/gitleaks.tar.gz" -C "${RUNNER_TEMP}/bin" gitleaks
29+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
30+
31+
- name: Scan current tree
32+
run: gitleaks detect --no-git --source . --redact --verbose
33+
34+
shellcheck:
35+
runs-on: ubuntu-latest
36+
name: shellcheck checked-in scripts
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install shellcheck
41+
run: |
42+
set -euo pipefail
43+
mkdir -p "${RUNNER_TEMP}/bin"
44+
curl -sSfL \
45+
-o "${RUNNER_TEMP}/shellcheck.tar.xz" \
46+
"https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
47+
tar -xJf "${RUNNER_TEMP}/shellcheck.tar.xz" \
48+
-C "${RUNNER_TEMP}/bin" \
49+
--strip-components=1 \
50+
"shellcheck-v${SHELLCHECK_VERSION}/shellcheck"
51+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
52+
53+
- name: Lint checked-in shell scripts
54+
run: |
55+
set -euo pipefail
56+
mapfile -d '' scripts < <(find . -type f -name '*.sh' -not -path './tmp/*' -print0)
57+
shellcheck "${scripts[@]}"
58+
59+
hadolint:
60+
runs-on: ubuntu-latest
61+
name: hadolint Dockerfiles
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Install hadolint
66+
run: |
67+
set -euo pipefail
68+
mkdir -p "${RUNNER_TEMP}/bin"
69+
curl -sSfL \
70+
-o "${RUNNER_TEMP}/bin/hadolint" \
71+
"https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VERSION}/hadolint-Linux-x86_64"
72+
chmod +x "${RUNNER_TEMP}/bin/hadolint"
73+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
74+
75+
- name: Lint Dockerfiles
76+
run: |
77+
set -euo pipefail
78+
mapfile -d '' dockerfiles < <(find . -type f \( -name 'Dockerfile' -o -name 'Dockerfile.*' \) -print0)
79+
hadolint "${dockerfiles[@]}"
80+
81+
helm-golden-render:
82+
runs-on: ubuntu-latest
83+
name: Helm golden renders
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- name: Setup Helm
88+
uses: azure/setup-helm@v4
89+
with:
90+
version: v3.12.1
91+
92+
- name: Check high-risk preset renders
93+
run: .github/scripts/check-helm-golden-renders.sh

logs/fluent-bit/image/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
FROM fluent/fluent-bit:3.2.10
22
ARG TARGETARCH
3+
# DL3048: Invalid label key.
4+
# hadolint ignore=DL3048
35
LABEL Maintainer="Coralogix Inc. <info@coralogix.com>"
6+
# DL3048: Invalid label key.
7+
# hadolint ignore=DL3048
48
LABEL Description="Special Fluent-Bit image for Coralogix integration" Vendor="Coralogix Inc." Version="3.2.10"
59
COPY ./functions.lua /fluent-bit/etc/
610
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.yaml"]
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
FROM coralogixrepo/coralogix-fluentd-multiarch:v1.18.0-4
2+
# DL3002: Last USER should not be root.
3+
# hadolint ignore=DL3002
24
USER root
3-
RUN gem install fluent-plugin-docker_metadata_filter
4-
RUN gem install fluent-plugin-script
5-
RUN apt update && apt install -y curl
5+
# DL3028: Pin versions in gem install.
6+
# DL3008: Pin apt packages.
7+
# DL3009: Delete apt lists after installing packages.
8+
# DL3015: Use --no-install-recommends.
9+
# hadolint ignore=DL3028,DL3008,DL3009,DL3015
10+
RUN gem install fluent-plugin-docker_metadata_filter \
11+
&& gem install fluent-plugin-script \
12+
&& apt-get update \
13+
&& apt-get install -y curl
614
COPY fargate.rb /fluentd/etc/
715
COPY fluent.conf /fluentd/etc/
816
COPY firelens.conf /fluentd/etc/

0 commit comments

Comments
 (0)