<commit_before>// Package buildcfg is a Travis-CI compatible configuration reader
// It reads a configuration from .ci.yml or .travis.yml, it also
// selects a suitable docker image
package buildcfg

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"

	"github.com/Sirupsen/logrus"
	"gopkg.in/yaml.v2"
)

const filename = ".ci.yml"
const travisconfig = ".travis.yml"

// Config is the travis-compatible structure
type Config struct {
	DockerImage  string `yaml:"docker_image"`
	Language     string
	GoImportPath string `yaml:"go_import_path"`
	Addons       struct {
		Apt struct {
			Packages []string `yaml:",flow"`
		}
		Artifacts struct {
			Paths []string `yaml:",flow"`
		}
	}
	Setup         multiString
	BeforeInstall multiString `yaml:"before_install"`
	Install       multiString
	Script        multiString
}

// GetScript returns the build script for building the project
func (c *Config) GetScript(f *os.File) {
	f.WriteString(`#!/bin/sh
cd /build
umask 0000
apt-get -yq update
echo "$(date) Build started"
set -xe

`)

	f.WriteString("apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ")
	f.WriteString(strings.Join(c.Addons.Apt.Packages, " "))
	f.WriteString("\n")

	for _, s := range c.Setup.V {
		f.WriteString(s + "\n")
	}
	for _, s := range c.BeforeInstall.V {
		f.WriteString(s + "\n")
	}
	for _, s := range c.Install.V {
		f.WriteString(s + "\n")
	}
	for _, s := range c.Script.V {
		f.WriteString(s + "\n")
	}
	f.WriteString("\nset +x\necho \"$(date) Build ended\"\n")
	f.Close()
}

func loadLangConfig(language, remote string, c *Config) {
	switch language {
	case "go":
		loadGoConfig(remote, c)
	case "c":
		loadCConfig(remote, c)
	default:
		logrus.Errorf("Unsupported language: %s", language)
	}
}

// Read build configuration, it need the root-directory for a repository
// and remote URL, some languages use this.
func Read(cfgDir, remote string) Config {
	c := Config{
		DockerImage: "debian",<commit_msg>Remove everyting with goveralls from the build-script<commit_after>// Package buildcfg is a Travis-CI compatible configuration reader
// It reads a configuration from .ci.yml or .travis.yml, it also
// selects a suitable docker image
package buildcfg

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"

	"github.com/Sirupsen/logrus"
	"gopkg.in/yaml.v2"
)

const filename = ".ci.yml"
const travisconfig = ".travis.yml"

// Config is the travis-compatible structure
type Config struct {
	DockerImage  string `yaml:"docker_image"`
	Language     string
	GoImportPath string `yaml:"go_import_path"`
	Addons       struct {
		Apt struct {
			Packages []string `yaml:",flow"`
		}
		Artifacts struct {
			Paths []string `yaml:",flow"`
		}
	}
	Setup         multiString
	BeforeInstall multiString `yaml:"before_install"`
	Install       multiString
	Script        multiString
}

func isValidCommand(cmd string) bool {
	return !strings.Contains(cmd, "goveralls")
}

// GetScript returns the build script for building the project
func (c *Config) GetScript(f *os.File) {
	f.WriteString(`#!/bin/sh
cd /build
umask 0000
apt-get -yq update
echo "$(date) Build started"
set -xe

`)

	f.WriteString("apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ")
	f.WriteString(strings.Join(c.Addons.Apt.Packages, " "))
	f.WriteString("\n")

	for _, s := range c.Setup.V {
		if isValidCommand(s) {
			f.WriteString(s + "\n")
		}
	}
	for _, s := range c.BeforeInstall.V {
		if isValidCommand(s) {
			f.WriteString(s + "\n")
		}
	}
	for _, s := range c.Install.V {
		if isValidCommand(s) {
			f.WriteString(s + "\n")
		}
	}
	for _, s := range c.Script.V {
		if isValidCommand(s) {
			f.WriteString(s + "\n")
		}
	}
	f.WriteString("\nset +x\necho \"$(date) Build ended\"\n")
	f.Close()
}

func loadLangConfig(language, remote string, c *Config) {
	switch language {
	case "go":
		loadGoConfig(remote, c)
	case "c":
		loadCConfig(remote, c)
	default:
		logrus.Errorf("Unsupported language: %s", language)
	}
}

// Read build configuration, it need the root-directory for a repository
// and remote URL, some languages use this.
func Read(cfgDir, remote string) Config {
	c := Config{
		DockerImage: "debian",
{'fraction_non_alphanumeric': 0.1401059220028888, 'fraction_numerical': 0.002407318247472316, 'mean_word_length': 3.526143790849673, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583071', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1461, 'n_words': 398}