-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
- Loading branch information
1 parent
faec544
commit c0766b8
Showing
5 changed files
with
137 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
|
||
- name: Verify | ||
run: make ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
GO ?= go | ||
|
||
OTELCOL_BUILDER_VERSION ?= 0.46.0 | ||
OTELCOL_BUILDER_DIR ?= ${HOME}/bin | ||
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb | ||
|
||
DISTRIBUTIONS ?= "sidecar,tracing" | ||
|
||
ci: check build | ||
check: | ||
|
||
build: go ocb | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
generate: generate-sources | ||
|
||
generate-sources: go ocb | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
.PHONY: ocb | ||
ocb: | ||
ifeq (, $(shell command -v ocb 2>/dev/null)) | ||
@{ \ | ||
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \ | ||
set -e ;\ | ||
os=$$(uname | tr A-Z a-z) ;\ | ||
machine=$$(uname -m) ;\ | ||
[ "$${machine}" != x86 ] || machine=386 ;\ | ||
[ "$${machine}" != x86_64 ] || machine=amd64 ;\ | ||
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\ | ||
mkdir -p $(OTELCOL_BUILDER_DIR) ;\ | ||
curl -sLo $(OTELCOL_BUILDER) "https://github.com/open-telemetry/opentelemetry-collector/releases/download/v$(OTELCOL_BUILDER_VERSION)/ocb_$(OTELCOL_BUILDER_VERSION)_$${os}_$${machine}" ;\ | ||
chmod +x $(OTELCOL_BUILDER) ;\ | ||
} | ||
else | ||
OTELCOL_BUILDER=$(shell command -v ocb) | ||
endif | ||
|
||
.PHONY: go | ||
go: | ||
@{ \ | ||
if ! command -v '$(GO)' >/dev/null 2>/dev/null; then \ | ||
echo >&2 '$(GO) command not found. Please install golang. https://go.dev/doc/install'; \ | ||
exit 1; \ | ||
fi \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
REPO_DIR="$( cd "$(dirname $( dirname "${BASH_SOURCE[0]}" ))" &> /dev/null && pwd )" | ||
BUILDER='' | ||
GO='' | ||
|
||
# default values | ||
skipcompilation=false | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distributions=${OPTARG};; | ||
s) skipcompilation=${OPTARG};; | ||
b) BUILDER=${OPTARG};; | ||
g) GO=${OPTARG};; | ||
esac | ||
done | ||
|
||
[[ -n "$BUILDER" ]] || BUILDER='ocb' | ||
[[ -n "$GO" ]] || GO='go' | ||
|
||
if [[ -z $distributions ]]; then | ||
echo "List of distributions to build not provided. Use '-d' to specify the names of the distributions to build. Ex.:" | ||
echo "$0 -d tracing" | ||
exit 1 | ||
fi | ||
|
||
if [[ "$skipcompilation" = true ]]; then | ||
echo "Skipping the compilation, we'll only generate the sources." | ||
fi | ||
|
||
echo "Distributions to build: $distributions"; | ||
|
||
for distribution in $(echo "$distributions" | tr "," "\n") | ||
do | ||
pushd "${REPO_DIR}/distributions/${distribution}" > /dev/null | ||
mkdir -p _build | ||
|
||
echo "Building: $distribution" | ||
echo "Using Builder: $(command -v "$BUILDER")" | ||
echo "Using Go: $(command -v "$GO")" | ||
|
||
if "$BUILDER" --skip-compilation=${skipcompilation} --go "$GO" --config manifest.yaml > _build/build.log 2>&1; then | ||
echo "✅ SUCCESS: distribution '${distribution}' built." | ||
else | ||
echo "❌ ERROR: failed to build the distribution '${distribution}'." | ||
echo "🪵 Build logs for '${distribution}'" | ||
echo "----------------------" | ||
cat _build/build.log | ||
echo "----------------------" | ||
exit 1 | ||
fi | ||
|
||
popd > /dev/null | ||
done |