Skip to content

Commit

Permalink
v3.0.1 (#23)
Browse files Browse the repository at this point in the history
* huge refactoring (mostly packages reorganization) + vendor updates + improving CI process + better debug message if no payload flag given
  • Loading branch information
gulien authored Apr 13, 2018
1 parent 5e4c45b commit 28db184
Show file tree
Hide file tree
Showing 282 changed files with 8,821 additions and 4,203 deletions.
23 changes: 23 additions & 0 deletions .ci/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -xe

# Statically checking Go source for errors and warnings.
gometalinter.v2 --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode -E gocyclo --vendor ./...;

# Running tests according to current Orbit version.
if [[ "$VERSION" == "snapshot" ]]; then
go test -race --cover --covermode=atomic ./...;
else
echo "" > .ci/coverage.txt;
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d;
if [ -f profile.out ]; then
cat profile.out >> .ci/coverage.txt;
rm profile.out;
fi
done
fi

# Bye!
exit 0;
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ find below useful information about how to contribute to the Orbit project.

1. Fork this repository
2. Clone it to your local Go environment (requires *Go* >= 1.10)
5. Install the latest Orbit release
6. Install dependencies by running `orbit run install`

### Working with git

Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Fixes #
**Checklist**

- [ ] Have you followed the guidelines in our [CONTRIBUTING](CONTRIBUTING.md) guide?
- [ ] Have you lint your code locally prior to submission (`orbit run fmt lint`)?
- [ ] Have you fmt your code locally prior to submission (`orbit run fmt`)?
- [ ] Have you written new tests for your core changes, as applicable?
- [ ] Have you successfully ran tests with your changes locally (`orbit run test`)?
- [ ] Have you successfully ran tests with your changes locally (`orbit run ci`)?
- [ ] I have squashed any insignificant commits
- [ ] This change has comments for package types, values, functions, and non-obvious lines of code
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.idea
dist
orbit
.ci/coverage.txt
2 changes: 1 addition & 1 deletion goreleaser.yml → .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project_name: Orbit
builds:
- main: ./orbit.go
- main: ./main.go
binary: orbit
env:
- CGO_ENABLED=0
Expand Down
31 changes: 10 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
language: go
sudo: required

go:
- "1.10"
- tip
language: generic

matrix:
allow_failures:
- go: tip
fast_finish: true
services:
- docker

install:
- go version
- go env
- go install
- orbit run install
before_install:
- wget -qO- https://github.com/gulien/orbit/releases/download/v3.0.0/orbit_Linux_x86_64.tar.gz | tar xvz -C .
- sudo mv ./orbit /usr/local/bin && chmod +x /usr/local/bin/orbit

script:
- orbit run lint
- ./codecov.sh

after_success:
- bash <(curl -s https://codecov.io/bash)

notifications:
email: false
- orbit run ci -p "Version,${TRAVIS_BRANCH}"
# Uploads coverage.
- bash <(curl -s https://codecov.io/bash)
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.10-stretch

WORKDIR /go/src/github.com/gulien/orbit

# Installs lint dependencies.
RUN go get -u gopkg.in/alecthomas/gometalinter.v2 &&\
gometalinter.v2 --install

# Installs dep for our tests.
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
ENV SHELL="/bin/sh"

# Copies our Go source.
COPY . .

# Installs project dependencies.
RUN go get -d -v ./...

ENTRYPOINT [".ci/docker-entrypoint.sh"]
44 changes: 22 additions & 22 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<p align="center">A cross-platform task runner for executing commands and generating files from templates</p>
<p align="center">
<a href="https://travis-ci.org/gulien/orbit">
<img src="https://img.shields.io/travis/gulien/orbit.svg?label=linux+build" alt="Travis CI">
<img src="https://travis-ci.org/gulien/orbit.svg?branch=master" alt="Travis CI">
</a>
<a href="https://ci.appveyor.com/project/gulien/orbit">
<img src="https://img.shields.io/appveyor/ci/gulien/orbit.svg?label=windows+build" alt="AppVeyor">
<img src="https://ci.appveyor.com/api/projects/status/fj6q6y75vdugn99i/branch/master?svg=true" alt="AppVeyor">
</a>
<a href="https://godoc.org/github.com/gulien/orbit">
<img src="https://godoc.org/github.com/gulien/orbit?status.svg" alt="GoDoc">
</a>
<a href="https://goreportcard.com/report/gulien/orbit">
<img src="https://goreportcard.com/badge/github.com/gulien/orbit" alt="Go Report Card">
</a>
<a href="https://codecov.io/gh/gulien/orbit">
<a href="https://codecov.io/gh/gulien/orbit/branch/master">
<img src="https://codecov.io/gh/gulien/orbit/branch/master/graph/badge.svg" alt="Codecov">
</a>
</p>
Expand Down
10 changes: 5 additions & 5 deletions context/context.go → app/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The main goal of the application context is to gather all the data which will be
package context

import (
"github.com/gulien/orbit/errors"
"github.com/gulien/orbit/helpers"
"github.com/gulien/orbit/logger"
OrbitError "github.com/gulien/orbit/app/error"
"github.com/gulien/orbit/app/helpers"
"github.com/gulien/orbit/app/logger"
)

// OrbitContext contains the data necessary for executing a data-driven template.
Expand All @@ -24,11 +24,11 @@ type OrbitContext struct {
func NewOrbitContext(templateFilePath string, payload string) (*OrbitContext, error) {
// as the data-driven template is mandatory, we must check its validity.
if templateFilePath == "" {
return nil, errors.NewOrbitErrorf("no data-driven template given")
return nil, OrbitError.NewOrbitErrorf("no data-driven template given")
}

if !helpers.FileExists(templateFilePath) {
return nil, errors.NewOrbitErrorf("the data-driven template %s does not exist", templateFilePath)
return nil, OrbitError.NewOrbitErrorf("the data-driven template %s does not exist", templateFilePath)
}

// let's instantiates our OrbitContext!
Expand Down
6 changes: 3 additions & 3 deletions context/context_test.go → app/context/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestNewOrbitContext(t *testing.T) {
}

// case 3: uses an existing template file path.
templateFilePath, _ := filepath.Abs("../_tests/template.yml")
templateFilePath, _ := filepath.Abs("../../_tests/template.yml")
if _, err := NewOrbitContext(templateFilePath, ""); err != nil {
t.Error("OrbitContext should have been instantiated!")
}
Expand All @@ -35,13 +35,13 @@ func TestNewOrbitContext(t *testing.T) {
}

// case 6: uses a broken payload entry.
brokenPayloadEntryFilePath, _ := filepath.Abs("../_tests/broken-data-source.yml")
brokenPayloadEntryFilePath, _ := filepath.Abs("../../_tests/broken-data-source.yml")
if _, err := NewOrbitContext(templateFilePath, "key,"+brokenPayloadEntryFilePath); err == nil {
t.Error("OrbitContext should not have been instantiated!")
}

// case 7: uses a correct payload entry.
payloadEntryFilePath, _ := filepath.Abs("../_tests/data-source.yml")
payloadEntryFilePath, _ := filepath.Abs("../../_tests/data-source.yml")
if _, err := NewOrbitContext(templateFilePath, "key,"+payloadEntryFilePath); err != nil {
t.Error("OrbitContext should have been instantiated!")
}
Expand Down
14 changes: 7 additions & 7 deletions context/decoder.go → app/context/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"io/ioutil"

"github.com/gulien/orbit/errors"
OrbitError "github.com/gulien/orbit/app/error"

"github.com/BurntSushi/toml"
"github.com/joho/godotenv"
Expand Down Expand Up @@ -61,12 +61,12 @@ func (d *orbitDumbDecoder) decode() (interface{}, error) {
func (d *orbitYAMLDecoder) decode() (interface{}, error) {
data, err := ioutil.ReadFile(d.value)
if err != nil {
return nil, errors.NewOrbitErrorf("unable to read the file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to read the file %s. Details:\n%s", d.value, err)
}

var decoded interface{}
if err := yaml.Unmarshal(data, &decoded); err != nil {
return nil, errors.NewOrbitErrorf("unable to decode the YAML file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to decode the YAML file %s. Details:\n%s", d.value, err)
}

var result interface{}
Expand All @@ -79,7 +79,7 @@ func (d *orbitYAMLDecoder) decode() (interface{}, error) {
func (d *orbitTOMLDecoder) decode() (interface{}, error) {
var decoded interface{}
if _, err := toml.DecodeFile(d.value, &decoded); err != nil {
return nil, errors.NewOrbitErrorf("unable to decode the TOML file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to decode the TOML file %s. Details:\n%s", d.value, err)
}

var result interface{}
Expand All @@ -92,12 +92,12 @@ func (d *orbitTOMLDecoder) decode() (interface{}, error) {
func (d *orbitJSONDecoder) decode() (interface{}, error) {
data, err := ioutil.ReadFile(d.value)
if err != nil {
return nil, errors.NewOrbitErrorf("unable to read the file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to read the file %s. Details:\n%s", d.value, err)
}

var decoded interface{}
if err := json.Unmarshal(data, &decoded); err != nil {
return nil, errors.NewOrbitErrorf("unable to decode the JSON file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to decode the JSON file %s. Details:\n%s", d.value, err)
}

var result interface{}
Expand All @@ -110,7 +110,7 @@ func (d *orbitJSONDecoder) decode() (interface{}, error) {
func (d *orbitEnvFileDecoder) decode() (interface{}, error) {
result, err := godotenv.Read(d.value)
if err != nil {
return nil, errors.NewOrbitErrorf("unable to decode the .env file %s. Details:\n%s", d.value, err)
return nil, OrbitError.NewOrbitErrorf("unable to decode the .env file %s. Details:\n%s", d.value, err)
}

return result, nil
Expand Down
Loading

0 comments on commit 28db184

Please sign in to comment.