Skip to content

Commit

Permalink
Add github actions ci
Browse files Browse the repository at this point in the history
  • Loading branch information
harsimranmaan authored and sbarzowski committed May 19, 2021
1 parent ba5dc76 commit 1b7cbff
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 95 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: ci
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
test:
name: Test go${{ matrix.goVersion}}.x ${{ matrix.goArch }}
strategy:
fail-fast: false
matrix:
include:
- goVersion: "1"
GOARCH: "amd64"
SKIP_PYTHON_BINDINGS_TESTS: "0"
# - goVersion: "1"
# GOARCH: "arm64"
# SKIP_PYTHON_BINDINGS_TESTS: "0"
# - goVersion: "1"
# GOARCH: "386"
# SKIP_PYTHON_BINDINGS_TESTS: "1"
# - goVersion: "1"
# GOARCH: "ppc64le"
# SKIP_PYTHON_BINDINGS_TESTS: "0"
- goVersion: "1.11"
GOARCH: "amd64"
SKIP_PYTHON_BINDINGS_TESTS: "0"
- goVersion: "1.12"
GOARCH: "amd64"
SKIP_PYTHON_BINDINGS_TESTS: "0"
- goVersion: "1.13"
GOARCH: "amd64"
SKIP_PYTHON_BINDINGS_TESTS: "0"
- goVersion: "1.14"
GOARCH: "amd64"
SKIP_PYTHON_BINDINGS_TESTS: "0"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goVersion }}
- run: sudo apt install python3-dev python3-setuptools
- run: pip install -U wheel
- run: pip install -U pytest setuptools
- run: make install.dependencies
- run: make test
env:
GOARCH: ${{ matrix.GOARCH }}
CGO_ENABLED: "1"
SKIP_PYTHON_BINDINGS_TESTS: ${{ matrix.SKIP_PYTHON_BINDINGS_TESTS }}

all:
name: Check all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt install python3-dev python3-setuptools
- run: pip install -U wheel
- run: pip install -U pytest setuptools
# - uses: golangci/golangci-lint-action@v2
# with:
# version: v1.30.0
- run: make all
- name: Install goveralls
env:
GO111MODULE: off
run: |
export GOPATH=$GITHUB_WORKSPACE
go get github.com/mattn/goveralls
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bin/goveralls -coverprofile=coverage.out -service=github

goreleaser:
name: Goreleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: goreleaser/goreleaser-action@v2
with:
args: release --snapshot --skip-publish --rm-dist
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ gojsonnet.egg-info/
/tests_path.source

/jsonnet-lint

/jsonnet-deps
/builtin-benchmark-results
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ builds:
- arm64
ignore:
- goos: darwin
goarch: 386
- goarch: 386

id: jsonnetfmt
main: ./cmd/jsonnetfmt
Expand All @@ -50,7 +50,7 @@ archives:
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"

nfpms:
- id: jsonnet
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ install.dependencies:
git submodule update
go get github.com/clipperhouse/gen
go get github.com/clipperhouse/set
go get github.com/fatih/color
go get github.com/axw/gocov/gocov
go get github.com/mattn/goveralls
go get github.com/sergi/go-diff/diffmatchpatch
if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi;
.PHONY: install.dependencies

build.bazel:
Expand Down
4 changes: 0 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
workspace(name = "google_jsonnet_go")

