Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize repository with Readme, CI pipelines and others #2

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Botkube maintainers (email: [email protected])
# Maintainers are listed alphabetically

* @kubeshop/botkube-dev
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug
about: Report a bug in the project
labels: bug
---

<!-- Thank you for your contribution. Before you submit the issue:
1. Search open and closed issues for duplicates.
2. Read the contributing guidelines (CONTRIBUTING.md file on root of the repository).
-->

## Description

<!-- Provide a clear and concise description of the problem.
Describe where it appears, when it occurred, and what it affects.
Provide all relevant technical details such as the Botkube version. -->

## Expected behavior

<!-- Describe what you expect to happen. -->

## Actual behavior

<!-- Describe what happens instead. -->

## Steps to reproduce

<!-- Steps to reproduce the issue. Attach all resources that can help us understand the bug, such as screenshots, links or files. -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest how we can improve
labels: enhancement
---

<!-- Thank you for your contribution. Before you submit the issue:
1. Search open and closed issues for duplicates.
2. Read the contributing guidelines (CONTRIBUTING.md file on root of the repository).
-->

## Overview

<!-- Provide a clear and concise overview of the feature. -->

## Acceptance Criteria

<!-- Provide a list of conditions that must be satisfied to close this issue. -->

## Reason

<!-- Explain why we should add this feature. -->
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Thank you for your contribution. Before you submit the pull request:
1. Follow contributing guidelines, templates, the recommended Git workflow, and any related documentation.
2. Test your changes and attach their results to the pull request.
3. Update the relevant documentation.
-->

## Description

Changes proposed in this pull request:

- ...

## Related issue(s)

<!-- If you refer to a particular issue, provide its number.
To close the issue after the pull request merge, use `Resolves #123` or `Fixes #123`.
Otherwise, use `See also #123` or just `#123`. -->
140 changes: 140 additions & 0 deletions .github/workflows/branch-pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Branch and PR build
on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
cancel-in-progress: ${{ github.event_name == 'pull_request' }} # cancel only PR related jobs

env:
GOLANGCI_LINT_TIMEOUT: 5m
GORELEASER_CURRENT_TAG: "v0.0.0-latest"
BUCKET_NAME: botkube-cloud-plugins-latest

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# When the files to be extracted are already present,
# tar extraction in Golangci Lint fails with the "File exists"
# errors. These files appear to be present because of
# cache in setup-go, on disabling the cache we are no more seeing
# such error. Cache is to be enabled once the fix is available for
# this issue:
# https://github.com/golangci/golangci-lint-action/issues/807
cache: false

- name: "Check code quality"
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=${{ env.GOLANGCI_LINT_TIMEOUT }}

test:
name: Test code
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: 'true'

- name: "Run tests"
run: make test

build-plugins:
name: Build plugins without publish
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: [lint, test]
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest

- name: Build plugins and generate plugins index.yaml
env:
PLUGIN_DOWNLOAD_URL_BASE_PATH: ""
run: |
make build-plugins-archives
USE_ARCHIVE=true make gen-plugin-index

release-latest-plugins:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
name: Build and release latest plugins
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: GCP auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.CLOUD_PLUGINS_LATEST_BUCKET_CREDS }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest

- name: Build plugins and generate plugins index.yaml
env:
PLUGIN_DOWNLOAD_URL_BASE_PATH: ""
run: |
make build-plugins-archives
USE_ARCHIVE=true make gen-plugin-index

- name: Upload plugins to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'dist'
destination: '${{ env.BUCKET_NAME }}/'
glob: '*.tar.gz'
parent: false

- name: Upload plugin index to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'plugins-index.yaml'
destination: '${{ env.BUCKET_NAME }}/'

- name: 'Disable GCS caching'
run: 'gsutil -m setmeta -h "Cache-Control: no-cache, no-store" gs://${{ env.BUCKET_NAME }}/*'
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Trigger release

on:
workflow_dispatch:
inputs:
version:
type: string
description: Version of the next release (e.g. v1.10.0)
required: true

permissions:
contents: write

jobs:
trigger-relase:
name: Trigger release
runs-on: ubuntu-latest
steps:
- name: Create tag
uses: actions/github-script@v7
with:
# Unfortunately PAT is required to create a tag and in that way trigger other workflow.
# Read more here: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
github-token: ${{ secrets.RELEASE_GH_DEV_ACCOUNT_PAT }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ inputs.version }}',
sha: context.sha
})
61 changes: 61 additions & 0 deletions .github/workflows/tag-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Tag build

on:
push:
tags:
- '*'

env:
BUCKET_NAME: botkube-cloud-plugins
VERSION: "${{ github.ref_name }}"

jobs:
release:
name: Release plugins
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout
uses: actions/checkout@v4

- name: GCP auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.CLOUD_PLUGINS_BUCKET_CREDS }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest

- name: Build plugins and generate plugins index.yaml
env:
PLUGIN_DOWNLOAD_URL_BASE_PATH: "${{ env.VERSION }}"
run: |
make build-plugins-archives
USE_ARCHIVE=true make gen-plugin-index

- name: Upload plugins to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'dist'
destination: '${{ env.BUCKET_NAME }}/${{ env.VERSION }}'
glob: '*.tar.gz'
parent: false

- name: Upload plugin index to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'plugins-index.yaml'
destination: '${{ env.BUCKET_NAME }}/${{ env.VERSION }}'
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

dist/
plugins-index.yaml
/.idea/
41 changes: 41 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
run:
tests: true
issues:
exclude-use-default: false
exclude:
# EXC0001 errcheck: source: https://github.com/kubernetes-sigs/controller-runtime/blob/master/.golangci.yml#L94
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# G505: Blocklisted import crypto/sha1: weak cryptographic primitive
# This is used just for hashing in ArgoCD plugin
- G505
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- revive
- gofmt
- misspell
- gochecknoinits
- unparam
- exportloopref
- gosec
- goimports
- whitespace
- bodyclose
- gocyclo

fast: false

linters-settings:
revive:
rules:
# Disable warns about capitalized and ended with punctuation error messages
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
- name: error-strings
disabled: true
Loading
Loading