FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ci: update CI scaffolding by sbinet · Pull Request #148 · go-python/gpython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (1) .yml  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ jobs:
run: |
GOARCH=386 go test $TAGS ./...
GOARCH=amd64 go run ./ci/run-tests.go $TAGS -race $COVERAGE
python3 py3test.py
## FIXME(sbinet): bring back python3.4 or upgrade gpython to python3.x
## python3 py3test.py
- name: Test Windows
if: matrix.platform == 'windows-latest'
run: |
Expand Down
76 changes: 52 additions & 24 deletions ci/run-tests.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2018 The go-python Authors. All rights reserved.
// 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.

//go:build ignore
// +build ignore

package main
Expand All @@ -10,32 +11,33 @@ import (
"bufio"
"bytes"
"flag"
"io/ioutil"
"fmt"
"log"
"os"
"os/exec"
"strings"
"time"
)

func main() {
log.SetPrefix("ci: ")
log.SetFlags(0)

start := time.Now()
defer func() {
log.Printf("elapsed time: %v\n", time.Since(start))
}()

var (
race = flag.Bool("race", false, "enable race detector")
cover = flag.Bool("cover", false, "enable code coverage")
tags = flag.String("tags", "", "build tags")
race = flag.Bool("race", false, "enable race detector")
cover = flag.String("coverpkg", "", "apply coverage analysis in each test to packages matching the patterns.")
tags = flag.String("tags", "", "build tags")
verbose = flag.Bool("v", false, "enable verbose output")
)

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()
pkgs, err := pkgList()
if err != nil {
log.Fatal(err)
}
Expand All @@ -48,23 +50,24 @@ func main() {

args := []string{"test"}

if *cover {
args = append(args, "-coverprofile=profile.out", "-covermode=atomic")
if *verbose {
args = append(args, "-v")
}
if *cover != "" {
args = append(args, "-coverprofile=profile.out", "-covermode=atomic", "-coverpkg="+*cover)
}
if *tags != "" {
args = append(args, "-tags="+*tags)
}
if *race {
args = append(args, "-race")
switch {
case *race:
args = append(args, "-race", "-timeout=20m")
default:
args = append(args, "-timeout=10m")
}
args = append(args, "")

scan := bufio.NewScanner(out)
for scan.Scan() {
pkg := scan.Text()
if strings.Contains(pkg, "vendor") {
continue
}
for _, pkg := range pkgs {
args[len(args)-1] = pkg
cmd := exec.Command("go", args...)
cmd.Stdin = os.Stdin
Expand All @@ -74,8 +77,8 @@ func main() {
if err != nil {
log.Fatal(err)
}
if *cover {
profile, err := ioutil.ReadFile("profile.out")
if *cover != "" {
profile, err := os.ReadFile("profile.out")
if err != nil {
log.Fatal(err)
}
Expand All @@ -92,3 +95,28 @@ func main() {
log.Fatal(err)
}
}

func pkgList() ([]string, error) {
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 {
return nil, fmt.Errorf("could not get package list: %w", err)
}

var pkgs []string
scan := bufio.NewScanner(out)
for scan.Scan() {
pkg := scan.Text()
if strings.Contains(pkg, "vendor") {
continue
}
pkgs = append(pkgs, pkg)
}

return pkgs, nil
}

Back | FazBrowse Home | New Git URL