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

Refactor package structure #86

Merged
merged 16 commits into from
Apr 5, 2020
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
83 changes: 40 additions & 43 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,42 @@ steps:
image: minio/mc:RELEASE.2018-09-26T00-42-43Z
commands:
- sleep 5
- mc config host add minio http://filestorage:9000 AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- mc config host add minio http://minio:9000 AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- mc mb --region=eu-west-1 minio/drone-cache-bucket

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
commands:
- apk add --update make git
- make drone-cache
environment:
CGO_ENABLED: 0

- name: test
image: golang:1.13-alpine
- name: lint
image: golang:1.14.1-alpine3.11
commands:
- go test -v -mod=vendor -cover ./...
- apk add --update make git curl
- make lint
environment:
CGO_ENABLED: 0
TEST_ENDPOINT: filestorage:9000
TEST_SFTP_HOST: sftp
TEST_AZURITE_URL: azurite:10000
volumes:
- name: testcache
path: /drone/src/testcache/cache

- name: lint
image: golang:1.13-alpine
- name: test
image: golang:1.14.1-alpine3.11
commands:
- "wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.21.0"
- ./bin/golangci-lint run -v --enable-all -D gochecknoglobals
- go test -mod=vendor -short -cover -failfast -tags=integration ./...
environment:
CGO_ENABLED: 0
TEST_S3_ENDPOINT: minio:9000
TEST_GCS_ENDPOINT: http://fakegcs:4443/storage/v1/
TEST_STORAGE_EMULATOR_HOST: fakegcs:4443
TEST_SFTP_HOST: sftp
TEST_AZURITE_URL: azurite:10000
volumes:
- name: testdata
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
path: /drone/src/tmp/testdata/cache

- name: release-snapshot-dev
image: goreleaser/goreleaser:v0.120
image: goreleaser/goreleaser:v0.131.1
commands:
- apk add --update make upx
- goreleaser release --rm-dist --snapshot
Expand Down Expand Up @@ -90,7 +94,7 @@ steps:
rebuild: true
region: eu-west-1
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Expand All @@ -107,7 +111,7 @@ steps:
rebuild: true
region: eu-west-1
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Expand All @@ -125,7 +129,7 @@ steps:
rebuild: true
region: eu-west-1
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Expand All @@ -147,7 +151,7 @@ steps:
path: /tmp/cache

- name: release-snapshot
image: goreleaser/goreleaser:v0.120
image: goreleaser/goreleaser:v0.131.1
commands:
- apk add --update make upx
- goreleaser release --rm-dist --snapshot
Expand Down Expand Up @@ -199,7 +203,7 @@ steps:
pull: always
restore: true
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Expand All @@ -217,7 +221,7 @@ steps:
region: eu-west-1
restore: true
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Expand Down Expand Up @@ -256,34 +260,21 @@ steps:
region: eu-west-1
restore: true
path_style: true
endpoint: filestorage:9000
endpoint: minio:9000
exit_code: true
environment:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

- name: build-after
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
commands:
- apk add --update make git
- make drone-cache

- name: test-after
image: golang:1.13-alpine
commands:
- go test -v -mod=vendor -cover ./...
environment:
CGO_ENABLED: 0
TEST_ENDPOINT: filestorage:9000
TEST_SFTP_HOST: sftp
TEST_AZURITE_URL: azurite:10000
volumes:
- name: testcache
path: /drone/src/testcache/cache

services:
- name: filestorage
image: minio/minio:RELEASE.2018-10-06T00-15-16Z
- name: minio
image: minio/minio:RELEASE.2020-03-05T01-04-19Z
commands:
- minio server /data
environment:
Expand All @@ -292,12 +283,18 @@ services:
MINIO_SECRET_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
ports:
- 9000
- name: fakegcs
image: fsouza/fake-gcs-server
ports:
- 4443
commands:
- fake-gcs-server -public-host fakegcs -scheme http
- name: sftp
image: atmoz/sftp
image: atmoz/sftp:alpine
ports:
- 22
commands:
- /entrypoint foo:pass:::upload
- /entrypoint foo:pass:::sftp_test bar:pass:::plugin_test
- name: azurite
image: mcr.microsoft.com/azure-storage/azurite
commands:
Expand All @@ -308,7 +305,7 @@ services:
volumes:
- name: cache
temp: {}
- name: testcache
- name: testdata
temp: {}

trigger:
Expand All @@ -333,7 +330,7 @@ steps:
- git fetch --tags

- name: release
image: goreleaser/goreleaser:v0.120
image: goreleaser/goreleaser:v0.131.1
commands:
- apk add --update make upx
- make release
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ drone-cache
vendor
target
bin
testcache
backup
tmp
TODO.md
testdata

