Skip to content

Commit

Permalink
add missing changes from dagger#2414
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Lilljedahl <[email protected]>
  • Loading branch information
marcosnils committed Jul 6, 2022
1 parent dc7ee4d commit 4badecb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 43 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ help: # Show how to get started & what targets are available
GIT_REVISION := $(shell git rev-parse --short HEAD)
.PHONY: dagger
dagger: # Build a dev dagger binary
CGO_ENABLED=0 go build -o ./cmd/dagger/ -ldflags '-s -w -X go.dagger.io/dagger/version.Revision=$(GIT_REVISION)' ./cmd/dagger/
CGO_ENABLED=0 go build -o ./cmd/dagger/ -ldflags '-s -w' ./cmd/dagger/

.PHONY: dagger-debug
dagger-debug: # Build a debug version of the dev dagger binary
go build -race -o ./cmd/dagger/dagger-debug -ldflags '-X go.dagger.io/dagger/version.Revision=$(GIT_REVISION)' ./cmd/dagger/
go build -race -o ./cmd/dagger/dagger-debug ./cmd/dagger/

.PHONY: install
install: # Install a dev dagger binary
go install -ldflags '-X go.dagger.io/dagger/version.Revision=$(GIT_REVISION)' ./cmd/dagger
go install ./cmd/dagger

.PHONY: test
test: dagger # Run all tests
Expand Down
29 changes: 1 addition & 28 deletions ci.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"dagger.io/dagger"
"dagger.io/dagger/core"

"universe.dagger.io/bash"
"universe.dagger.io/alpine"
"universe.dagger.io/go"

"github.com/dagger/dagger/ci/golangci"
Expand Down Expand Up @@ -43,39 +41,14 @@ dagger.#Plan & {
actions: {
_source: client.filesystem["."].read.contents

// FIXME: this can be removed once `go` supports built-in VCS info
version: {
_image: alpine.#Build & {
packages: bash: _
packages: curl: _
packages: git: _
}

_revision: bash.#Run & {
input: _image.output
workdir: "/src"
mounts: source: {
dest: "/src"
contents: _source
}

script: contents: #"""
printf "$(git rev-parse --short HEAD)" > /revision
"""#
export: files: "/revision": string
}

output: _revision.export.files["/revision"]
}

build: {
"go": go.#Build & {
source: _source
package: "./cmd/dagger/"
os: *client.platform.os | "linux"
arch: client.platform.arch

ldflags: "-s -w -X go.dagger.io/dagger/version.Revision=\(version.output)"
ldflags: "-s -w"

env: {
CGO_ENABLED: "0"
Expand Down
2 changes: 1 addition & 1 deletion docs/1001-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ From the **assets** section, download the archive corresponding to your OS and A

## Option 4: Install from source

You will need [Go](https://golang.org) version 1.16 or later.
You will need [Go](https://golang.org) version 1.18 or later.

1\. Clone the dagger repository

Expand Down
4 changes: 2 additions & 2 deletions docs/use-cases/1012-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ source: dagger.#Artifact
// coming from a registry.
test: os.#Container & {
image: docker.#Pull & {
from: "golang:1.16-alpine"
from: "golang:1.18-alpine"
}
mount: "/app": from: source
command: "go test -v ./..."
Expand Down Expand Up @@ -162,7 +162,7 @@ backend: {
test: os.#Container & {
image: docker.#Pull & {
from: "golang:1.16-alpine"
from: "golang:1.18-alpine"
}
mount: "/app": from: code
command: "go test -v ./..."
Expand Down
2 changes: 1 addition & 1 deletion telemetry/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func New(props Properties) *Event {

Engine: engineProperties{
Version: version.Version,
Revision: version.Revision,
Revision: version.Revision(),

OS: runtime.GOOS,
Arch: runtime.GOARCH,
Expand Down
27 changes: 19 additions & 8 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@ package version
import (
"fmt"
"runtime"
"runtime/debug"
)

const (
DevelopmentVersion = "devel"
)

var (
// Version holds the complete version number. Filled in at linking time.
Version = DevelopmentVersion
// Version holds the complete version number. Filled in at linking time.
var Version = DevelopmentVersion

// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.
Revision = ""
)
// Revision returns the VCS revision being used to build or empty string
// if none.
func Revision() string {
bi, ok := debug.ReadBuildInfo()
if !ok {
return ""
}
for _, s := range bi.Settings {
if s.Key == "vcs.revision" {
return s.Value
}
}

return ""
}

func Short() string {
return fmt.Sprintf("dagger %s (%s)", Version, Revision)
return fmt.Sprintf("dagger %s (%s)", Version, Revision())
}

func Long() string {
Expand Down

0 comments on commit 4badecb

Please sign in to comment.