Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi-rai committed Jan 24, 2022
1 parent 31071b2 commit beac8f8
Show file tree
Hide file tree
Showing 45 changed files with 3,341 additions and 131 deletions.
6 changes: 6 additions & 0 deletions .bhojpur.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM bhojpur/platform-full
ENV TRIGGER_REBUILD=1
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo BINDIR=/usr/local/bin sh
RUN sudo su -c "cd /usr; curl -L https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-amd64.tar.gz | tar xvz"
# NOTE: remove when platform-full includes golangci
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo BINDIR=/usr/local/bin sh
12 changes: 12 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 1

test_patterns = ["**/*_test.go"]

exclude_patterns = ["scripts/**"]

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_paths = ["github.com/bhojpur/drive"]
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Please use English, because others could join the discussion, if they got similar issue!

Please answer these questions before submitting your issue.

1. Which version of Go and Bhojpur Drive are you using (`drivectl version`)?

2. Which operating system and processor architecture are you using (`go env`)?

3. What did you do?

If possible, provide a recipe for reproducing the error. A complete runnable program is better.
Please provide the database schemas, if it is an ORM issue.

4. What did you expect to see?

5. What did you see instead?
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
43 changes: 43 additions & 0 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
run:
timeout: 5m
skip-files:
- generated.*

issues:
new: true

linters:
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- gci
- gocritic
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nilerr
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- unparam
- varcheck
- whitespace
disable:
- errcheck

linters-settings:
gci:
local-prefixes: github.com/bhojpur/drive
goimports:
local-prefixes: github.com/bhojpur/drive
154 changes: 154 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Unit tests
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'

jobs:
check-go:
name: Check Go code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: ^1.17
- name: Download all Go modules
run: |
go mod download
- name: Check for tidyness of go.mod and go.sum
run: |
go mod tidy
git diff --exit-code -- .
build-go:
name: Build & cache Go code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: ^1.17
- name: Restore go build cache
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Download all Go modules
run: |
go mod download
lint-go:
name: Lint Go code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.39.0
args: --timeout 5m

test-go:
name: Run unit tests
runs-on: ubuntu-latest
needs:
- build-go
services:
# Local registry
registr:
# Docker Hub image
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: ^1.17
- name: Restore go build cache
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Download and vendor all required packages
run: |
go mod download
- name: Build the protobuf
run: pushd pkg/api/v1; sudo chmod 764 ./generate.sh; popd
- name: Install the latest buildkit release
run: |
BUILDKIT_URL="$(curl -sL https://api.github.com/repos/moby/buildkit/releases \
| jq -r 'map(select(.name|startswith("v")))|sort_by(.name)[-1].assets[]|select(.name|endswith(".linux-amd64.tar.gz")).browser_download_url')"
curl -L "${BUILDKIT_URL}" | sudo tar -xz -C /usr/local
- name: Start buildkit daemon
run: |
sudo --non-interactive --shell <<END_SUDO
install -d -m 0750 -o root -g docker /run/buildkit
buildkitd &
while ! test -S /run/buildkit/buildkitd.sock; do sleep 0.1; done
chgrp docker /run/buildkit/buildkitd.sock
END_SUDO
- name: Run all unit tests
env:
BUILDKIT_ADDR: unix:///run/buildkit/buildkitd.sock
TARGET_REF: 127.0.0.1:5000
run: go test -v -coverprofile=coverage.out $(go list ./...)
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v2
with:
name: code-coverage
path: coverage.out

test-go-race:
name: Run unit tests with -race
runs-on: ubuntu-latest
needs:
- build-go
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: ^1.17
- name: Restore go build cache
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Download and vendor all required packages
run: |
go mod download
- name: Run all unit tests
run: go test -race -v $(go list ./...)

analyze:
name: Process & analyze test artifacts
runs-on: ubuntu-latest
needs:
- test-go
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create test-results directory
run: |
mkdir -p test-results
- name: Get code coverage artifiact
uses: actions/download-artifact@v2
with:
name: code-coverage
- name: Upload code coverage information to codecov.io
uses: codecov/codecov-action@v1
with:
file: coverage.out
34 changes: 34 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This action requires that any PR targeting the master branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip
# Changelog" label to disable this action.

name: changelog

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- develop

jobs:
changelog:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.labels.*.name, 'Skip Changelog')"

steps:
- uses: actions/checkout@v2

- name: Check for CHANGELOG changes
run: |
# Only the latest commit of the feature branch is available
# automatically. To diff with the base branch, we need to
# fetch that too (and we only need its latest commit).
git fetch origin ${{ github.base_ref }} --depth=1
if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]]
then
echo "A CHANGELOG was modified. Looks good!"
else
echo "No CHANGELOG was modified."
echo "Please add a CHANGELOG entry, or add the \"Skip Changelog\" label if not required."
false
fi
26 changes: 26 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint
on:
push:
branches:
- master
paths:
- "**/*.go"
- ".github/workflows/golangci-lint.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- ".github/workflows/golangci-lint.yml"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v2

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --config=.github/linters/.golangci.yml
only-new-issues: true
19 changes: 19 additions & 0 deletions .github/workflows/need-feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: need-feeback-issues

on:
schedule:
- cron: "0 * * * *" # pick a cron here, this is every 1h
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: luanpotter/changes-requested@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# these are optional, if you want to configure:
days-until-close: 5
trigger-label: status/need-feedback
closing-comment: This issue was closed by the need-feedback bot due to without feedbacks.
dry-run: false
19 changes: 19 additions & 0 deletions .github/workflows/need-translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: need-translation-issues

on:
schedule:
- cron: "0 * * * *" # pick a cron here, this is every 1h
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: luanpotter/changes-requested@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# these are optional, if you want to configure:
days-until-close: 5
trigger-label: status/need-translation
closing-comment: This issue was closed by the need-translation bot. Please transalate your issue to English so it could help others.
dry-run: false
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Go project

on:
push:
tags:
- "v*" # triggers only if push new tag version, like `0.8.4` or else

jobs:
release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.17
-
name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit beac8f8

Please sign in to comment.