Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test #106

Merged
merged 1 commit into from
Mar 8, 2024
Merged
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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bug Report
description: Report a bug in Kubectl AI
title: "[BUG] <title>"
labels:
- "bug"
body:
- type: markdown
attributes:
value: |
Please search to see if an issue already exists for your bug before continuing.
> If you need to report a security issue please see https://github.com/sozercan/kubectl-ai/security/policy instead.
- type: textarea
attributes:
label: Expected Behavior
description: Briefly describe what you expect to happen.
- type: textarea
attributes:
label: Actual Behavior
description: Briefly describe what is actually happening.
- type: textarea
attributes:
label: Steps To Reproduce
description: Detailed steps to reproduce the behavior.
placeholder: |
1. In ...
2. With this config...
3. Run '...'
4. See error...
- type: checkboxes
id: idea
attributes:
label: "Are you willing to submit PRs to contribute to this bug fix?"
options:
- label: Yes, I am willing to implement it.
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out a bug report!
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Request
description: Request a new feature or propose an enhancement to Kubectl AI
title: "[REQ] <title>"
labels:
- "enhancement"
body:
- type: markdown
attributes:
value: |
Please search to see if an issue already exists for your request before continuing.
- type: dropdown
attributes:
label: What kind of request is this?
multiple: false
options:
- New feature
- Improvement of existing experience
- Other
- type: textarea
attributes:
label: What is your request or suggestion?
placeholder: |
e.g. I would like Kubectl AI to add this <feature> so that I can use it in my <scenario>.
e.g. When using Kubectl AI the <current behavior> has this <limitation> and it would be better if it has this <improvement>.
- type: checkboxes
id: idea
attributes:
label: "Are you willing to submit PRs to contribute to this feature request?"
options:
- label: Yes, I am willing to implement it.
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out a request!
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, using `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when the PR gets merged)*:
Fixes #

**Special notes for your reviewer**:
50 changes: 32 additions & 18 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
name: test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:

permissions: read-all

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
options:
- fn-call
- non-fn-call
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"

- name: go mod tidy
- name: setup test dependencies
if: matrix.options == 'fn-call'
run: |
go mod tidy
git diff --exit-code

- name: test
run: make test
make test-e2e-dependencies

- name: build
run: make bin

- name: run tests
shell: bash
run: |
if [[ ${{ matrix.options }} == 'fn-call' ]]; then
FN_CALL="--use-k8s-api"
# used to retrieve the k8s api
kind create cluster
fi

bin/kubectl-ai "create an nginx deployment with 3 replicas" --require-confirmation=false ${FN_CALL}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_DEPLOYMENT_NAME: ${{ secrets.OPENAI_DEPLOYMENT_NAME }}
OPENAI_ENDPOINT: ${{ secrets.OPENAI_ENDPOINT }}

- run: |
kubectl get deployments
kubectl get pods
36 changes: 36 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: unit-test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

permissions: read-all

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: go mod tidy
run: |
go mod tidy
git diff --exit-code

- name: test
run: make test

- name: build
run: make bin
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
KIND_VERSION ?= 0.22.0
KUBERNETES_VERSION ?= 1.29.2

.PHONY: test
test:
go test ./... -coverprofile cover.out
Expand All @@ -14,5 +17,15 @@ fmt:
vet:
go vet ./...

.PHONY: lint
lint:
golangci-lint run -v ./...

.PHONY: test-e2e-dependencies
test-e2e-dependencies:
mkdir -p ${GITHUB_WORKSPACE}/bin
echo "${GITHUB_WORKSPACE}/bin" >> ${GITHUB_PATH}

# used for kubernetes test
curl -sSL https://dl.k8s.io/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl -o ${GITHUB_WORKSPACE}/bin/kubectl && chmod +x ${GITHUB_WORKSPACE}/bin/kubectl
curl -sSL https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64 -o ${GITHUB_WORKSPACE}/bin/kind && chmod +x ${GITHUB_WORKSPACE}/bin/kind
9 changes: 9 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Security Policy

## Supported Versions

Security updates are applied only to the most recent releases.

## Reporting a Vulnerability

To securely report a vulnerability, please [open an advisory on GitHub](https://github.com/sozercan/kubectl-ai/security/advisories/new). This form is also accessible when [submitting a new issue](https://github.com/sozercan/kubectl-ai/issues/new/choose).
Loading