-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b97fbe6
Showing
25 changed files
with
2,843 additions
and
0 deletions.
There are no files selected for viewing
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,123 @@ | ||
name: go | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "0 12 * * *" | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Check for code generation differences | ||
run: | | ||
make generate | ||
git diff --exit-code | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
# The golangci-lint action takes care of caching by itself. | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Test | ||
env: | ||
AXM_ACCESS_TOKEN: ${{ secrets.TESTING_AZURE_1_STAGING_ACCESS_TOKEN }} | ||
AXM_DEPLOYMENT_URL: ${{ secrets.TESTING_AZURE_1_STAGING_DEPLOYMENT_URL }} | ||
run: make test-integration | ||
|
||
- name: Code coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
fail_ci_if_error: true | ||
|
||
- name: Update GoReport Card | ||
uses: creekorful/[email protected] | ||
|
||
release: | ||
name: Release | ||
needs: | ||
- check | ||
- lint | ||
- test | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Release | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
# 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 | ||
|
||
# Build artifacts | ||
dist | ||
|
||
# Go mod timestamp for Makefile | ||
/dep.stamp | ||
|
||
# Local $GOBIN directory for tools | ||
/bin/ |
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,52 @@ | ||
run: | ||
modules-download-mode: readonly | ||
skip-dirs: | ||
- .git | ||
- .github | ||
- bin | ||
- dist | ||
build-tags: | ||
- integration | ||
|
||
linters: | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exhaustive | ||
- exportloopref | ||
- goconst | ||
- gofmt | ||
- goimports | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nolintlint | ||
- prealloc | ||
- revive | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
goimports: | ||
local-prefixes: github.com/lukasmalkmus/icloud-go | ||
govet: | ||
check-shadowing: true | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: false | ||
require-explanation: true | ||
require-specific: true |
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,28 @@ | ||
project_name: icloud-go | ||
|
||
builds: | ||
- skip: true | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
|
||
milestones: | ||
- repo: | ||
owner: lukasmalkmus | ||
name: icloud-go | ||
close: true | ||
fail_on_error: false | ||
|
||
release: | ||
github: | ||
owner: lukasmalkmus | ||
name: icloud-go | ||
prerelease: auto | ||
name_template: "iCloud Go v{{.Version}}" |
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,19 @@ | ||
Copyright (c) 2021, Lukas Malkmus | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,125 @@ | ||
# TOOLCHAIN | ||
GO := CGO_ENABLED=0 GOBIN=$(CURDIR)/bin go | ||
GOFMT := $(GO)fmt | ||
|
||
# ENVIRONMENT | ||
VERBOSE = | ||
|
||
# GO TOOLS | ||
GOLANGCI_LINT := bin/golangci-lint | ||
GOTESTSUM := bin/gotestsum | ||
STRINGER := bin/stringer | ||
|
||
# MISC | ||
COVERPROFILE := coverage.out | ||
|
||
# FLAGS | ||
GO_TEST_FLAGS := -race -coverprofile=$(COVERPROFILE) | ||
|
||
# DEPENDENCIES | ||
GOMODDEPS = go.mod go.sum | ||
|
||
# Enable verbose test output if explicitly set. | ||
GOTESTSUM_FLAGS = | ||
ifdef VERBOSE | ||
GOTESTSUM_FLAGS += --format=standard-verbose | ||
endif | ||
|
||
# FUNCTIONS | ||
# func go-list-pkg-sources(package) | ||
go-list-pkg-sources = $(GO) list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $(1) | ||
# func go-pkg-sourcefiles(package) | ||
go-pkg-sourcefiles = $(shell $(call go-list-pkg-sources,$(strip $1))) | ||
|
||
.PHONY: all | ||
all: dep generate fmt lint test ## Run dep, generate, fmt, lint and test | ||
|
||
.PHONY: clean | ||
clean: ## Remove build and test artifacts | ||
@echo ">> cleaning up artifacts" | ||
@rm -rf $(COVERPROFILE) | ||
|
||
.PHONY: cover | ||
cover: $(COVERPROFILE) ## Calculate the code coverage score | ||
@echo ">> calculating code coverage" | ||
@$(GO) tool cover -func=$(COVERPROFILE) | tail -n1 | ||
|
||
.PHONY: dep-clean | ||
dep-clean: ## Remove obsolete dependencies | ||
@echo ">> cleaning dependencies" | ||
@$(GO) mod tidy | ||
|
||
.PHONY: dep-upgrade | ||
dep-upgrade: ## Upgrade all direct dependencies to their latest version | ||
@echo ">> upgrading dependencies" | ||
@$(GO) get -d $(shell $(GO) list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all) | ||
@make dep | ||
|
||
.PHONY: dep | ||
dep: dep-clean dep.stamp ## Install and verify dependencies and remove obsolete ones | ||
|
||
dep.stamp: $(GOMODDEPS) | ||
@echo ">> installing dependencies" | ||
@$(GO) mod download | ||
@$(GO) mod verify | ||
@touch $@ | ||
|
||
.PHONY: fmt | ||
fmt: ## Format and simplify the source code using `gofmt` | ||
@echo ">> formatting code" | ||
@! $(GOFMT) -s -w $(shell find . -path -prune -o -name '*.go' -print) | grep '^' | ||
|
||
.PHONY: generate | ||
generate: $(STRINGER) \ | ||
icloud/database_string.go \ | ||
icloud/environment_string.go \ | ||
icloud/error_string.go \ | ||
icloud/records_string.go ## Generate code using `go generate` | ||
|
||
.PHONY: lint | ||
lint: $(GOLANGCI_LINT) ## Lint the source code | ||
@echo ">> linting code" | ||
@$(GOLANGCI_LINT) run | ||
|
||
.PHONY: test-integration | ||
test-integration: $(GOTESTSUM) ## Run all unit and integration tests. Run with VERBOSE=1 to get verbose test output ('-v' flag). Requires some environment variables to be set. | ||
@echo ">> running integration tests" | ||
@$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(GO_TEST_FLAGS) -tags=integration ./... | ||
|
||
.PHONY: test | ||
test: $(GOTESTSUM) ## Run all unit tests. Run with VERBOSE=1 to get verbose test output ('-v' flag). | ||
@echo ">> running tests" | ||
@$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(GO_TEST_FLAGS) ./... | ||
|
||
.PHONY: tools | ||
tools: $(GOLANGCI_LINT) $(GOTESTSUM) $(STRINGER) ## Install all tools into the projects local $GOBIN directory | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
# GO GENERATE TARGETS | ||
|
||
icloud/%_string.go: icloud/%.go | ||
@echo ">> generating $@ from $<" | ||
@$(GO) generate $< | ||
|
||
# MISC TARGETS | ||
|
||
$(COVERPROFILE): | ||
@echo "Please run 'make test' or 'make test-integration' to generate a coverage result" | ||
@exit 1 | ||
|
||
# GO TOOLS | ||
|
||
$(GOLANGCI_LINT): dep.stamp $(call go-pkg-sourcefiles, github.com/golangci/golangci-lint/cmd/golangci-lint) | ||
@echo ">> installing golangci-lint" | ||
@$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(GOTESTSUM): dep.stamp $(call go-pkg-sourcefiles, gotest.tools/gotestsum) | ||
@echo ">> installing gotestsum" | ||
@$(GO) install gotest.tools/gotestsum | ||
|
||
$(STRINGER): dep.stamp $(call go-pkg-sourcefiles, golang.org/x/tools/cmd/stringer) | ||
@echo ">> installing stringer" | ||
@$(GO) install golang.org/x/tools/cmd/stringer |
Oops, something went wrong.