load(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",
)
load(
"@google_jsonnet_go//bazel:repositories.bzl",
"jsonnet_go_repositories",
Expand Down
64 changes: 33 additions & 31 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load(

def jsonnet_go_dependencies():
go_rules_dependencies()
go_register_toolchains()
go_register_toolchains(version = "host")
gazelle_dependencies()
go_repository(
name = "com_github_davecgh_go_spew",
Expand All @@ -22,20 +22,39 @@ def jsonnet_go_dependencies():
go_repository(
name = "com_github_fatih_color",
importpath = "github.com/fatih/color",
sum = "h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=",
version = "v1.9.0",
sum = "h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=",
version = "v1.10.0",
)

go_repository(
name = "com_github_kr_pretty",
importpath = "github.com/kr/pretty",
sum = "h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=",
version = "v0.1.0",
)
go_repository(
name = "com_github_kr_pty",
importpath = "github.com/kr/pty",
sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=",
version = "v1.1.1",
)
go_repository(
name = "com_github_kr_text",
importpath = "github.com/kr/text",
sum = "h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=",
version = "v0.1.0",
)
go_repository(
name = "com_github_mattn_go_colorable",
importpath = "github.com/mattn/go-colorable",
sum = "h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=",
version = "v0.1.4",
sum = "h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=",
version = "v0.1.8",
)
go_repository(
name = "com_github_mattn_go_isatty",
importpath = "github.com/mattn/go-isatty",
sum = "h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=",
version = "v0.0.11",
sum = "h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=",
version = "v0.0.12",
)
go_repository(
name = "com_github_pmezard_go_difflib",
Expand All @@ -61,30 +80,7 @@ def jsonnet_go_dependencies():
sum = "h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=",
version = "v1.4.0",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=",
version = "v0.0.0-20191026070338-33540a1f6037",
)
go_repository(
name = "com_github_kr_pretty",
importpath = "github.com/kr/pretty",
sum = "h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=",
version = "v0.1.0",
)
go_repository(
name = "com_github_kr_pty",
importpath = "github.com/kr/pty",
sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=",
version = "v1.1.1",
)
go_repository(
name = "com_github_kr_text",
importpath = "github.com/kr/text",
sum = "h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=",
version = "v0.1.0",
)

go_repository(
name = "in_gopkg_check_v1",
importpath = "gopkg.in/check.v1",
Expand All @@ -97,3 +93,9 @@ def jsonnet_go_dependencies():
sum = "h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=",
version = "v2.2.4",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=",
version = "v0.0.0-20200223170610-d5e6a3e2c0ae",
)
37 changes: 14 additions & 23 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,25 @@ load(
"http_archive",
)

def _maybe(repo_rule, name, **kwargs):
"""Executes the given repository rule if it hasn't been executed already.
Args:
repo_rule: The repository rule to be executed (e.g.,
`native.git_repository`.)
name: The name of the repository to be defined by the rule.
**kwargs: Additional arguments passed directly to the repository rule.
"""
if not native.existing_rule(name):
repo_rule(name = name, **kwargs)

def jsonnet_go_repositories():
_maybe(
http_archive,
http_archive(
name = "io_bazel_rules_go",
sha256 = "e6f8cb2da438cc4899809b66ba96d57397ed871640fe5c848ca9c56190b7c8ba",
strip_prefix = "rules_go-8ea79bbd5e6ea09dc611c245d1dc09ef7ab7118a",
urls = ["https://github.com/bazelbuild/rules_go/archive/8ea79bbd5e6ea09dc611c245d1dc09ef7ab7118a.zip"],
sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
],
)
_maybe(
http_archive,

http_archive(
name = "bazel_gazelle",
sha256 = "c5faf839dd1da0065ed7d44ac248b01ab5ffcd0db46e7193439906df68867c39",
strip_prefix = "bazel-gazelle-38bd65ead186af23549480d6189b89c7c53c023e",
urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/38bd65ead186af23549480d6189b89c7c53c023e.zip"],
sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
],
)
_maybe(
http_archive,
http_archive(
name = "cpp_jsonnet",
sha256 = "82d3cd35de8ef230d094b60a30e7659f415c350b0aa2bd62162cf2afdf163959",
strip_prefix = "jsonnet-90cad75dcc2eafdcf059c901169d36539dc8a699",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/google/go-jsonnet
go 1.13

require (
github.com/fatih/color v1.9.0
github.com/fatih/color v1.10.0
github.com/sergi/go-diff v1.1.0
)
19 changes: 9 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
14 changes: 7 additions & 7 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ var standardExtCode = map[string]string{
}

var metadataForTests = map[string]testMetadata{
"testdata/extvar_code": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_error": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_hermetic": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_mutually_recursive": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_self_recursive": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_static_error": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_string": testMetadata{extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_code": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_error": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_hermetic": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_mutually_recursive": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_self_recursive": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_static_error": {extVars: standardExtVars, extCode: standardExtCode},
"testdata/extvar_string": {extVars: standardExtVars, extCode: standardExtCode},
}

type mainTest struct {
Expand Down
2 changes: 1 addition & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ JSONNET_CPP_DIR=${JSONNET_CPP_DIR:=$PWD/cpp-jsonnet}

set -x

[ "$SKIP_GO_TESTS" == 1 ] || go test ./...
go test -covermode atomic -coverprofile=coverage.out ./...

if [ "$SKIP_PYTHON_BINDINGS_TESTS" == 1 ]
then
Expand Down
1 change: 0 additions & 1 deletion travisBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -e

run_tests() {
golangci-lint run ./...
$GOPATH/bin/goveralls -service=travis-ci
SKIP_GO_TESTS=1 ./tests.sh
}

Expand Down

0 comments on commit 1b7cbff

Please sign in to comment.