Skip to content

Commit

Permalink
feat(TKC-1580): prepare Init Process for TestWorkflow containers (#5090)
Browse files Browse the repository at this point in the history
* feat(TKC-1465): add helpers to immediately evaluate Template/Expression
* feat(TKC-1465): add option to force simplifying templates in unknown structs
* fix(TKC-1465): template evaluation typo
* fix(TKC-1465): simplifying private properties in structs
* fix(TKC-1465): deep simplify structs
* fix(TKC-1465): EvalExpression typo
* fix(TKC-1465): Negation precedence
* fix(TKC-1465): add negative number test
* feat(TKC-1465): predict logical operations paths
* feat(TKC-1580): prepare initial Init Process for TestWorkflow containers
* feat(TKC-1580): distinguish hints of outputs in TestWorkflow containers
* chore(TKC-1580): delete unused code
* chore(TKC-1580): extract commons for critical errors in init process
* feat(TKC-1465): add Escape helper
* feat(TKC-1580): make conditions order irrelevant
* fix(TKC-1580): compute init status with execution status too
* fix(TKC-1580): compute conditions correctly
* fix: image inspector with ConfigMap
* feat(TKC-1465): add option to finalize structs with expression language
  • Loading branch information
rangoo94 authored Mar 1, 2024
1 parent 2d12234 commit 615b275
Show file tree
Hide file tree
Showing 28 changed files with 1,436 additions and 49 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker-build-api-executors-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,61 @@ jobs:
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
ALPINE_IMAGE: ${{ env.ALPINE_IMAGE }}

testworkflow-init:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- uses: sigstore/[email protected]

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
- uses: anchore/sbom-action/[email protected]

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set-up Go
uses: actions/setup-go@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Go Cache
uses: actions/cache@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: testkube-tw-init-go-${{ hashFiles('**/go.sum') }}

- name: Login to DockerHub
uses: docker/login-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Release
uses: goreleaser/goreleaser-action@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow-init.yml
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
ANALYTICS_API_KEY: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_SECRET}}
SLACK_BOT_CLIENT_ID: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_ID}}
SLACK_BOT_CLIENT_SECRET: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_SECRET}}
SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_SEGMENTIO_KEY}}
CLOUD_SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_CLOUD_SEGMENTIO_KEY}}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
ALPINE_IMAGE: ${{ env.ALPINE_IMAGE }}

single_executor:
strategy:
matrix:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/docker-build-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,63 @@ jobs:
run: |
docker push kubeshop/testkube-api-server:${{ steps.commit.outputs.short }}
testworkflow-init:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set-up Go
uses: actions/setup-go@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Go Cache
uses: actions/cache@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: testkube-tw-init-go-${{ hashFiles('**/go.sum') }}

- name: Login to DockerHub
uses: docker/login-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: commit
uses: prompt/actions-commit-hash@v3

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Release
uses: goreleaser/goreleaser-action@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow-init.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
ANALYTICS_API_KEY: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_SECRET}}
SLACK_BOT_CLIENT_ID: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_ID}}
SLACK_BOT_CLIENT_SECRET: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_SECRET}}
SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_SEGMENTIO_KEY}}
CLOUD_SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_CLOUD_SEGMENTIO_KEY}}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
ALPINE_IMAGE: ${{ env.ALPINE_IMAGE }}
IMAGE_TAG_SHA: true

- name: Push Docker images
run: |
docker push kubeshop/testkube-tw-init:${{ steps.commit.outputs.short }}
single_executor:
strategy:
matrix:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/docker-build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,63 @@ jobs:
run: |
docker push kubeshop/testkube-api-server:${{ steps.commit.outputs.short }}
testworkflow-init:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Set-up Go
uses: actions/setup-go@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Go Cache
uses: actions/cache@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: testkube-tw-init-go-${{ hashFiles('**/go.sum') }}

- name: Login to DockerHub
uses: docker/login-action@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: commit
uses: prompt/actions-commit-hash@v3

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help

- name: Release
uses: goreleaser/goreleaser-action@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
with:
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-testworkflow-init.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_ID}}
ANALYTICS_API_KEY: ${{secrets.TESTKUBE_API_GA_MEASUREMENT_SECRET}}
SLACK_BOT_CLIENT_ID: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_ID}}
SLACK_BOT_CLIENT_SECRET: ${{secrets.TESTKUBE_SLACK_BOT_CLIENT_SECRET}}
SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_SEGMENTIO_KEY}}
CLOUD_SEGMENTIO_KEY: ${{secrets.TESTKUBE_API_CLOUD_SEGMENTIO_KEY}}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
ALPINE_IMAGE: ${{ env.ALPINE_IMAGE }}
IMAGE_TAG_SHA: true

- name: Push Docker images
run: |
docker push kubeshop/testkube-tw-init:${{ steps.commit.outputs.short }}
single_executor:
strategy:
matrix:
Expand Down
6 changes: 6 additions & 0 deletions build/testworkflow-init/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# syntax=docker/dockerfile:1
ARG ALPINE_IMAGE
FROM ${ALPINE_IMAGE}

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium test

score is 0: containerImage not pinned by hash
Click Remediation section below to solve this issue
COPY testworkflow-init /init
USER 1001
ENTRYPOINT ["/init"]
7 changes: 7 additions & 0 deletions cmd/tcl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Testkube - TCL Package

This folder contains special code with the Testkube Community license.

## License

The code in this folder is licensed under the Testkube Community License. Please see the [LICENSE](../../licenses/TCL.txt) file for more information.
33 changes: 33 additions & 0 deletions cmd/tcl/testworkflow-init/data/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 Testkube.
//
// Licensed as a Testkube Pro file under the Testkube Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt

package data

import (
"os"
)

type config struct {
Negative bool
Debug bool
RetryCount int
RetryUntil string

Resulting []Rule
}

var Config = &config{
Debug: os.Getenv("DEBUG") == "1",
}

func LoadConfig(config map[string]string) {
Config.Debug = getBool(config, "debug", Config.Debug)
Config.RetryCount = getInt(config, "retryCount", 1)
Config.RetryUntil = getStr(config, "retryUntil", "self.passed")
Config.Negative = getBool(config, "negative", false)
}
34 changes: 34 additions & 0 deletions cmd/tcl/testworkflow-init/data/emit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2024 Testkube.
//
// Licensed as a Testkube Pro file under the Testkube Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt

package data

import (
"encoding/json"
"fmt"
)

func EmitOutput(ref string, name string, value interface{}) {
j, err := json.Marshal(value)
if err != nil {
panic(fmt.Sprintf("error while marshalling reference: %v", err))
}
fmt.Printf("\n;;%s;%s:%s;\n", ref, name, string(j))
}

func EmitHint(ref string, name string) {
fmt.Printf("\n;;;%s;%s;\n", ref, name)
}

func EmitHintDetails(ref string, name string, value interface{}) {
j, err := json.Marshal(value)
if err != nil {
panic(fmt.Sprintf("error while marshalling reference: %v", err))
}
fmt.Printf("\n;;;%s;%s:%s;\n", ref, name, string(j))
}
Loading

0 comments on commit 615b275

Please sign in to comment.