# Azurite temp files
__*__
__*__.json
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ run:
deadline: 1m
tests: false
modules-download-mode: vendor
timeout: 5m

linters:
enable-all: true
Expand All @@ -16,3 +17,7 @@ linters-settings:
exclude: .errcheck_excludes
lll:
line-length: 120
funlen:
lines: 85
statements: 45

2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ before:
- make vendor
dist: target/dist
builds:
# TODO: -tags netgo
- env:
- CGO_ENABLED=0
goos:
Expand Down Expand Up @@ -71,6 +72,7 @@ release:

# NOTICE: To be able to run this stage in drone.io, we need Docker which runs in a container,
# - and Docker needs a privileged container, so it's not possible for free tier right now.
# TODO: Alternative: https://github.com/goreleaser/goreleaser-action
# TODO: Add missing GOOS and ARCH
# dockers:
# -
Expand Down
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ the requirements below.
## Pull Request Process

0. Check out [Pull Request Checklist](#pull-request-checklist), ensure you have fulfilled each step.
1. Check out [Uber Style Guide](https://github.com/uber-go/guide/blob/master/style.md), project tries to follow it, ensure you have fulfilled it as much as possible.
1. Check out guidelines below, the project tries to follow these, ensure you have fulfilled them as much as possible.
* [Effective Go](https://golang.org/doc/effective_go.html)
* [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
2. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
3. Please ensure the [README](README.md) and [DOCS](./DOCS.md) are up-to-date with details of changes to the command-line interface,
this includes new environment variables, exposed ports, useful file locations and container parameters.
this includes new environment variables, exposed ports, used file locations, and container parameters.
4. **PLEASE ENSURE YOU DO NOT INTRODUCE BREAKING CHANGES.**
5. **PLEASE ENSURE BUG FIXES AND NEW FEATURES INCLUDE TESTS.**
6. You may merge the Pull Request in once you have the sign-off of one other maintainer/code owner,
Expand All @@ -46,17 +48,19 @@ the requirements below.
0. **PLEASE DO NOT INTRODUCE BREAKING CHANGES**
1. Execute `make README.md`. This will update [usage](README.md#usage) section of [README.md](README.md) with latest CLI options
2. Increase the version numbers in any examples files and the README.md to the new version that this
release would represent. The versioning scheme we use is [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/meltwater/drone-cache/tags).
the release would represent. The versioning scheme we use is [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/meltwater/drone-cache/tags).

3. Ensure [CHANGELOG](CHANGELOG.md) is up-to-date with new version changes.
4. Update version references.
5. Create a tag on master. Any changes on master will trigger a release with given tag and `latest tag.
5. Create a tag on the master. Any changes on the master will trigger a release with the given tag and `latest tag.

```console
$ git tag -am 'vX.X.X'
> ...
$ git push --tags
> ...
```
6. Check whether all the generate artifacts in-place properly.
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
7. Update [plugin index](https://github.com/drone/drone-plugin-index/blob/master/content/meltwater/drone-cache/index.md) using [DOCS](./DOCS.md).

> **Keep in mind that users usually use the `latest` tagged images in their pipeline, please make sure you do not interfere with their working workflow.**
12 changes: 6 additions & 6 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ steps:
- 'vendor'

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
pull: true
commands:
- apk add --update make git
Expand Down Expand Up @@ -160,7 +160,7 @@ steps:
path: /tmp/cache

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
pull: true
commands:
- apk add --update make git
Expand Down Expand Up @@ -188,7 +188,7 @@ volumes:

**With custom cache key template**

See [cache key templates](/meltwater/drone-cache#using-cache-key-templates) section for further information and to learn about syntax.
See [cache key templates](#using-cache-key-templates) section for further information and to learn about syntax.

```yaml
kind: pipeline
Expand All @@ -212,7 +212,7 @@ steps:
- 'vendor'

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
pull: true
commands:
- apk add --update make git
Expand Down Expand Up @@ -260,7 +260,7 @@ steps:
- 'vendor'

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
pull: true
commands:
- apk add --update make git
Expand Down Expand Up @@ -299,7 +299,7 @@ steps:
debug: true

- name: build
image: golang:1.13-alpine
image: golang:1.14.1-alpine3.11
pull: true
commands:
- apk add --update make git
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13-alpine AS builder
FROM golang:1.14.1-alpine3.11 AS builder
RUN apk add --update --no-cache ca-certificates tzdata && update-ca-certificates

RUN echo "[WARNING] Make sure you have run 'goreleaser release', before 'docker build'!"
Expand Down
Loading