diff --git a/.travis.yml b/.travis.yml index 2066b733..53e9394c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: services: - docker script: - - go build -o clickhouse-backup/clickhouse-backup + - go build -ldflags "-X main.version=${TRAVIS_TAG} -X main.gitCommit=${TRAVIS_COMMIT} -X main.buildDate=$(date --iso-8601)" -o clickhouse-backup/clickhouse-backup - ./clickhouse-backup/clickhouse-backup default-config > clickhouse-backup/config.yml - docker-compose -f integration-test/docker-compose-travis.yml up -d --force-recreate - go test -tags integration @@ -19,6 +19,5 @@ deploy: file: clickhouse-backup.tar.gz skip_cleanup: true overwrite: true - on: tags: true diff --git a/integration_test.sh b/integration_test.sh index 1ec0a921..d5387d40 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -4,4 +4,4 @@ set -e docker-compose -f integration-test/docker-compose.yml up -d --force-recreate go test -tags integration -# docker-compose -f integration-test/docker-compose.yml down \ No newline at end of file +# docker-compose -f integration-test/docker-compose.yml down diff --git a/main.go b/main.go index 148a5e26..bf9f206f 100644 --- a/main.go +++ b/main.go @@ -13,13 +13,19 @@ import ( "github.com/urfave/cli" ) -var config *Config +var ( + config *Config + version = "unknown" + gitCommit = "unknown" + buildDate = "unknown" +) func main() { cliapp := cli.NewApp() cliapp.Name = "clickhouse-backup" cliapp.Usage = "Backup ClickHouse to s3" - cliapp.Version = "0.0.2" + cliapp.Version = version + cliapp.Flags = []cli.Flag{ cli.StringFlag{ Name: "config, c", @@ -37,7 +43,9 @@ func main() { } cli.VersionPrinter = func(c *cli.Context) { - fmt.Println(c.App.Version) + fmt.Println("Version:\t", c.App.Version) + fmt.Println("Git Commit:\t", gitCommit) + fmt.Println("Build Date:\t", buildDate) } cliapp.Before = func(c *cli.Context) error { @@ -236,7 +244,8 @@ func createTables(config Config, args []string, dryRun bool) error { databaseName := file.Name() if databaseName == "system" { // do not touch system database - continue } + continue + } log.Printf("Found metadata files for database: %s", databaseName) ch.CreateDatabase(databaseName) databaseDir := path.Join(metadataPath, databaseName) @@ -325,8 +334,7 @@ func freeze(config Config, args []string, dryRun bool) error { return nil } for _, table := range backupTables { - err := ch.FreezeTable(table) - if err != nil { + if err := ch.FreezeTable(table); err != nil { return err } }