Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/00-pr-scanner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: 00-pr_scanner
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches:
- 'master'
- 'main'
- 'dev'
paths-ignore:
- '**.yaml'
- '**.md'
Expand All @@ -29,3 +25,18 @@ jobs:
RELEASE: ""
CLIENT: test
secrets: inherit

binary-build:
if: ${{ contains( github.event.pull_request.labels.*.name, 'trigger-integration-test') }} ## run only if labeled as "trigger-integration-test"
uses: ./.github/workflows/b-binary-build-and-e2e-tests.yaml
needs: pr-scanner
with:
COMPONENT_NAME: kubescape
CGO_ENABLED: 1
GO111MODULE: ""
GO_VERSION: "1.20"
RELEASE: ""
CLIENT: test
ARCH: ""
OS: "ubuntu-20.04"
secrets: inherit
34 changes: 0 additions & 34 deletions .github/workflows/01-pr-merged.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/a-pr-scanner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,3 @@ jobs:
- Credentials scan: ${{ steps.credentials-scan.outcome }}
- Vulnerabilities scan: ${{ steps.vulnerabilities-scan.outcome }}
reactions: 'eyes'
basic-tests:
needs: scanners
uses: ./.github/workflows/b-binary-build-and-e2e-tests.yaml
with:
COMPONENT_NAME: kubescape
CGO_ENABLED: 1
GO111MODULE: ""
GO_VERSION: "1.20"
RELEASE: ${{ inputs.RELEASE }}
CLIENT: ${{ inputs.CLIENT }}
CHECKOUT_REPO: ${{ github.repository }}
secrets: inherit
74 changes: 66 additions & 8 deletions .github/workflows/b-binary-build-and-e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
name: b-binary-build-and-e2e-tests

on:
workflow_dispatch:
inputs:
COMPONENT_NAME:
required: false
type: string
default: "kubescape"
RELEASE:
required: false
type: string
default: ""
CLIENT:
required: false
type: string
default: "test"
GO_VERSION:
required: false
type: string
default: "1.20"
GO111MODULE:
required: false
type: string
default: ""
CGO_ENABLED:
type: number
default: 1
required: false
OS_METRIX:
type: string
required: false
default: '[ "ubuntu-20.04", "macos-latest", "windows-latest"]'
ARCH_METRIX:
type: string
required: false
default: '[ "", "arm64"]'
BINARY_TESTS:
type: string
required: false
default: '[ "scan_nsa", "scan_mitre", "scan_with_exceptions", "scan_repository", "scan_local_file", "scan_local_glob_files", "scan_local_list_of_files", "scan_nsa_and_submit_to_backend", "scan_mitre_and_submit_to_backend", "scan_local_repository_and_submit_to_backend", "scan_repository_from_url_and_submit_to_backend", "scan_with_exception_to_backend", "scan_with_custom_framework", "scan_customer_configuration", "host_scanner", "scan_compliance_score" ]'

workflow_call:
inputs:
COMPONENT_NAME:
Expand All @@ -23,18 +63,22 @@ on:
BINARY_TESTS:
type: string
default: '[ "scan_nsa", "scan_mitre", "scan_with_exceptions", "scan_repository", "scan_local_file", "scan_local_glob_files", "scan_local_list_of_files", "scan_nsa_and_submit_to_backend", "scan_mitre_and_submit_to_backend", "scan_local_repository_and_submit_to_backend", "scan_repository_from_url_and_submit_to_backend", "scan_with_exception_to_backend", "scan_with_custom_framework", "scan_customer_configuration", "host_scanner", "scan_compliance_score" ]'
CHECKOUT_REPO:
OS_METRIX:
type: string
required: false
default: '[ "ubuntu-20.04", "macos-latest", "windows-latest"]'
ARCH_METRIX:
type: string



required: false
default: '[ "", "arm64"]'
jobs:
wf-preparation:
name: secret-validator
runs-on: ubuntu-latest
outputs:
TEST_NAMES: ${{ steps.export_tests_to_env.outputs.TEST_NAMES }}
OS_METRIX: ${{ steps.export_os_to_env.outputs.OS_METRIX }}
ARCH_METRIX: ${{ steps.export_arch_to_env.outputs.ARCH_METRIX }}
is-secret-set: ${{ steps.check-secret-set.outputs.is-secret-set }}
steps:
- name: check if the necessary secrets are set in github secrets
Expand All @@ -49,32 +93,46 @@ jobs:
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: "echo \"is-secret-set=${{ env.CUSTOMER != '' && \n env.USERNAME != '' &&\n env.PASSWORD != '' &&\n env.CLIENT_ID != '' &&\n env.SECRET_KEY != '' &&\n env.REGISTRY_USERNAME != '' &&\n env.REGISTRY_PASSWORD != ''\n }}\" >> $GITHUB_OUTPUT\n"

- id: export_os_to_env
name: set test name
run: |
echo "OS_METRIX=$input" >> $GITHUB_OUTPUT
env:
input: ${{ inputs.OS_METRIX }}

- id: export_tests_to_env
name: set test name
run: |
echo "TEST_NAMES=$input" >> $GITHUB_OUTPUT
env:
input: ${{ inputs.BINARY_TESTS }}


- id: export_arch_to_env
name: set test name
run: |
echo "ARCH_METRIX=$input" >> $GITHUB_OUTPUT
env:
input: ${{ inputs.ARCH_METRIX }}


binary-build:
name: Create cross-platform build
needs: wf-preparation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
arch: ["", arm64]
os: ${{ fromJson(needs.wf-preparation.outputs.OS_METRIX) }}
arch: ${{ fromJson(needs.wf-preparation.outputs.ARCH_METRIX) }}
exclude:
- os: windows-latest
arch: arm64
steps:

- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # ratchet:actions/checkout@v3
with:
repository: ${{inputs.CHECKOUT_REPO}}
fetch-depth: 0
submodules: recursive

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/pr-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
pull_request:
issue_comment:
jobs:
pr_agent_job:
runs-on: ubuntu-latest
name: Run pr agent on every pull request, respond to user comments
steps:
- name: PR Agent action step
id: pragent
uses: Codium-ai/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
client_var = "github.com/kubescape/kubescape/v2/core/cautils.Client"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Remove unused variable client_var

Suggested change
client_var = "github.com/kubescape/kubescape/v2/core/cautils.Client"

client_name = os.getenv("CLIENT")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Remove unused variable client_name

Suggested change
client_name = os.getenv("CLIENT")


# Create build directory
# Create the build directory
build_dir = get_build_dir()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add error handling for the get_build_dir() function

Suggested change
build_dir = get_build_dir()
try:
build_dir = get_build_dir()
except Exception as e:
print(f'Error getting build directory: {e}')


ks_file = os.path.join(build_dir, package_name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Use os.path.join() for concatenating file paths

Suggested change
ks_file = os.path.join(build_dir, package_name)
ks_file = os.path.join(build_dir, package_name)

Expand Down