diff --git a/.travis.yml b/.travis.yml index 4faa6286..79e54b44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,36 @@ language: go sudo: false dist: trusty + os: -- linux -go: -- 1.8.7 -- 1.9.3 -- "1.10.1" -- tip -script: -- go test ./... -- GOARCH=386 go test ./... + - linux + +env: + - TAGS="-tags travis" + matrix: - allow_failures: - - go: tip + fast_finish: true + allow_failures: + - go: master + include: + - go: 1.8.x + env: + - TAGS="-tags travis" + - go: 1.9.x + env: + - TAGS="-tags travis" + - go: 1.10.x + env: + - TAGS="-tags travis" + - COVERAGE="-cover" + - go: master + env: + - TAGS="-tags travis" + +script: + - go install -v $TAGS ./... + - GOARCH=386 go test $TAGS ./... + - GOARCH=amd64 go run ./ci/run-tests.go -race $TAGS $COVERAGE + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index a5afab3f..1ec5b918 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # gpython [![Build Status](https://travis-ci.org/go-python/gpython.svg?branch=master)](https://travis-ci.org/go-python/gpython) +[![codecov](https://codecov.io/gh/go-python/gpython/branch/master/graph/badge.svg)](https://codecov.io/gh/go-python/gpython) [![GoDoc](https://godoc.org/github.com/go-python/gpython?status.svg)](https://godoc.org/github.com/go-python/gpython) +[![License](https://img.shields.io/badge/License-BSD--3-blue.svg)](https://github.com/go-python/gpython/blob/master/LICENSE) gpython is a part re-implementation / part port of the Python 3.4 interpreter to the Go language, "batteries not included". diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..7e922524 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,19 @@ +build: off + +clone_folder: c:\gopath\src\github.com\go-python\gpython + +branches: + only: + - master + +environment: + GOPATH: c:\gopath + PATH: '%GOPATH%\bin;%PATH%' + +stack: go 1.10 + +build_script: + - go get -v -t -race ./... + +test_script: + - go test -race ./... diff --git a/ci/run-tests.go b/ci/run-tests.go new file mode 100644 index 00000000..031a08ab --- /dev/null +++ b/ci/run-tests.go @@ -0,0 +1,94 @@ +// Copyright 2018 The go-python Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "bufio" + "bytes" + "flag" + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) + +func main() { + log.SetPrefix("ci: ") + log.SetFlags(0) + + var ( + race = flag.Bool("race", false, "enable race detector") + cover = flag.Bool("cover", false, "enable code coverage") + tags = flag.String("tags", "", "build tags") + ) + + flag.Parse() + + out := new(bytes.Buffer) + cmd := exec.Command("go", "list", "./...") + cmd.Stdout = out + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + + err := cmd.Run() + if err != nil { + log.Fatal(err) + } + + f, err := os.Create("coverage.txt") + if err != nil { + log.Fatal(err) + } + defer f.Close() + + args := []string{"test"} + + if *cover { + args = append(args, "-coverprofile=profile.out", "-covermode=atomic") + } + if *tags != "" { + args = append(args, "-tags="+*tags) + } + if *race { + args = append(args, "-race") + } + args = append(args, "") + + scan := bufio.NewScanner(out) + for scan.Scan() { + pkg := scan.Text() + if strings.Contains(pkg, "vendor") { + continue + } + args[len(args)-1] = pkg + cmd := exec.Command("go", args...) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + log.Fatal(err) + } + if *cover { + profile, err := ioutil.ReadFile("profile.out") + if err != nil { + log.Fatal(err) + } + _, err = f.Write(profile) + if err != nil { + log.Fatal(err) + } + os.Remove("profile.out") + } + } + + err = f.Close() + if err != nil { + log.Fatal(err) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..be655164 --- /dev/null +++ b/go.mod @@ -0,0 +1,6 @@ +module github.com/go-python/gpython + +require ( + github.com/mattn/go-runewidth v0.0.3 // indirect + github.com/peterh/liner v0.0.0-20180619022028-8c1271fcf47f +)