Skip to content

Commit 76a621c

Browse files
author
Mykola Serdiuk
committed
chore: Migrate from gerrit to github pipelines (#17)
1 parent b1b7333 commit 76a621c

File tree

8 files changed

+196
-10
lines changed

8 files changed

+196
-10
lines changed

.github/workflows/pr.yaml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: "pull_request"
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
types: [opened, synchronize, reopened]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
env:
13+
GOLANG_VERSION: '1.20'
14+
15+
jobs:
16+
17+
check-commit-message:
18+
runs-on: ubuntu-20.04
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Check Commit Format
26+
uses: gsactions/commit-message-checker@v2
27+
with:
28+
pattern: '^(fix|feat|docs|style|refactor|test|chore){1}(\([\w\-\.]+\))?(!)?: .+( (#\d+))?$'
29+
error: 'Your commit message should be in the format "type: Description (#issue)". Example: "fix: Update build (#33)"'
30+
excludeDescription: 'true'
31+
excludeTitle: 'true'
32+
checkAllCommitMessages: 'true'
33+
accessToken: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Check Line Length
36+
uses: gsactions/commit-message-checker@v2
37+
with:
38+
pattern: '.{0,50}'
39+
error: 'The maximum line length of 50 characters is exceeded.'
40+
excludeDescription: 'true'
41+
excludeTitle: 'true'
42+
checkAllCommitMessages: 'true'
43+
accessToken: ${{ secrets.GITHUB_TOKEN }}
44+
45+
helm-docs:
46+
needs: [check-commit-message]
47+
runs-on: ubuntu-20.04
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
- name: Set up Go
52+
uses: actions/setup-go@v5
53+
with:
54+
go-version: ${{ env.GOLANG_VERSION }}
55+
56+
- name: Make Build
57+
run: make validate-docs
58+
59+
helm-lint:
60+
needs: [helm-docs]
61+
runs-on: ubuntu-20.04
62+
env:
63+
CHART_DIR: "deploy-templates"
64+
CT_CONFIGS_DIR: "."
65+
CT_CONFIGS_DIR_DEFAULT: "ct-configs"
66+
CT_FILE_PATH: "ct.yaml"
67+
LINTCONF_FILE_PATH: "lintconf.yaml"
68+
CHART_SCHEMA_FILE_PATH: "chart_schema.yaml"
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
75+
- name: Set up Helm
76+
uses: azure/setup-helm@v3
77+
with:
78+
version: v3.12.1
79+
80+
- uses: actions/setup-python@v4
81+
with:
82+
python-version: '3.10'
83+
check-latest: true
84+
85+
- name: Set up chart-testing
86+
uses: helm/[email protected]
87+
88+
- name: Run chart-testing (lint)
89+
run: ct lint --target-branch ${{ github.event.repository.default_branch }} \
90+
--charts ${CHART_DIR}/ \
91+
--config ${CT_FILE_PATH} \
92+
--lint-conf ${LINTCONF_FILE_PATH} \
93+
--chart-yaml-schema ${CHART_SCHEMA_FILE_PATH}
94+
95+
build-and-lint:
96+
needs: [helm-lint]
97+
runs-on: ubuntu-20.04
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
102+
- name: Set up Go
103+
uses: actions/setup-go@v5
104+
with:
105+
go-version: ${{ env.GOLANG_VERSION }}
106+
107+
- name: Make Build
108+
run: make build
109+
110+
- name: Make Test
111+
run: make test
112+
113+
- name: Make Lint
114+
run: make lint
115+
116+
docker-lint:
117+
needs: [build-and-lint]
118+
runs-on: ubuntu-20.04
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v4
122+
- name: Run hadolint
123+
uses: hadolint/[email protected]
124+
with:
125+
dockerfile: Dockerfile
126+
127+
e2e-tests:
128+
name: End-to-end tests
129+
needs: [docker-lint]
130+
runs-on: ubuntu-20.04
131+
strategy:
132+
fail-fast: false
133+
matrix:
134+
# The e2e tests are run on the lowest and highest supported k8s version.
135+
# All Kubernetes version in between expose the same APIs, hence the operator
136+
# should be compatible with them.
137+
kube-version:
138+
- "1.27"
139+
- "1.28"
140+
141+
steps:
142+
- name: Check out code into the Go module directory
143+
uses: actions/checkout@v4
144+
145+
- name: Set up Go
146+
uses: actions/setup-go@v5
147+
with:
148+
go-version: ${{ env.GOLANG_VERSION }}
149+
150+
- name: "install kuttl"
151+
run: ./hack/install-kuttl.sh
152+
153+
- name: "run tests"
154+
env:
155+
KUBE_VERSION: ${{ matrix.kube-version }}
156+
run: make start-kind KUBE_VERSION=$KUBE_VERSION && make e2e
157+
158+
e2e-tests-check:
159+
runs-on: ubuntu-20.04
160+
if: always()
161+
needs: [e2e-tests]
162+
steps:
163+
- name: Print result
164+
run: echo ${{ needs.e2e-tests.result }}
165+
- name: Interpret result
166+
run: |
167+
if [[ success == ${{ needs.e2e-tests.result }} ]]
168+
then
169+
echo "All matrix jobs passed!"
170+
else
171+
echo "One or more matrix jobs failed."
172+
false
173+
fi

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
5353
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
5454

5555
# Use kind cluster for testing
56+
CONTAINER_REGISTRY_URL?="repo"
57+
CONTAINER_REGISTRY_SPACE?="edp"
5658
START_KIND_CLUSTER?=true
5759
KIND_CLUSTER_NAME?="sonar-operator"
5860
KUBE_VERSION?=1.26
@@ -88,9 +90,9 @@ test: fmt vet envtest
8890

8991
## Run e2e tests. Requires kind with running cluster and kuttl tool.
9092
e2e: build
91-
docker build --no-cache -t ${E2E_IMAGE_REPOSITORY}:${E2E_IMAGE_TAG} .
92-
kind load --name $(KIND_CLUSTER_NAME) docker-image ${E2E_IMAGE_REPOSITORY}:${E2E_IMAGE_TAG}
93-
E2E_IMAGE_REPOSITORY=${E2E_IMAGE_REPOSITORY} E2E_IMAGE_TAG=${E2E_IMAGE_TAG} kubectl kuttl test
93+
docker build --no-cache -t ${CONTAINER_REGISTRY_URL}/${CONTAINER_REGISTRY_SPACE}/${E2E_IMAGE_REPOSITORY}:${E2E_IMAGE_TAG} .
94+
kind load --name $(KIND_CLUSTER_NAME) docker-image ${CONTAINER_REGISTRY_URL}/${CONTAINER_REGISTRY_SPACE}/${E2E_IMAGE_REPOSITORY}:${E2E_IMAGE_TAG}
95+
E2E_IMAGE_REPOSITORY=${E2E_IMAGE_REPOSITORY} CONTAINER_REGISTRY_URL=${CONTAINER_REGISTRY_URL} CONTAINER_REGISTRY_SPACE=${CONTAINER_REGISTRY_SPACE} E2E_IMAGE_TAG=${E2E_IMAGE_TAG} kubectl-kuttl test
9496

9597
.PHONY: fmt
9698
fmt: ## Run go fmt

hack/install-kuttl.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sudo curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64
4+
sudo chmod +x /usr/local/bin/kubectl-kuttl
5+
export PATH=$PATH:/usr/local/bin

hack/kind-1.26.yaml

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

hack/kind-1.27.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
6+

hack/kind-1.28.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
image: kindest/node:v1.28.7

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ sonar.projectName=sonar-operator
33
sonar.projectVersion=1.0
44
sonar.go.coverage.reportPaths=coverage.out
55
sonar.test.inclusions=**/*_test.go
6-
sonar.exclusions=**/deploy-templates/**,**/config/**,**/*.groovy,**/helm-chart/**,**/.github/**,**/*generated.*.go,**/mocks/**
6+
sonar.exclusions=**/cache/**,**/config/**,**/deploy-templates/**,**/*_controller.go,**/zz_generated.deepcopy.go,**/*_types.go,**/factory.go,**/mock_*.go,**/*.groovy,**/.github/**,**/api/**,**/tests/**,**/hack/**,**/bundle/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: kuttl.dev/v1beta1
22
kind: TestStep
33
commands:
4-
- command: helm install --set image.repository=${E2E_IMAGE_REPOSITORY} --set image.tag=${E2E_IMAGE_TAG} --replace --wait sonar-operator-e2e ../../../deploy-templates
4+
- command: helm install --set image.repository=${CONTAINER_REGISTRY_URL}/${CONTAINER_REGISTRY_SPACE}/${E2E_IMAGE_REPOSITORY} --set image.tag=${E2E_IMAGE_TAG} --replace --wait sonar-operator-e2e ../../../deploy-templates
55
namespaced: true

0 commit comments

Comments
 (0)