Skip to content

Commit

Permalink
Automate getting the list of examples to build (and switch to go 1.13…
Browse files Browse the repository at this point in the history
… to avoid module problems) (#246)

* automate building all the examples

the EXAMPLES variable was out of date - the stackdriver example wasn't
even built

let's automate it, so we don't need to remember about updating the
variable after adding a new example to the examples directory

* move jaeger example to example directory

this should be in the examples directory, so it can be built by the
make test during CI.

* switch to go 1.13

circle ci uses go 1.12 (which is the oldest 1.12 release) that
contains some bugs with module handling

let's switch to go 1.13.3, the latest go currently

* use a single valid revision of the project in go.mod files

this probably shouldn't be a problem since the switch to go 1.13 in
circle ci, but cleans up the mess and the use of bogus releases
  • Loading branch information
krnowak authored and rghetia committed Oct 29, 2019
1 parent 8013f47 commit 7d30122
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.12 #
- image: circleci/golang:1.13.3

environment:
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ coverage.*
/example/basic/basic
/example/http/client/client
/example/http/server/server
/example/http-stackdriver/client/client
/example/http-stackdriver/server/server
/example/jaeger/jaeger
/example/namedtracer/namedtracer
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ ALL_PKGS := $(shell GO111MODULE=on go list ./...)

export GO111MODULE=on

EXAMPLES := \
./example/basic \
./example/http/client \
./example/http/server
EXAMPLES := $(shell ./get_main_pkgs.sh ./example)

# All source code and documents. Used in spell check.
ALL_DOCS := $(shell find . -name '*.md' -type f | sort)
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Example uses

#### Prequisites

- go 1.12 installed
- go 1.13 installed
- GOPATH is configured.

#### 1 Download git repo
Expand Down
4 changes: 2 additions & 2 deletions example/basic/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/open-telemetry/opentelemetry-go/example/basic

go 1.12
go 1.13

replace go.opentelemetry.io => ../..

require go.opentelemetry.io v0.0.0-00010101000000-000000000000
require go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
4 changes: 2 additions & 2 deletions example/http-stackdriver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ replace (
)

require (
go.opentelemetry.io v0.0.0
go.opentelemetry.io/exporter/trace/stackdriver v0.0.0-00010101000000-000000000000
go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
go.opentelemetry.io/exporter/trace/stackdriver v0.0.0-20191025183852-68310ab97435
google.golang.org/grpc v1.24.0
)
4 changes: 2 additions & 2 deletions example/http/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/open-telemetry/opentelemetry-go/example/http

go 1.12
go 1.13

replace go.opentelemetry.io => ../..

require (
go.opentelemetry.io v0.0.0-00010101000000-000000000000
go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
google.golang.org/grpc v1.24.0
)
13 changes: 13 additions & 0 deletions example/jaeger/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module go.opentelemetry.io/example/jaeger

go 1.13

replace (
go.opentelemetry.io => ../..
go.opentelemetry.io/exporter/trace/jaeger => ../../exporter/trace/jaeger
)

require (
go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
go.opentelemetry.io/exporter/trace/jaeger v0.0.0-20191025183852-68310ab97435
)
326 changes: 326 additions & 0 deletions example/jaeger/go.sum

Large diffs are not rendered by default.

File renamed without changes.
4 changes: 2 additions & 2 deletions example/namedtracer/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module go.opentelemetry.io/example/namedtracer

go 1.12
go 1.13

replace go.opentelemetry.io => ../..

require go.opentelemetry.io v0.0.0-00010101000000-000000000000
require go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
4 changes: 2 additions & 2 deletions exporter/trace/stackdriver/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module go.opentelemetry.io/exporter/trace/stackdriver

go 1.12
go 1.13

replace go.opentelemetry.io => ../../..

require (
cloud.google.com/go v0.47.0
github.com/golang/protobuf v1.3.2
go.opentelemetry.io v0.0.0-20191021171549-9b5f5dd13acd
go.opentelemetry.io v0.0.0-20191025183852-68310ab97435
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
google.golang.org/api v0.11.0
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03
Expand Down
22 changes: 22 additions & 0 deletions get_main_pkgs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euo pipefail

top_dir='.'
if [[ $# -gt 0 ]]; then
top_dir="${1}"
fi

p=$(pwd)
mod_dirs=()
mapfile -t mod_dirs < <(find "${top_dir}" -type f -name 'go.mod' -exec dirname {} \; | sort)

for mod_dir in "${mod_dirs[@]}"; do
cd "${mod_dir}"
main_dirs=()
mapfile -t main_dirs < <(go list --find -f '{{.Name}}|{{.Dir}}' ./... | grep '^main|' | cut -f 2- -d '|')
for main_dir in "${main_dirs[@]}"; do
echo ".${main_dir#${p}}"
done
cd "${p}"
done

0 comments on commit 7d30122

Please sign in to comment.