Skip to content

Commit 49b9cce

Browse files
committed
ci: refactor and fix gitignore & make targets
refactor of CI jobs: divide the checks b/n code vs non-code which helps in easily turning off one or the other during fixing any CI issues and also consolidates jobs by similarity. gitignore fix: PR 311 brought new vendor dependency and that is being git ignored unintentionally which created failures while running in CI, previous PR was merged as not to get blocked by explicitly doing a `go mod tidy` and `go mod vendor` which masked the original issue. as not to hit this again, added a new condition for verifying deps from mandatory parts for build if they are being git ignored. golang cache: as we were using `vendor/` for the project there is no need to cache mod dependencies again and this is removed except for a single job where it makes sense, infact storing & loading cache is increasing the overall time w/ no added benefit. concurrency of jobs: added a concurrency check to the action as to cancel running jobs if PR is pushed in quick successions as not to do work on older changes. makefile: do not update dependencies implicitiy before testing as that could mask potentially issues which effectively makes updating dependencies a separate step. Signed-off-by: Leela Venkaiah G <[email protected]>
1 parent 218ff6a commit 49b9cce

16 files changed

+622
-151
lines changed

.github/workflows/codespell.yaml

-23
This file was deleted.

.github/workflows/commitlint.yaml

-28
This file was deleted.

.github/workflows/docker-push.yaml .github/workflows/dispatch-image-push.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
---
12
name: image-publisher
2-
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
36
on:
47
workflow_dispatch:
58
inputs:
@@ -9,25 +12,22 @@ on:
912
IMAGE_TAG:
1013
required: false
1114
default: ""
12-
1315
jobs:
1416
docker-push:
1517
name: docker-push
1618
runs-on: ubuntu-latest
1719
steps:
1820
- uses: actions/checkout@v4
19-
2021
- uses: actions/setup-go@v5
2122
with:
2223
go-version-file: go.mod
23-
24+
cache: false
2425
- name: Login to Quay
2526
uses: docker/login-action@v3
2627
with:
2728
registry: quay.io
2829
username: ${{ secrets.QUAY_USERNAME }}
2930
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
30-
3131
- name: Build and push docker images
3232
env:
3333
REGISTRY_NAMESPACE: ${{ github.event.inputs.REGISTRY_NAMESPACE }}

.github/workflows/golangci-lint.yaml

-34
This file was deleted.
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: lint-and-spellcheck
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
on:
7+
pull_request:
8+
branches: ['*']
9+
jobs:
10+
codespell:
11+
name: codespell
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: codespell
16+
uses: codespell-project/actions-codespell@v2
17+
with:
18+
exclude_file: go.sum
19+
check_filenames: true
20+
check_hidden: true
21+
skip: vendor
22+
commitlint:
23+
name: commitlint
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
# we check commitlint for every 20 commits
29+
fetch-depth: 20
30+
- name: run commitlint
31+
uses: wagoid/commitlint-github-action@v5
32+
with:
33+
configFile: './.github/workflows/conf/commitlintrc.json'
34+
helpURL: |
35+
Some helpful links
36+
Contribution Guide -> https://github.com/red-hat-storage/odf-operator/blob/main/CONTRIBUTING.md#commit-structure
37+
Naming Conventions -> https://commitlint.js.org/#/concepts-commit-conventions
38+
Rules -> https://commitlint.js.org/#/reference-rules
39+
How to Write a Good Git Commit Message -> https://chris.beams.io/posts/git-commit
40+
yamllint:
41+
name: yamllint
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: yamllint
46+
uses: ibiqlik/action-yamllint@v3
47+
with:
48+
config_file: ./.github/workflows/conf/yamllint.yaml
49+
file_or_dir: . # Recursive on all yaml files

.github/workflows/docker-build.yaml .github/workflows/operator-build-pipeline.yaml

