Skip to content

Commit fc0ada9

Browse files
authored
feat: improve CI and configure pre-commit (#11)
1 parent ca3b99c commit fc0ada9

File tree

16 files changed

+99
-30
lines changed

16 files changed

+99
-30
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ RUN mkdir -p ~/.ssh
8383
RUN chmod 600 ./helm-repo-updater-test
8484

8585
# Add git-server access with helm-repo-updater-test key to know_hosts
86-
RUN echo "git-server $(ssh-keygen -f ./helm-repo-updater-test -y | cut -d' ' -f-2)" >> ~/.ssh/known_hosts
86+
RUN echo "git-server $(ssh-keygen -f ./helm-repo-updater-test -y | cut -d' ' -f-2)" >> ~/.ssh/known_hosts

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"-v", "/var/run/docker.sock:/var/run/docker.sock",
2424

2525
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined",
26-
26+
2727
// Use same network as created for docker-compose that create git-server container
2828
"--network=vsc-helm-repo-updater-network"
2929
],
@@ -45,4 +45,4 @@
4545
"golang.go",
4646
"ms-azuretools.vscode-docker"
4747
]
48-
}
48+
}

.github/workflows/build-tools.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525

2626
- name: Build and publish Tools image
2727
run: make publish-build-tools
28-
28+
2929
- name: Build and publish Git Server tool image
30-
run: make publish-git-server-tool
30+
run: make publish-git-server-tool

.github/workflows/pull_request_tests.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,36 @@ on:
88
- synchronize
99

1010
jobs:
11-
lint:
12-
name: Lint
11+
static-checks:
12+
name: Static Checks
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
17-
- uses: golangci/golangci-lint-action@v2
16+
- uses: actions/[email protected]
17+
with:
18+
python-version: '3.9'
19+
- uses: actions/setup-go@v2
1820
with:
19-
version: v1.40.1
20-
21-
tests:
22-
name: Tests
21+
go-version: 1.17
22+
- name: Get golangci-lint
23+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION}
24+
env:
25+
GOLANGCI_LINT_VERSION: "1.44.0"
26+
- uses: pre-commit/[email protected]
27+
28+
unit-tests:
29+
name: Unit Tests
2330
runs-on: ubuntu-latest
24-
container:
31+
container:
2532
image: ghcr.io/docplanner/helm-repo-updater/build-tools:develop
26-
# TODO: Remind to delete this part when we make public the repository
33+
# TODO: Remind to delete this part when we make public the repository
2734
credentials:
2835
username: ${{ github.actor }}
2936
password: ${{ secrets.CR_PAT }}
3037
services:
3138
git-server:
3239
image: ghcr.io/docplanner/helm-repo-updater/git-repo-server:develop
33-
# TODO: Remind to delete this part when we make public the repository
40+
# TODO: Remind to delete this part when we make public the repository
3441
credentials:
3542
username: ${{ github.actor }}
3643
password: ${{ secrets.CR_PAT }}

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set Docker Image Registry Env
2323
run: |
2424
echo DOCKER_IMAGE_REGISTRY=$(echo "${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
25-
25+
2626
- name: Test DOCKER_IMAGE_REGISTRY value
2727
run: echo ${{ env.DOCKER_IMAGE_REGISTRY }}
2828

@@ -57,4 +57,4 @@ jobs:
5757
push: true
5858
tags: |
5959
${{ env.DOCKER_IMAGE_REGISTRY }}:${{ steps.get_version.outputs.VERSION }}
60-
${{ env.DOCKER_IMAGE_REGISTRY }}:latest
60+
${{ env.DOCKER_IMAGE_REGISTRY }}:latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# vendor/
1616

1717
# VisualStudioCode
18-
.vscode/*
18+
.vscode/*
1919

2020
### Intellij ###
2121
.idea

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
default_stages: [commit, push]
2+
minimum_pre_commit_version: "1.20.0"
3+
repos:
4+
- repo: https://github.com/dnephin/pre-commit-golang
5+
rev: v0.3.5
6+
hooks:
7+
- id: go-fmt
8+
name: Run go fmt against the code
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v3.4.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-merge-conflict
15+
- id: mixed-line-ending
16+
- repo: https://github.com/thlorenz/doctoc.git
17+
rev: v2.0.0
18+
hooks:
19+
- id: doctoc
20+
name: Add TOC for md files
21+
files: ^README\.md$|^CONTRIBUTING\.md$
22+
args:
23+
- "--maxlevel"
24+
- "3"
25+
- repo: local
26+
hooks:
27+
- id: golangci-lint
28+
language: golang
29+
name: Run golangci against the code
30+
entry: golangci-lint run
31+
types: [go]
32+
pass_filenames: false

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ RUN wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/
1313
COPY hack/ /usr/local/bin/
1414
COPY --from=builder /go/src/build/dist/ .
1515

16-
ENTRYPOINT ["./helm-repo-updater"]
16+
ENTRYPOINT ["./helm-repo-updater"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ publish-git-server-tool: ## Publish git-server-tool image
8383

8484
$(GOBIN_TOOL):
8585
go get github.com/myitcv/gobin
86-
go install github.com/myitcv/gobin
86+
go install github.com/myitcv/gobin

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
# helm-repo-updater
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents**
4+
5+
- [helm-repo-updater](#helm-repo-updater)
6+
- [Scope](#scope)
7+
- [pre-commit](#pre-commit)
8+
9+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
10+
11+
# helm-repo-updater
12+
13+
## Scope
14+
15+
This repo aims to manage the development of `helm-repo-updater`, a CLI tool whose objective is to update one or more sets of value keys in the `values.yaml` files used by a [helm chart](https://helm.sh/docs/topics/charts/) stored in a specific git repository, using a commit with the desired change in the repository where the `values.yaml` file is stored.
16+
17+
## pre-commit
18+
19+
This repo leverage [pre-commit](https://pre-commit.com) to lint, secure, document the codebase. The [pre-commit](https://pre-commit.com) configuration require the following dependencies installed locally:
20+
- [pre-commit](https://pre-commit.com/#install)
21+
- [golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
22+
23+
**One first repo download, to install the pre-commit hooks it's necessary execute the following command**:
24+
```
25+
pre-commit install
26+
```
27+
28+
**To run the hooks at will it's necessary execute the following command**:
29+
```
30+
pre-commit run -a
31+
```

0 commit comments

Comments
 (0)