From 0aaa0a8dc920f164d39b45b643842ceb71cb3a5b Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 22 Aug 2018 08:57:24 +0200 Subject: [PATCH 1/5] ci: use latest patch version of Go releases --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4faa6286..8cc512a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,13 @@ dist: trusty os: - linux go: -- 1.8.7 -- 1.9.3 -- "1.10.1" -- tip +- 1.8.x +- 1.9.x +- 1.10.x +- master script: - go test ./... - GOARCH=386 go test ./... matrix: allow_failures: - - go: tip + - go: master From 12248b4a59676f4bc1e0361e79777d817c111f87 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 22 Aug 2018 08:59:25 +0200 Subject: [PATCH 2/5] gpython: add initial support for Go modules --- go.mod | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 go.mod 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 +) From 054112c052f8a8a2f7d7df37e85c8ed68db3e60c Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 22 Aug 2018 09:11:09 +0200 Subject: [PATCH 3/5] gpython: add license badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a5afab3f..b4f8dda8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/go-python/gpython.svg?branch=master)](https://travis-ci.org/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". From 0ec30d8912f31acbb9a19bdafe6136b5a8965287 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 22 Aug 2018 09:15:32 +0200 Subject: [PATCH 4/5] ci: add appveyor build (windows) --- appveyor.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 appveyor.yml 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 ./... From 89b4e4073c816aa2f890beeb469c365a1ca90a79 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 22 Aug 2018 09:07:56 +0200 Subject: [PATCH 5/5] gpython: add code coverage support --- .travis.yml | 42 ++++++++++++++++------ README.md | 1 + ci/run-tests.go | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 ci/run-tests.go diff --git a/.travis.yml b/.travis.yml index 8cc512a7..79e54b44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,36 @@ language: go sudo: false dist: trusty + os: -- linux -go: -- 1.8.x -- 1.9.x -- 1.10.x -- master -script: -- go test ./... -- GOARCH=386 go test ./... + - linux + +env: + - TAGS="-tags travis" + matrix: - allow_failures: - - go: master + 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 b4f8dda8..1ec5b918 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 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) 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) + } +}