Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
chore: using Bazel as a build system
Browse files Browse the repository at this point in the history
Signed-off-by: danmx <[email protected]>
  • Loading branch information
danmx committed May 22, 2020
1 parent b5dada9 commit b609cfa
Show file tree
Hide file tree
Showing 42 changed files with 2,112 additions and 578 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
scripts/
24 changes: 24 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
startup --expand_configs_in_place

build --collect_code_coverage

# Show us information about failures.
build --verbose_failures
test --test_output=errors

# Include git version and other info
build --stamp
build --workspace_status_command tools/get_workspace_status.sh

# Make /tmp hermetic
build --sandbox_tmpfs_path=/tmp

# Ensure that Bazel never runs as root, which can cause unit tests to fail.
build --sandbox_fake_username

test:unit --build_tests_only

# Cross-compile pure Go
build:cross:darwin_amd64 --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 --cpu=amd64
build:cross:windows_amd64 --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 --cpu=amd64
build:cross:linux_amd64 --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 --cpu=amd64
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.0
56 changes: 56 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
28 changes: 28 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/danmx/sigil
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE
9 changes: 1 addition & 8 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
version = 1

test_patterns = ["**/*_test.go"]
exclude_patterns = ["**/mocks/"]
exclude_patterns = ["**/*_mock_test.go"]

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

[analyzers.meta]
import_path = "github.com/danmx/sigil"

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

[analyzers.meta]
dockerfile_paths = ["Dockerfile"]
6 changes: 0 additions & 6 deletions .dockerignore

This file was deleted.

112 changes: 76 additions & 36 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,102 @@ platform:

steps:
- name: test
image: golang:1.14
image: l.gcr.io/google/bazel:3.1.0
commands:
- make test
- bazel test --config cross:linux_amd64 //...
volumes:
- name: cache
path: /root/.cache/bazel/

- name: coverage
image: l.gcr.io/google/bazel:3.1.0
commands:
- bazel coverage --config cross:linux_amd64 //...
- bazel build --config cross:linux_amd64 :concat-cov
volumes:
- name: cache
path: /root/.cache/bazel/

- name: codecov
image: plugins/codecov
settings:
files:
- coverage.txt
- bazel-bin/coverage.txt
required: true
token:
from_secret: codecov_token
volumes:
- name: cache
path: /root/.cache/bazel/

- name: build-binaries
image: golang:1.14
- name: build-dev
image: l.gcr.io/google/bazel:3.1.0
commands:
- make build build-dev
- bazel build --config cross:linux_amd64 :dev
- bazel build --config cross:darwin_amd64 :dev
- bazel build --config cross:windows_amd64 :dev
- bazel build --config cross:linux_amd64 :dev-image
environment:
REVISION: "${DRONE_COMMIT}"
GIT_BRANCH: ${DRONE_BRANCH}
GIT_COMMIT: ${DRONE_COMMIT}
VERSION: DEV
volumes:
- name: cache
path: /root/.cache/bazel/
when:
event:
- push

- name: build-docker
image: plugins/docker
settings:
build_args:
- VER=DEBUG
- "REV=\"${DRONE_COMMIT}\""
password:
- name: docker-dev
image: l.gcr.io/google/bazel:3.1.0
commands:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- bazel run --config cross:linux_amd64 :push-dev-image
environment:
DOCKER_PASSWORD:
from_secret: docker_password
repo: danmx/sigil
tags:
- debug
target: debug
username:
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: cache
path: /root/.cache/bazel/
when:
event:
- push

- name: build-release
image: golang:1.14
- name: pkg-release
image: l.gcr.io/google/bazel:3.1.0
commands:
- make release
- bazel build --config cross:linux_amd64 :sigil_linux-amd64
- bazel build --config cross:darwin_amd64 :sigil_darwin-amd64
- bazel build --config cross:windows_amd64 :sigil_windows-amd64
environment:
REVISION: "${DRONE_COMMIT}"
VERSION: "${DRONE_TAG}"
GIT_BRANCH: ${DRONE_BRANCH}
GIT_COMMIT: ${DRONE_COMMIT}
VERSION: ${DRONE_TAG}
volumes:
- name: cache
path: /root/.cache/bazel/
when:
event:
- push
- tag

- name: docker-release
image: plugins/docker
settings:
auto_tag: true
build_args:
- "VER=\"${DRONE_TAG}\""
- "REV=\"${DRONE_COMMIT}\""
password:
image: l.gcr.io/google/bazel:3.1.0
commands:
- docker login -u $DOCKER_USERNAME -P $DOCKER_PASSWORD
- bazel run --config cross:linux_amd64 :push-release-image
- bazel run --config cross:linux_amd64 :push-major-release-image
- bazel run --config cross:linux_amd64 :push-minor-release-image
environment:
DOCKER_PASSWORD:
from_secret: docker_password
repo: danmx/sigil
target: prod
username:
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: cache
path: /root/.cache/bazel/
when:
event:
- tag
Expand All @@ -89,13 +118,24 @@ steps:
- sha256
- sha512
files:
- "dist/*"
- bazel-bin/sigil_linux-amd64.tar.gz
- bazel-bin/sigil_darwin-amd64.tar.gz
- bazel-bin/sigil_windows-amd64.zip
note: CHANGELOG.md
title: ${DRONE_TAG}
volumes:
- name: cache
path: /root/.cache/bazel/
when:
event:
- tag

volumes:
- name: cache
temp: {}

---
kind: signature
hmac: 6bf71f4f9351d1dd4fa01be2a085ce6178319adc0d892138f60674c871e184fd
hmac: 8d1e567f27c745f1f2a02606369d012452c58d00eef920bd90c00cdd2eed2abd

...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ bin/
dist/
coverage.txt
*.deb
bazel-*
*mock_test.go
15 changes: 12 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
run:
deadline: 5m
deadline: 1m
tests: true
skip-dirs:
- .git
- bazel-*
- tools
- docs
skip-dirs-use-default: true
modules-download-mode: readonly
allow-parallel-runners: true
linters-settings:
# depguard:
# list-type: blacklist
Expand Down Expand Up @@ -28,7 +37,7 @@ linters-settings:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
# - whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
Expand Down Expand Up @@ -76,7 +85,7 @@ linters:
# - lll
- misspell
- nakedret
- rowserrcheck
# - rowserrcheck
- scopelint
- staticcheck
- structcheck
Expand Down
Loading

0 comments on commit b609cfa

Please sign in to comment.