Skip to content

Commit 620bc1a

Browse files
authored
feat(flow): Remove all dependencies from netobserv-flow chart (#81)
# Description Rename `netobserv` -> `netobserv-flow` and remove all dependencies from `netobserv-flow` chart, follow-up PR will introduce the `netobserv-os` chart that combines the NetObserv Flow Collector, OpenSearch, and OpenSearch Dashboards charts Release flow relies on the [prepare-release](elastiflow/gha-reusable#16) changes. Note, `netobserv-os` will be added in the separate PR due to absent `netobserv-flow` release presence that needs to be used in the dependencies. ## Changes summary * feat: Rename `netobserv` -> `netobserv-flow` Rename `netobserv` -> `netobserv-flow` to make "Flow Collector" component more explicit and follow same pattern that is present in the Ansible Collection * feat: Release flow for multiple charts * `charts/netobserv-flow` is released when changes happen to the `charts/netobserv-flow/*` dir * `charts/netobserv-os` is released when changes happen to the `charts/netobserv-os/*` dir * feat: Remove all dependencies from `netobserv-flow` chart
1 parent 8cda2c4 commit 620bc1a

32 files changed

+248
-150
lines changed

.commitlintrc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extends:
2+
- '@commitlint/config-conventional'
3+
rules:
4+
subject-case: [2, always, ["lower-case","upper-case","camel-case","kebab-case","pascal-case","sentence-case","snake-case","start-case"]]

.github/workflows/ci.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ concurrency:
44
cancel-in-progress: true
55
on:
66
pull_request:
7-
branches:
8-
- main
97
push:
108
branches:
119
- main
1210

1311
jobs:
12+
pr_checks:
13+
name: PR Checks
14+
if: >-
15+
${{
16+
github.event_name == 'pull_request'
17+
&& !(github.event_name == 'pull_request' && github.event.pull_request.user.login == 'github-actions[bot]' && startsWith(github.event.pull_request.title, '[release netobserv-'))
18+
}}
19+
uses: elastiflow/gha-reusable/.github/workflows/reusable_pr_checks.yml@v0
20+
1421
renovate_config_validator:
1522
name: renovate config validator
1623
runs-on: ubuntu-latest
@@ -38,8 +45,14 @@ jobs:
3845
check-latest: true
3946
- name: Build helm dependencies
4047
run: |
41-
helm repo add opensearch https://opensearch-project.github.io/helm-charts/
42-
helm dependency build charts/netobserv
48+
find charts -mindepth 1 -maxdepth 1 -type d | while read -r chart; do
49+
echo Building for ${chart}
50+
(helm dependency list ${chart} || true) | grep -E 'https://' | while read -r dep; do
51+
helm repo add $(echo ${dep} | awk '{print $1}') $(echo ${dep} | awk '{print $4}')
52+
done
53+
54+
helm dependency build ${chart}
55+
done
4356
- name: Set up chart-testing
4457
uses: helm/chart-testing-action@v2.7.0
4558
- name: Run chart-testing (list-changed)

.github/workflows/release.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Release netobserv-flow
3+
concurrency:
4+
group: release-netobserv-flow-${{ github.ref }}
5+
cancel-in-progress: false
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- 'charts/netobserv-flow/*'
12+
13+
jobs:
14+
deploy:
15+
name: Release netobserv-flow
16+
uses: ./.github/workflows/reusable_release.yml
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
with:
21+
chart_name: netobserv-flow
22+
chart_dir: charts/netobserv-flow
23+
chart_yaml_version_keys: '.version'
24+
secrets: inherit
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Release netobserv-os
3+
concurrency:
4+
group: release-netobserv-os-${{ github.ref }}
5+
cancel-in-progress: false
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- 'charts/netobserv-os/*'
12+
13+
jobs:
14+
deploy:
15+
name: Release netobserv-os
16+
uses: ./.github/workflows/reusable_release.yml
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
with:
21+
chart_name: netobserv-os
22+
chart_dir: charts/netobserv-os
23+
chart_yaml_version_keys: '.version,.appVersion'
24+
secrets: inherit
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
on:
3+
workflow_call:
4+
inputs:
5+
chart_name:
6+
type: string
7+
required: true
8+
description: "Chart name to release"
9+
chart_dir:
10+
type: string
11+
required: true
12+
description: "Chart path to release"
13+
chart_yaml_version_keys:
14+
type: string
15+
required: true
16+
description: "Keys in the Chart.yaml to replace with the new version"
17+
repository_owner:
18+
type: string
19+
default: elastiflow
20+
description: "Repository owner to push the Helm registry index"
21+
repository_name:
22+
type: string
23+
default: helm-chart-netobserv
24+
description: "Repository name to push the Helm registry index"
25+
runs-on:
26+
type: string
27+
default: ubuntu-latest
28+
description: "GHA runner for the job (ubuntu-latest, ubuntu-latest-4c, ubuntu-latest-8c)"
29+
timeout-minutes:
30+
type: number
31+
default: 15
32+
description: "Job timeout in minutes"
33+
34+
jobs:
35+
# Detect if a commit was made from a release PR with title like '[release v0.1.1] (#49)'
36+
release_or_pr:
37+
name: Release or Release PR?
38+
runs-on: ${{ inputs.runs-on }}
39+
timeout-minutes: ${{ inputs.timeout-minutes }}
40+
outputs:
41+
is_release: ${{ steps.release_or_pr.outputs.is_release }}
42+
steps:
43+
- id: release_or_pr
44+
env:
45+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
46+
run: |
47+
cat > /tmp/commit_message <<- EOF
48+
${COMMIT_MESSAGE}
49+
EOF
50+
51+
# https://regex101.com/r/plAysi/1
52+
echo $(grep -Pq '^\[release netobserv-[a-z]+-(?:[0-9]{1,3}\.?){3}(?:-rc(?:\.[0-9]{1,3})?)?\] \(#[0-9]{1,5}\)$' /tmp/commit_message && echo true || echo false) > /tmp/is_release
53+
echo "is_release=$(cat /tmp/is_release)" >> $GITHUB_OUTPUT
54+
55+
echo is_release=$(cat /tmp/is_release)
56+
57+
58+
release_pr_create:
59+
name: Release PR create
60+
needs: [release_or_pr]
61+
if: ${{ ! fromJson(needs.release_or_pr.outputs.is_release) }}
62+
runs-on: ${{ inputs.runs-on }}
63+
timeout-minutes: ${{ inputs.timeout-minutes }}
64+
permissions:
65+
contents: write
66+
pull-requests: write
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v5
70+
- name: Prepare ${{ inputs.chart_name }} Release
71+
id: prepare_release
72+
uses: elastiflow/gha-reusable/actions/prepare-release@v0
73+
with:
74+
semantic_release_working_directory: ${{ inputs.chart_dir }}
75+
semantic_release_monorepo: true
76+
changelog_update: true
77+
changelog_path: ${{ inputs.chart_dir }}/CHANGELOG.md
78+
bump_version_yaml: true
79+
bump_version_yaml_path: ${{ inputs.chart_dir }}/Chart.yaml
80+
bump_version_yaml_key: ${{ inputs.chart_yaml_version_keys }}
81+
github_token: ${{ secrets.GITHUB_TOKEN }}
82+
- name: Create Pull Request
83+
if: ${{ fromJson(steps.prepare_release.outputs.new_release_published) }}
84+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
85+
with:
86+
token: ${{ secrets.GITHUB_TOKEN }}
87+
base: "${{ github.ref_name }}"
88+
branch: release-${{ inputs.chart_name }}-from-${{ github.ref_name }}
89+
title: '[release ${{ inputs.chart_name }}-${{ steps.prepare_release.outputs.new_release_version }}]'
90+
body: |
91+
# Description
92+
Release the v${{ steps.prepare_release.outputs.new_release_version }} version
93+
94+
# Changelog
95+
${{ steps.prepare_release.outputs.new_release_notes }}
96+
97+
release:
98+
name: Release
99+
needs: [release_or_pr]
100+
if: ${{ fromJson(needs.release_or_pr.outputs.is_release) }}
101+
runs-on: ${{ inputs.runs-on }}
102+
timeout-minutes: ${{ inputs.timeout-minutes }}
103+
permissions:
104+
contents: write
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v5
108+
with:
109+
fetch-depth: 0
110+
- name: Prepare Release
111+
id: prepare_release
112+
uses: elastiflow/gha-reusable/actions/prepare-release@v0
113+
with:
114+
semantic_release_working_directory: ${{ inputs.chart_dir }}
115+
semantic_release_monorepo: true
116+
add_git_notes: true
117+
github_token: ${{ secrets.GITHUB_TOKEN }}
118+
- name: Configure Git
119+
run: |
120+
git config user.name "$GITHUB_ACTOR"
121+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
122+
- name: Install Helm
123+
uses: azure/setup-helm@v4
124+
- name: Install Helm dependencies
125+
run: |
126+
(helm dependency list ${{ inputs.chart_dir }} || true) | grep -E 'https://' | while read -r dep; do
127+
helm repo add $(echo ${dep} | awk '{print $1}') $(echo ${dep} | awk '{print $4}')
128+
done
129+
- name: Install chart-releaser
130+
uses: helm/chart-releaser-action@v1.7.0
131+
env:
132+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
133+
with:
134+
install_only: true
135+
- name: Package helm chart
136+
run: |
137+
cr package ${{ inputs.chart_dir }}
138+
- name: Create GH release
139+
if: ${{ fromJson(steps.prepare_release.outputs.new_release_published) }}
140+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8
141+
with:
142+
name: ${{ inputs.chart_name }}-${{ steps.prepare_release.outputs.new_release_version }}
143+
tag_name: ${{ inputs.chart_name }}-${{ steps.prepare_release.outputs.new_release_version }}
144+
body: ${{ steps.prepare_release.outputs.new_release_notes }}
145+
target_commitish: ${{ github.ref_name }}
146+
preserve_order: true
147+
make_latest: true
148+
files: ".cr-release-packages/${{ inputs.chart_name }}-*.tgz"
149+
- name: Update GH pages index
150+
run: |
151+
mkdir .cr-index
152+
cr index --push -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ inputs.repository_owner }} --git-repo ${{ inputs.repository_name }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
# Misc
99
tmp.*
10-
charts/netobserv/charts/**
10+
charts/**/charts/*
1111
helm_rendered

CHANGELOG.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)