+21-25
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,59 @@
11
---
2-
name: image-builder
3-
2+
name: operator-build-pipeline
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
46
on:
5-
push:
6-
branches: ['*']
77
pull_request:
88
branches: ['*']
9-
109
jobs:
10+
golangci-lint:
11+
name: golangci-lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version-file: go.mod
18+
cache: false
19+
- name: Source build env variables
20+
run: |
21+
grep -v '^#' hack/build.env >> $GITHUB_ENV
22+
- uses: golangci/golangci-lint-action@v6
23+
with:
24+
version: ${{ env.GO_LINT_IMG_TAG }}
25+
args: --config=.golangci.yaml -v
1126
container-build:
1227
name: operator-build
1328
runs-on: ubuntu-latest
1429
steps:
1530
- uses: actions/checkout@v4
16-
1731
- uses: actions/setup-go@v5
1832
with:
1933
go-version-file: go.mod
20-
21-
- name: Run go mod tidy
22-
run: |
23-
make godeps-update
24-
34+
cache: false
2535
- name: Build operator container image
2636
run: make build
27-
2837
bundle-build:
2938
name: bundle-build
3039
runs-on: ubuntu-latest
3140
steps:
3241
- uses: actions/checkout@v4
33-
3442
- uses: actions/setup-go@v5
3543
with:
3644
go-version-file: go.mod
3745
cache: false
38-
39-
- name: Run go mod tidy
40-
run: |
41-
make godeps-update
42-
4346
- name: Build operator bundle container image
4447
run: make bundle-build
45-
4648
catalog-build:
4749
name: catalog-build
4850
runs-on: ubuntu-latest
4951
steps:
5052
- uses: actions/checkout@v4
51-
5253
- uses: actions/setup-go@v5
5354
with:
5455
go-version-file: go.mod
5556
cache: false
56-
57-
- name: Run go mod tidy
58-
run: |
59-
make godeps-update
60-
6157
- name: Build catalog container image
6258
env:
6359
IMAGE_REGISTRY: localhost:5000

.github/workflows/verify-generated.yaml

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
---
22
name: verify-generated
3-
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
46
on:
5-
push:
6-
branches: ['*']
7-
paths:
8-
- hack/**
9-
- Makefile
10-
- config/manager/csi-images.yaml
11-
- go.mod
12-
- go.sum
13-
- vendor
147
pull_request:
158
branches: ['*']
169
paths:
@@ -20,7 +13,6 @@ on:
2013
- go.mod
2114
- go.sum
2215
- vendor
23-
2416
jobs:
2517
csi-images-manifest:
2618
name: verify-generated-changes
@@ -30,14 +22,14 @@ jobs:
3022
runs-on: ${{ matrix.os }}
3123
steps:
3224
- uses: actions/checkout@v4
33-
3425
- uses: actions/setup-go@v5
3526
with:
3627
go-version-file: go.mod
37-
28+
cache-dependency-path: |
29+
./go.sum
30+
api/go.sum
3831
- name: Verify go deps
3932
run: make godeps-verify
40-
4133
- name: Verify bundle
4234
run: |
4335
make bundle

.github/workflows/yamllint.yaml

-18
This file was deleted.

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
bin/
22
testbin/
33

4-
catalog
5-
catalog.Dockerfile
4+
./catalog
5+
./catalog.Dockerfile
66

77
# Created by https://www.toptal.com/developers/gitignore/api/go,vim,visualstudiocode,git
88
# Edit at https://www.toptal.com/developers/gitignore?templates=go,vim,visualstudiocode,git

.golangci.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# options for analysis running
44
run:
55
# timeout for analysis, e.g. 30s, 5m, default is 1m
6-
timeout: 2m
6+
timeout: 5m
7+
modules-download-mode: vendor
8+
allow-parallel-runners: true
79
linters:
810
disable-all: true
911
enable:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ godeps-verify: godeps-update
5656
@echo "Verifying go-deps"
5757
./hack/godeps-verify.sh
5858

59-
test-setup: godeps-update generate fmt vet envtest ## Run setup targets for tests
59+
test-setup: generate fmt vet envtest ## Run setup targets for tests
6060

6161
go-test: ## Run go test against code.
6262
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN_DIR) -p path)" go test -coverprofile cover.out `go list ./... | grep -v "e2e"`

hack/godeps-verify.sh

+3
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ if [[ -n "$(git status --porcelain "${paths[@]}")" ]]; then
66
git diff -u "${paths[@]}"
77
echo "Inconsistency found in dependency files. Run 'make godeps-update' and commit results."
88
exit 1
9+
elif [[ -n "$(git status --ignored --porcelain "${paths[@]}")" ]]; then
10+
echo ".gitignore file is excluding required files for build from [${paths[@]}]"
11+
exit 1
912
fi
1013
echo "Success: no out of source tree changes found for dependency files"

0 commit comments

Comments
 (0)