Skip to content

Commit

Permalink
build: make uploading build outputs the default
Browse files Browse the repository at this point in the history
Build outputs are now uploaded by default as part of the build.
The "build" command has a new flag --skip-upload to only build and not upload.
  • Loading branch information
fho committed Nov 14, 2018
1 parent 01fa5c5 commit 24788af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Some commands to start with are:
- Build all applications with outstanding builds, upload their artifacts and
records the results:
```
baur build --upload
baur build
```
- List recorded builds:
```
Expand All @@ -91,7 +91,7 @@ To get more information about a command pass the `--help` parameter to baur.
The inputs of applications are specified in the `.app.toml` config file for each
application. baur calculates a SHA384 digest for all inputs and stores the
digest in the database when an application was build and its artifacts uploaded
(`baur build --upload`).
(`baur build`).
The digest is used to detect if a previous build for the same input files exists.
If a build exist, the application does not need to be rebuild otherwise a build
is done.
Expand Down
25 changes: 13 additions & 12 deletions command/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ Environment Variables:
highlight("DOCKER_TLS_VERIFY"))

const buildExampleHelp = `
build payment-service build the application with the name payment-service
build ---force rebuild all applications in the repository
build --verbose ui/shop build the application in the directory ui/shop with verbose output
build --upload ui/shop build the application in the directory ui/shop and upload it's outputs`
build payment-service build and upload the application with the name payment-service
build --verbose --force rebuild and upload all applications, enable verbose output
build --skip-upload shop-ui build the application with the name shop-ui, skip uploading it's build ouputs
build ui/shop build and upload the application in the directory ui/shop
`

var buildCmd = &cobra.Command{
Use: "build [<PATH>|<APP-NAME>]...",
Expand All @@ -83,8 +84,8 @@ var buildCmd = &cobra.Command{
}

var (
buildUpload bool
buildForce bool
buildSkipUpload bool
buildForce bool

result = map[string]*storage.Build{}
resultLock = sync.Mutex{}
Expand All @@ -105,8 +106,8 @@ type buildUserData struct {
}

func init() {
buildCmd.Flags().BoolVar(&buildUpload, "upload", false,
"upload build outputs after the application(s) was build")
buildCmd.Flags().BoolVarP(&buildSkipUpload, "skip-upload", "s", false,
"skip uploading build outputs and recording the build")
buildCmd.Flags().BoolVarP(&buildForce, "force", "f", false,
"force rebuilding of all applications")
rootCmd.AddCommand(buildCmd)
Expand Down Expand Up @@ -401,7 +402,7 @@ func buildRun(cmd *cobra.Command, args []string) {

apps = mustArgToApps(repo, args)

if buildUpload || !buildForce {
if !buildSkipUpload || !buildForce {
store = MustGetPostgresClt(repo)
}

Expand All @@ -427,7 +428,7 @@ func buildRun(cmd *cobra.Command, args []string) {
builder := seq.New(buildJobs, buildChan)
outputCnt := outputCount(apps)

if buildUpload {
if !buildSkipUpload {
uploadChan := make(chan *scheduler.Result, outputCnt)
uploader = startBGUploader(outputCnt, uploadChan)
uploadWatchFin = make(chan struct{}, 1)
Expand Down Expand Up @@ -467,7 +468,7 @@ func buildRun(cmd *cobra.Command, args []string) {
app, ar)
}

if buildUpload {
if !buildSkipUpload {
uj, err := ar.UploadJob()
if err != nil {
log.Fatalf("%s: could not get upload job for build output %s: %s",
Expand All @@ -493,7 +494,7 @@ func buildRun(cmd *cobra.Command, args []string) {

}

if buildUpload && outputCnt > 0 {
if !buildSkipUpload && outputCnt > 0 {
fmt.Println("waiting for uploads to finish...")
<-uploadWatchFin
}
Expand Down

0 comments on commit 24788af

Please sign in to comment.