diff --git a/.github/workflows/publish-autoinstrumentation-e2e-images.yaml b/.github/workflows/publish-autoinstrumentation-e2e-images.yaml new file mode 100644 index 0000000000..aeedb5a660 --- /dev/null +++ b/.github/workflows/publish-autoinstrumentation-e2e-images.yaml @@ -0,0 +1,61 @@ +name: "Publish instrumentation E2E images" + +on: + push: + paths: + - 'tests/instrumentation-e2e-apps/**' + - '.github/workflows/publish-autoinstrumentation-e2e-images.yaml' + branches: + - main + pull_request: + paths: + - 'tests/instrumentation-e2e-apps/**' + - '.github/workflows/publish-autoinstrumentation-e2e-images.yaml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + golang: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-golang + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Package Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: tests/instrumentation-e2e-apps/golang + platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le + push: ${{ github.event_name == 'push' }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/tests/instrumentation-e2e-apps/golang/Dockerfile b/tests/instrumentation-e2e-apps/golang/Dockerfile new file mode 100644 index 0000000000..fd80c06f1b --- /dev/null +++ b/tests/instrumentation-e2e-apps/golang/Dockerfile @@ -0,0 +1,8 @@ +FROM golang:1.21-alpine as builder + +COPY main.go . +RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o app main.go + +FROM scratch +COPY --from=builder /go/app . +ENTRYPOINT ["./app"] diff --git a/tests/instrumentation-e2e-apps/golang/main.go b/tests/instrumentation-e2e-apps/golang/main.go new file mode 100644 index 0000000000..ad36410372 --- /dev/null +++ b/tests/instrumentation-e2e-apps/golang/main.go @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "net/http" + "time" +) + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Println("Hi") + }) + + server := &http.Server{ + Addr: ":8080", + ReadHeaderTimeout: 3 * time.Second, + } + + err := server.ListenAndServe() + if err != nil { + panic(err) + } +}