forked from konflux-ci/internal-services
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Moreno García <[email protected]>
- Loading branch information
1 parent
635671c
commit 5542f3e
Showing
5 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.github/gitlint/contrib_description_conventional_commits.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
from gitlint.rules import CommitRule, RuleViolation | ||
|
||
|
||
class ConventionalCommitsDescription(CommitRule): | ||
"""This rule will enforce that each commit description starts with | ||
a lowercase.""" | ||
|
||
id = "UC1" | ||
name = "contrib-description-conventional-commits" | ||
|
||
def validate(self, commit): | ||
"""Validate the given commit checking that the description starts with | ||
a lowercase.""" | ||
if ":" not in commit.message.title: | ||
self.log.debug("Title does not follow conventional commit specification") | ||
return | ||
|
||
description = commit.message.title.split(":")[1].strip() | ||
|
||
if len(description) > 0 and description[0].isupper(): | ||
return [ | ||
RuleViolation( | ||
self.id, "Description should start with lowercase", line_nr=1 | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Code Coverage Report | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18 | ||
- name: Run tests | ||
run: make test | ||
- name: Codecov | ||
uses: codecov/codecov-action@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
name: Go Test on Pull Requests | ||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
paths: | ||
- '**.go' | ||
workflow_dispatch: | ||
jobs: | ||
gosec: | ||
name: Check GO security | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Run Gosec Security Scanner | ||
uses: securego/gosec@master | ||
with: | ||
args: -exclude-generated ./... | ||
env: | ||
GOROOT: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
name: Go Test on Pull Requests | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
jobs: | ||
go: | ||
name: Check sources | ||
runs-on: ubuntu-20.04 | ||
env: | ||
OPERATOR_SDK_VERSION: v1.18.0 | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18 | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Cache Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | ||
uses: actions/cache@v2 | ||
id: cache-operator-sdk | ||
with: | ||
path: ~/cache | ||
key: operator-sdk-${{ env.OPERATOR_SDK_VERSION }} | ||
- name: Download Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | ||
if: steps.cache-operator-sdk.outputs.cache-hit != 'true' | ||
run: | | ||
mkdir -p ~/cache | ||
wget https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null | ||
chmod +x ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} | ||
- name: Install Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | ||
run: | | ||
mkdir -p ~/bin | ||
cp ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} ~/bin/operator-sdk | ||
echo "$HOME/bin" >> $GITHUB_PATH | ||
- name: Regenerate executables with current environment packages | ||
run: | | ||
rm -f bin/kustomize bin/controller-gen | ||
make kustomize controller-gen | ||
- name: Cache go modules | ||
id: cache-mod | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Download dependencies | ||
run: go mod download | ||
if: steps.cache-mod.outputs.cache-hit != 'true' | ||
- name: Check go mod status | ||
run: | | ||
go mod tidy | ||
if [[ ! -z $(git status ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' -s) ]] | ||
then | ||
echo "Go mod state is not clean:" | ||
git --no-pager diff ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' | ||
exit 1 | ||
fi | ||
- name: Check format | ||
run: | | ||
make fmt | ||
if [[ ! -z $(git status ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' -s) ]] | ||
then | ||
echo "Some files are not properly formatted." | ||
echo "Please run `go fmt` and amend your commit." | ||
git --no-pager diff ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' | ||
exit 1 | ||
fi | ||
- uses: dominikh/[email protected] | ||
with: | ||
version: "2022.1" | ||
install-go: false | ||
- name: Check manifests | ||
run: | | ||
make generate manifests | ||
if [[ ! -z $(git status ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' -s) ]] | ||
then | ||
echo "generated sources are not up to date:" | ||
git --no-pager diff ':(exclude)bin/kustomize' ':(exclude)bin/controller-gen' | ||
exit 1 | ||
fi | ||
- name: Run Go Tests | ||
run: make test | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
- name: Ensure make build succeeds | ||
run: make build | ||
- name: Ensure make bundle succeeds | ||
run: make bundle | ||
docker: | ||
name: Check docker build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check if dockerimage build is working | ||
run: docker build -f ./Dockerfile . | ||
gitlint: | ||
name: Run gitlint checks | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Install gitlint into container | ||
run: python -m pip install gitlint | ||
- name: Run gitlint check | ||
run: gitlint --commits origin/${{ github.event.pull_request.base.ref }}..HEAD | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Documentation: https://docs.codecov.io/docs/codecov-yaml | ||
ignore: | ||
- "api/v1alpha1/zz_generated.deepcopy.go" # generated file | ||
|
||
coverage: | ||
status: | ||
# Allows coverage to drop by a 3% when compared against the base commit. | ||
project: | ||
default: | ||
target: auto | ||
threshold: 3% | ||
# Sets the expected status for `codecov/patch` check. | ||
# We set this to be only informational hence it does not cause the check to fail. | ||
patch: | ||
default: | ||
informational: true |