From 1be78ecfc556d09c21179073f75b32988076d61d Mon Sep 17 00:00:00 2001 From: Abdurrahman Allawala Date: Mon, 1 Aug 2022 15:31:07 -0700 Subject: [PATCH] add CI and project.yml (#1) * add CI and project.yml * add caching * add lint check * add lint check * rearrange steps * rearrange steps and generify CI job for any component * rearrange steps and generify CI job for any component * add MANDATORY_REVIEWERS --- MANDATORY_REVIEWERS | 1 + Makefile.Common | 2 +- _infra/ci/Dockerfile | 27 +++++++++++++++ _infra/ci/dispatch.yml | 16 +++++++++ _infra/ci/jobs/component_ci.yml | 59 +++++++++++++++++++++++++++++++++ _infra/project.yml | 11 ++++++ 6 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 MANDATORY_REVIEWERS create mode 100644 _infra/ci/Dockerfile create mode 100644 _infra/ci/dispatch.yml create mode 100644 _infra/ci/jobs/component_ci.yml create mode 100644 _infra/project.yml diff --git a/MANDATORY_REVIEWERS b/MANDATORY_REVIEWERS new file mode 100644 index 0000000000000..615de61bc033d --- /dev/null +++ b/MANDATORY_REVIEWERS @@ -0,0 +1 @@ +third-party/observability \ No newline at end of file diff --git a/Makefile.Common b/Makefile.Common index 6b54df6b6720d..8d1552dd4c629 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -195,7 +195,7 @@ fmt: $(GOIMPORTS) $(GOIMPORTS) -w -local github.com/open-telemetry/opentelemetry-collector-contrib ./ .PHONY: lint -lint: $(LINT) checklicense misspell +lint: $(LINT) misspell $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=30m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck diff --git a/_infra/ci/Dockerfile b/_infra/ci/Dockerfile new file mode 100644 index 0000000000000..e030eaed54ae2 --- /dev/null +++ b/_infra/ci/Dockerfile @@ -0,0 +1,27 @@ +# This Dockerfile describes the container in which to run your CI jobs. +# You can install whatever dependencies you'd like in this Dockerfile, +# and you can even define more Dockerfiles if you have multiple jobs +# that need to run in different environments! +# +# By default, CI Dockerfiles are built with an empty build context. You +# can configure a custom build context in your job. +# +# Questions? Visit air.bb/ci-docs or ask a question on Stack Overflow with +# the tag #continuous-integration. + +FROM 172631448019.dkr.ecr.us-east-1.amazonaws.com/ubuntu1804:2024-01-09-5ed90b7b + +######### install go +ARG GO_VERSION=1.20.13 +RUN /jorb/scripts/install-go.sh ${GO_VERSION} +######### + +# Set up Gopath for caching +WORKDIR /go +ENV GOPATH=/go +ENV GOMAXTHREADS=3 +ENV PATH="/usr/local/go/bin:$GOPATH/bin:$PATH" +ENV GO=go + +# Delete forward-udp to enable statsd_receiver testing +RUN rm -f /usr/local/bin/forward-udp \ No newline at end of file diff --git a/_infra/ci/dispatch.yml b/_infra/ci/dispatch.yml new file mode 100644 index 0000000000000..b7f9485056bcf --- /dev/null +++ b/_infra/ci/dispatch.yml @@ -0,0 +1,16 @@ +--- +# Generated by: onetouch-gen v1.26.3 (titanic: e28693593a57d500d94cdd97ceddff82c776522a) + +# This file configures your CI jobs to run when you push your branch. +# In this file, you can define build matrices, dependencies between +# jobs, resource requests, timeouts, parallelism, and more! +# +# Questions? Visit air.bb/ci-docs or ask a question on Stack Overflow with +# the tag #continuous-integration. + +jobs: + - name: receiver/statsdreceiver CI Check + path: _infra/ci/jobs/component_ci.yml + options: + env: + COMPONENT_PATH: "receiver/statsdreceiver" \ No newline at end of file diff --git a/_infra/ci/jobs/component_ci.yml b/_infra/ci/jobs/component_ci.yml new file mode 100644 index 0000000000000..8abcf42e00ac0 --- /dev/null +++ b/_infra/ci/jobs/component_ci.yml @@ -0,0 +1,59 @@ +--- +# Generated by: onetouch-gen v1.26.3 (titanic: e28693593a57d500d94cdd97ceddff82c776522a) + +# This is a simple CI job. A CI job comprises a list of steps that run +# sequentially in a container described by an image or a Dockerfile. +# +# Questions? Visit air.bb/ci-docs or ask a question on Stack Overflow with +# the tag #continuous-integration. + +dockerfile: ../Dockerfile + +steps: + # start: environment setup # + - type: restore_cache + label: Restore cache + cache_key: go-image-{% image_id %}-go-sum-{% checksum files=[go.sum] %} + + - type: run + label: make moddownload + command: | + set -ex + sudo mkdir -p "$GOPATH" + sudo chmod -R ugo+rwX "$GOPATH" + + cd $COMPONENT_PATH + make moddownload + + - type: run + label: make install-tools + command: make install-tools + + - type: save_cache + label: Save cache + cache_key: go-image-{% image_id %}-go-sum-{% checksum files=[go.sum] %} + paths: + - /go + # end: environment setup # + + # start: go mod tidy, unit tests, and lint # + - type: run + label: Check for go mod dependency changes + command: | + cd $COMPONENT_PATH + make tidy + git diff --exit-code || (echo 'go.mod/go.sum deps changes detected, please run "make gotidy" and commit the changes in this PR.' && exit 1) + + - type: run + label: make test + command: | + cd $COMPONENT_PATH + make test + + - type: run + label: make lint + command: | + cd $COMPONENT_PATH + make lint + + # end: go mod tidy, unit tests, and lint # \ No newline at end of file diff --git a/_infra/project.yml b/_infra/project.yml new file mode 100644 index 0000000000000..ee2e61440f4ee --- /dev/null +++ b/_infra/project.yml @@ -0,0 +1,11 @@ +--- +# Generated by: onetouch-gen v1.26.3 (titanic: e28693593a57d500d94cdd97ceddff82c776522a) +name: opentelemetry-collector-contrib +description: An Airbnb-specific fork of the opentelemetry-collector-contrib repo +slack: observability +teams: +- 'Airbnb Platform: Infrastructure: Data Platform: Observability' +data_sensitivity: public +additional_owners: [] +type: library +primary_language: golang