-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] Build and publish application hosted in the repository for th…
…e Golang instrumentation E2E test (#2097) * Build and publish the Golang E2E image Signed-off-by: Israel Blancas <[email protected]> * Fix the CI Signed-off-by: Israel Blancas <[email protected]> * Fix the tags Signed-off-by: Israel Blancas <[email protected]> * Add missing header Signed-off-by: Israel Blancas <[email protected]> * Use alpine image for builder Signed-off-by: Israel Blancas <[email protected]> * Change image name Signed-off-by: Israel Blancas <[email protected]> --------- Signed-off-by: Israel Blancas <[email protected]>
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
.github/workflows/publish-autoinstrumentation-e2e-images.yaml
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,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 |
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,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"] |
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,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) | ||
} | ||
} |