Skip to content

Commit 3a88507

Browse files
authoredNov 5, 2024
New release pipeline in operator (ydb-platform#260)
1 parent 5744c87 commit 3a88507

20 files changed

+154
-150
lines changed
 

‎.changes/header.tpl.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

‎.changes/unreleased/.gitkeep

Whitespace-only changes.

‎.changes/v0.5.31.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## v0.5.31 - 2024-11-04
2+
### Added
3+
* Initialized a changelog

‎.changie.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
changesDir: .changes
2+
unreleasedDir: unreleased
3+
headerPath: header.tpl.md
4+
changelogPath: CHANGELOG.md
5+
versionExt: md
6+
versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
7+
kindFormat: '### {{.Kind}}'
8+
changeFormat: '* {{.Body}}'
9+
kinds:
10+
- label: Added
11+
auto: minor
12+
- label: Changed
13+
auto: major
14+
- label: Deprecated
15+
auto: minor
16+
- label: Removed
17+
auto: major
18+
- label: Fixed
19+
auto: patch
20+
- label: Security
21+
auto: patch
22+
newlines:
23+
afterChangelogHeader: 1
24+
beforeChangelogVersion: 1
25+
endOfVersion: 1
26+
envPrefix: CHANGIE_

‎.github/scripts/check-work-copy-equals-to-committed.sh

-11
This file was deleted.

‎.github/scripts/format-all-go-code.sh

-22
This file was deleted.

‎.github/scripts/format-go-code.sh

-13
This file was deleted.

‎.github/scripts/is_autogenerated_file.sh

-10
This file was deleted.
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: create-release-pr
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
create-release-pr:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: checkout
11+
uses: actions/checkout@v4
12+
13+
- name: batch-changes
14+
uses: miniscruff/changie-action@v2
15+
with:
16+
version: latest
17+
args: batch patch
18+
19+
- name: merge-changes
20+
uses: miniscruff/changie-action@v2
21+
with:
22+
version: latest
23+
args: merge
24+
25+
- name: print the latest version
26+
id: latest
27+
uses: miniscruff/changie-action@v2
28+
with:
29+
version: latest
30+
args: latest
31+
32+
- name: print the latest version without "v"
33+
id: latest-no-v
34+
uses: miniscruff/changie-action@v2
35+
with:
36+
version: latest
37+
args: latest --remove-prefix
38+
39+
- name: check-chart-version
40+
run: |
41+
VERSION=${{ steps.latest-no-v.outputs.output }}
42+
APP_VERSION=$(grep '^appVersion:' ./deploy/ydb-operator/Chart.yaml | awk '{print $2}' | tr -d '"')
43+
CHART_VERSION=$(grep '^version:' ./deploy/ydb-operator/Chart.yaml | awk '{print $2}' | tr -d '"')
44+
45+
if [ "$APP_VERSION" != "$VERSION" ] || [ "$CHART_VERSION" != "$VERSION" ]; then
46+
echo "Version mismatch: appVersion ($APP_VERSION) or version ($CHART_VERSION) does not match expected version ($VERSION). You most likely forgot to bump the version in Chart.yaml, please do so."
47+
exit 1
48+
else
49+
echo "Version matches: appVersion ($APP_VERSION) and version ($CHART_VERSION) are both $VERSION."
50+
fi
51+
52+
- name: Create Pull Request
53+
uses: peter-evans/create-pull-request@v7
54+
with:
55+
title: Release ${{ steps.latest.outputs.output }}
56+
branch: release/${{ steps.latest.outputs.output }}
57+
commit-message: Release ${{ steps.latest.outputs.output }}
58+
token: ${{ github.token }}

‎.github/workflows/run-tests.yml

+3-27
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: checkout
15-
uses: actions/checkout@v3
16-
- name: setup-go
17-
uses: actions/setup-go@v3
18-
with:
19-
go-version: '1.20'
15+
uses: actions/checkout@v4
2016
- name: golangci-lint
21-
uses: golangci/golangci-lint-action@v2
22-
with:
23-
version: v1.58.1
24-
code-format-check:
25-
concurrency:
26-
group: lint-autoformat-${{ github.head_ref || github.ref_name }}
27-
cancel-in-progress: true
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: checkout
31-
uses: actions/checkout@v3
32-
- name: setup-go
33-
uses: actions/setup-go@v3
17+
uses: golangci/golangci-lint-action@v6
3418
with:
35-
go-version: '1.20'
36-
- name: install-utilities
37-
run: |
38-
go install mvdan.cc/gofumpt@v0.5.0
39-
go install github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8
40-
- name: format all files with auto-formatter
41-
run: bash ./.github/scripts/format-all-go-code.sh "$PWD"
42-
- name: check-repository-diff
43-
run: bash ./.github/scripts/check-work-copy-equals-to-committed.sh "auto-format broken"
19+
version: v1.61.0
4420
run-unit-tests:
4521
concurrency:
4622
group: run-unit-tests-${{ github.head_ref || github.ref_name }}

‎.github/workflows/upload-artifacts.yml

+33-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
name: upload-artifacts
2+
23
on:
34
push:
45
branches:
56
- master
7+
paths:
8+
- 'CHANGELOG.md'
9+
workflow_dispatch:
10+
611
jobs:
7-
tag-job:
12+
tag-and-release:
813
runs-on: ubuntu-latest
9-
outputs:
10-
tagcreated: ${{steps.tag-step.outputs.tagcreated}}
1114
steps:
12-
- uses: actions/checkout@v3
13-
- id: tag-step
14-
uses: butlerlogic/action-autotag@1.1.2
15-
env:
16-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
- uses: actions/checkout@v4
16+
17+
- name: get-latest-version
18+
uses: miniscruff/changie-action@v2
1719
with:
18-
strategy: regex
19-
root: "./deploy/ydb-operator/Chart.yaml"
20-
regex_pattern: 'version:[\s]*(["]?[0-9\.]{3,}["]?)'
21-
upload-artifacts:
22-
runs-on: ubuntu-latest
23-
needs: tag-job
24-
if: ${{ needs.tag-job.outputs.tagcreated == 'yes' }}
25-
steps:
26-
- uses: actions/checkout@v3
20+
version: latest
21+
args: latest
22+
- name: get-latest-no-v-version
23+
uses: miniscruff/changie-action@v2
24+
with:
25+
version: latest
26+
# Echoes the same version as previous step, but without "v" prefix.
27+
# Is used as a docker image tag in the release step.
28+
# E.g. "v0.5.31" -> "0.5.31"
29+
args: latest --remove-prefix
30+
31+
- name: update-chart-version-with-release-version
32+
run: |
33+
RELEASE_VERSION=${{ steps.get-latest-no-v-version.outputs.output }}
34+
sed -i 's/<IS_SUBSTITUTED_IN_CI_RELEASE_JOB>/'"$RELEASE_VERSION"'/g' ./deploy/ydb-operator/Chart.yaml
35+
36+
- name: create-tag
37+
uses: mathieudutour/github-tag-action@v6.2
38+
with:
39+
tag_prefix: ""
40+
custom_tag: ${{ steps.get-latest-version.outputs.output }}
41+
github_token: ${{ github.token }}
42+
2743
- name: install-dependencies
2844
run: |
2945
HELM_PKG="helm-v3.10.3-linux-amd64.tar.gz"

‎.golangci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ linters-settings:
5656
check-blank: false
5757
govet:
5858
# report about shadowed variables
59-
check-shadowing: true
59+
shadow: true
6060
fieldalignment: true
6161
golint:
6262
# minimal confidence for issues, default is 0.8
@@ -76,6 +76,7 @@ linters-settings:
7676
gosec:
7777
excludes:
7878
- G101
79+
- G115
7980
fieldalignment:
8081
# print struct with more effective memory layout or not, false by default
8182
suggest-new: true
@@ -129,6 +130,8 @@ linters-settings:
129130
linters:
130131
disable-all: true
131132
enable:
133+
# - cyclop
134+
# - depguardgolang
132135
- dogsled
133136
- errcheck
134137
- errorlint

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
4+
## v0.5.31 - 2024-11-04
5+
### Added
6+
* Initialized a changelog

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![check-pr](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/check-pr.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/check-pr.yml)
1+
[![run-tests](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml)
22
[![upload-artifacts](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml)
33

44
# YDB Kubernetes Operator

‎deploy/ydb-operator/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.5.30
18+
version: "0.5.31"
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.5.30"
24+
appVersion: "0.5.31"

‎docs/README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
This document attempts to be some sort of a table of contents:
22

3-
## Operator release flow
43

5-
See [here](./release-flow.md).
4+
## Working on a feature
65

7-
## Writing and running tests
8-
9-
See [here](./tests.md).
10-
11-
## Storage
12-
13-
#### [Storage state machine schema](./storage-state-machine-schema.md)
14-
15-
This describes which states the Storage object has and in what order they are
16-
traversed.
6+
- don't forget to use `changie` to generate a changelog entry, whenever you complete a feature
7+
- see [here](./tests.md) to learn how to run tests
8+
- see [here](./tests.md) to learn how to release a new version

‎docs/release-flow.md

+12-31
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,15 @@
22

33
#### How and when the operator version is changed
44

5-
The single source of truth is the version number in
6-
[Chart.yaml](https://github.com/ydb-platform/ydb-kubernetes-operator/blob/master/deploy/ydb-operator/Chart.yaml#L18)
7-
file.
8-
9-
It is incremented according to semver practices. Essentially, it is incremented every
10-
time any change is made into either chart or the operator code.
11-
12-
For the contrast, changing some details of Github workflows or rewriting the docs
13-
does not initiate a new release.
14-
15-
#### What the CI does
16-
17-
When you increment the version in `Chart.yaml` and your PR is merged into master, tag
18-
is automatically extracted from the Chart like this:
19-
20-
```
21-
"version: 0.4.22" -> "0.4.22"
22-
```
23-
24-
If the version is new (no previous commit was tagged with this version), then:
25-
26-
- this merge commit gets tagged with version extracted from `Chart.yaml`;
27-
- new docker image is built and uploaded to `cr.yandex/yc/ydb-kubernetes-operator`;
28-
- new chart version is uploaded to https://charts.ydb.tech.
29-
30-
#### What if I forget to bump up the chart version?
31-
32-
Then these changes won't get automatically tagged, new version won't be built and
33-
uploaded and you most likely will notice it immediately when you'll want to use an
34-
updated version. Then you make another PR with a chart version bump and get your
35-
changes rebuilt.
5+
The single source of truth is the changelog.
6+
7+
Currently, version is updated when a developer decides to release a new version by manually invoking
8+
`create-release-pr` workflow in Github Actions:
9+
10+
- invoke `create-release-pr` workflow
11+
- `changie` tool automatically bumps the version and generates an updated CHANGELOG.md
12+
- if a generated `CHANGELOG.md` looks okay, just merge it
13+
- the `upload-artifacts` workflow will:
14+
- substitute the latest version in `Chart.yaml`
15+
- build artifacts (docker image and helm chart) and upload them to all configured registries
16+
- create a new Github release
-33.6 KB
Binary file not shown.

‎docs/storage-state-machine-schema.md

-3
This file was deleted.

‎internal/exec/exec.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func InPod(
5858
if err != nil {
5959
return stdout.String(), stderr.String(), errors.Wrapf(
6060
err,
61+
//nolint:govet // TODO @jorres figure out why non-const error messages are not recommended
6162
fmt.Sprintf("failed to stream execution results back, stdout:\n\"%s\"stderr:\n\"%s\"", stdout.String(), stderr.String()),
6263
)
6364
}

0 commit comments

Comments
 (0)
Please sign in to comment.