From 491131321a935b396bf9323d7998ec3fdcdf65d6 Mon Sep 17 00:00:00 2001 From: jaime merino Date: Wed, 28 Jan 2026 16:21:17 +0100 Subject: [PATCH] test inti --- .forgejo/workflows/demo.yaml | 19 ++++++++++++++ .forgejo/workflows/docker.yaml | 38 +++++++++++++++++++++++++++ internal/common/logger/logger.go | 1 + main.go | 7 +++++ pkg/app/app.go | 27 ++++++++++++++++++++ pkg/app/app_test.go | 44 ++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 .forgejo/workflows/demo.yaml create mode 100644 .forgejo/workflows/docker.yaml create mode 100644 internal/common/logger/logger.go create mode 100644 main.go create mode 100644 pkg/app/app.go create mode 100644 pkg/app/app_test.go diff --git a/.forgejo/workflows/demo.yaml b/.forgejo/workflows/demo.yaml new file mode 100644 index 0000000..2a49f02 --- /dev/null +++ b/.forgejo/workflows/demo.yaml @@ -0,0 +1,19 @@ +on: [push] +jobs: + upload-many: + runs-on: stackit-ubuntu-22 + steps: + - run: mkdir -p artifacts + + - run: touch artifacts/ONE artifacts/TWO + + - uses: actions/upload-artifact@v3 + with: + name: many-artifacts + path: artifacts/ + + - uses: actions/download-artifact@v3 + + - run: | + test -f many-artifacts/ONE + test -f many-artifacts/TWO diff --git a/.forgejo/workflows/docker.yaml b/.forgejo/workflows/docker.yaml new file mode 100644 index 0000000..3decae4 --- /dev/null +++ b/.forgejo/workflows/docker.yaml @@ -0,0 +1,38 @@ +on: [pr] + +env: + JFROG_URL: schwarzit-xx-sit-stackit-dev-exp-docker-local.jfrog.io + JFROG_USERNAME: t-do-s-stackit-dev-exp + +jobs: + test: + runs-on: stackit-docker + steps: + + - uses: actions/checkout@v4 + + - name: Import Secrets + id: import-secrets + uses: hashicorp/vault-action@v2 + with: + url: https://prod.sm.eu01.stackit.cloud + method: userpass + username: ${{ secrets.SECRET_MANAGER_USERNAME }} + password: ${{ secrets.SECRET_MANAGER_PASSWORD }} + secrets: | + 3332b656-c8e9-4a99-9a87-6086843272bc/data/stackit-git-user-management version + - name: echo version + run: "echo $VERSION" + - name: Sensitive Operation + run: "echo '${{ steps.import-secrets.outputs.version }}'" + - name: Log in to Artifactory + uses: docker/login-action@v3 + with: + registry: ${{ env.JFROG_URL }} + username: ${{ env.JFROG_USERNAME }} + password: ${{ secrets.JFROG_PASSWORD }} + - name: Build and push image + uses: https://code.forgejo.org/docker/build-push-action@v5 + with: + push: false + tags: ${{ env.JFROG_URL }}/pipeline_test:ok \ No newline at end of file diff --git a/internal/common/logger/logger.go b/internal/common/logger/logger.go new file mode 100644 index 0000000..90c66f6 --- /dev/null +++ b/internal/common/logger/logger.go @@ -0,0 +1 @@ +package logger diff --git a/main.go b/main.go new file mode 100644 index 0000000..f7b85de --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Printf("hello, world") +} diff --git a/pkg/app/app.go b/pkg/app/app.go new file mode 100644 index 0000000..7eb0aa1 --- /dev/null +++ b/pkg/app/app.go @@ -0,0 +1,27 @@ +package app + +import ( + "context" + "fmt" +) + +func RunApp(ctx context.Context) error { + u := &User{ + Name: "hola", + } + if !UserOK(ctx, u) { + return fmt.Errorf("could not found user") + } + return nil +} + +type User struct { + Name string +} + +func UserOK(ctx context.Context, user *User) bool { + if user == nil { + return false + } + return true +} diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go new file mode 100644 index 0000000..5658cb5 --- /dev/null +++ b/pkg/app/app_test.go @@ -0,0 +1,44 @@ +package app + +import ( + "context" + "testing" +) + +func TestUserOK(t *testing.T) { + type args struct { + ctx context.Context + user *User + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "test ok", + args: args{ + ctx: context.TODO(), + user: &User{ + Name: "hola", + }, + }, + want: true, + }, + { + name: "test not found", + args: args{ + ctx: context.TODO(), + user: nil, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := UserOK(tt.args.ctx, tt.args.user); got != tt.want { + t.Errorf("UserOK() = %v, want %v", got, tt.want) + } + }) + } +}