Skip to content

Commit

Permalink
Merge branch 'sustainable-computing-io:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vprashar2929 authored May 20, 2024
2 parents dfcf4dd + 90fd281 commit 24acb5b
Show file tree
Hide file tree
Showing 141 changed files with 15,801 additions and 6,804 deletions.
14 changes: 14 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
categories:
- title: 🏕 Features
labels:
- '^feat.*'
- title: 🧑‍💻 Dev
labels:
- '^dev.*'
- title: 🔧 Fix
labels:
- '^fix.*'
- title: 👒 Chores
labels:
- '^chore.*'
1 change: 1 addition & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This workflow would be run on sustainable-computing-io/kepler only.
name: Scheduled build
on:
workflow_dispatch:
branch_protection_rule:
schedule:
- cron: "12 9 * * *"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
file: ./build/Dockerfile.builder
platforms: linux/amd64,linux/arm64,linux/s390x
push: ${{ inputs.pushImage }}
tags: quay.io/sustainable_computing_io/kepler_builder:ubi-9-libbpf-1.2.0
tags: quay.io/sustainable_computing_io/kepler_builder:ubi-9-libbpf-1.3.0
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
secrets:
username: ${{ secrets.BOT_NAME }}
password: ${{ secrets.BOT_TOKEN }}

releasepage:
name: download Kepler image SBOM
needs: [push-image]
Expand All @@ -125,4 +125,3 @@ jobs:
with:
tag_name: ${{ github.event.inputs.tag }}
files: ./sbom-kepler-${{ github.event.inputs.release }}.spdx.json
body_path: CHANGELOG.md
88 changes: 88 additions & 0 deletions .github/workflows/review_bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Review Bot

permissions:
contents: read
pull-requests: write
issues: write
discussions: write

on:
issues:
types: [ opened ]
issue_comment:
types: [ created ]
pull_request:
pull_request_target:
types: [ opened, synchronize, edited ]
pull_request_review_comment:
types: [ created ]
discussion:
types: [ created ]
discussion_comment:
types: [ created ]

concurrency:
group:
${{ github.repository }}-${{ github.event.number || github.head_ref ||
github.sha }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
seinesailor:
# the github.event.pull_request.head.repo.fork is a boolean, it ensures that the pull_request_target event only
# runs from a forked repo
if: |
github.event_name == 'pull_request' ||
github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork ||
(contains(github.event.comment.body, '@SeineSailor') && (
github.event_name == 'issue_comment' ||
github.event_name == 'pull_request_review_comment' ||
github.event_name == 'discussion_comment')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@SeineSailor')) ||
(github.event_name == 'discussion' && contains(github.event.discussion.body, '@SeineSailor'))
runs-on: ubuntu-latest
steps:
- name: Check for mention outside of quotes in comments
id: check_mention
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
echo "checking for mention outside of quotes and code blocks"
mention_outside_quotes=false
in_code_block=false
while IFS= read -r line; do
# Check for start or end of a code block
if [[ "$line" =~ ^\`\`\` ]]; then
if [[ "$in_code_block" = true ]]; then
in_code_block=false
else
in_code_block=true
fi
fi
# Process lines that are not in a code block or quoted
if [[ "$in_code_block" = false && ! "$line" =~ ^\> ]]; then
if echo "$line" | grep -q '@SeineSailor'; then
mention_outside_quotes=true
break
fi
fi
done <<< "$COMMENT_BODY"
echo "mention_outside_quotes=$mention_outside_quotes" >> $GITHUB_ENV
# - name: Dump GitHub context for debug
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"
- name: Dump event payload for debug
run: cat $GITHUB_EVENT_PATH
- name: Run SeineSailor
uses: SeineAI/SeineSailor@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
debug: true
82 changes: 41 additions & 41 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Get ginkgo
run: make ginkgo-set
env:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Get ginkgo
run: make ginkgo-set
env:
GOPATH: /home/runner/go
GOBIN: /home/runner/go/bin
- name: Prepare environment
run: |
- name: Prepare environment
run: |
sudo apt-get install -y cpuid clang
cd doc/ && sudo ./dev/prepare_dev_env.sh && cd -
git config --global --add safe.directory /kepler
- name: install libbpf
uses: sustainable-computing-io/kepler-action@v0.0.6
with:
ebpfprovider: libbpf
- name: Run
run: |
- name: install libbpf
uses: sustainable-computing-io/kepler-action@v0.0.6
with:
ebpfprovider: libbpf
- name: Run
run: |
sudo apt remove libbpf-dev
mkdir temp-libbpf
cd temp-libbpf
Expand All @@ -47,30 +47,30 @@ jobs:
sudo make install_uapi_headers
sudo prefix=/usr BUILD_STATIC_ONLY=y make install
cd ../../../
ATTACHER_TAG=libbpf make test-verbose
make VERBOSE=1 test
go tool cover -func=coverage.out -o=coverage.out
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: README.md
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: README.md

- name: Commit changes
if: github.event_name != 'pull_request' && steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "bot@sustainable-computing.io"
git config --local user.name "sustainable-computing-bot"
git add README.md
git commit -m "bot: Updated coverage badge." -s
- name: Commit changes
if: github.event_name != 'pull_request' && steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "bot@sustainable-computing.io"
git config --local user.name "sustainable-computing-bot"
git add README.md
git commit -m "bot: Updated coverage badge." -s
- name: Push changes
if: github.event_name != 'pull_request' && steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_BOT_SECRET }}
branch: ${{ github.head_ref }}
- name: Push changes
if: github.event_name != 'pull_request' && steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_BOT_SECRET }}
branch: ${{ github.head_ref }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ local-dev-cluster

# object files
*.o

# test coverage
coverage.out
64 changes: 44 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ clean-cross-build:
build: clean_build_local _build_local copy_build_local ## Build binary and copy to $(OUTPUT_DIR)/bin
.PHONY: build

_build_local: ## Build Kepler binary locally.
_build_ebpf_local:
@make -C bpfassets/libbpf

_build_local: _build_ebpf_local ## Build Kepler binary locally.
@echo TAGS=$(GO_BUILD_TAGS)
@mkdir -p "$(CROSS_BUILD_BINDIR)/$(GOOS)_$(GOARCH)"
+@$(GOENV) go build -v -tags ${GO_BUILD_TAGS} -o $(CROSS_BUILD_BINDIR)/$(GOOS)_$(GOARCH)/kepler -ldflags $(LDFLAGS) ./cmd/exporter/exporter.go
Expand Down Expand Up @@ -229,17 +231,20 @@ cross-build: clean_build_local cross-build-linux-amd64 cross-build-linux-arm64 c
.PHONY: cross-build

## toolkit ###
.PHONY: tidy-vendor
tidy-vendor:
go mod tidy -v
go mod vendor

.PHONY: ginkgo-set
ginkgo-set:
mkdir -p $(GOBIN)
mkdir -p $(ENVTEST_ASSETS_DIR)
@test -f $(ENVTEST_ASSETS_DIR)/ginkgo || \
(go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.4.0 && \
(go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.15.0 && \
cp $(GOBIN)/ginkgo $(ENVTEST_ASSETS_DIR)/ginkgo)

.PHONY: container_test
container_test:
$(CTR_CMD) run --rm \
-v $(base_dir):/kepler:Z\
Expand All @@ -254,32 +259,51 @@ container_test:
cd doc/ && \
./dev/prepare_dev_env.sh && \
cd - && git config --global --add safe.directory /kepler && \
make test-container-verbose'
make VERBOSE=1 unit-test bench'

test: ginkgo-set tidy-vendor
@echo TAGS=$(GO_TEST_TAGS)
@$(GOENV) go test -tags $(GO_TEST_TAGS) ./... --race --bench=. -cover --count=1 --vet=all -v
VERBOSE ?= 0
TMPDIR := $(shell mktemp -d)
TEST_PKGS := $(shell go list ./... | grep -v pkg/bpf | grep -v e2e)
SUDO?=sudo
SUDO_TEST_PKGS := $(shell go list ./... | grep pkg/bpf)

test-verbose: ginkgo-set tidy-vendor
@echo TAGS=$(GO_TEST_TAGS)
@echo GOENV=$(GOENV)
@$(GOENV) go test -tags $(GO_TEST_TAGS) \
-timeout=30m \
-covermode=atomic -coverprofile=coverage.out \
-v $$(go list ./... | grep pkg | grep -v bpfassets) \
--race --bench=. -cover --count=1 --vet=all
.PHONY: test
test: unit-test bpf-test bench ## Run all tests.

test-container-verbose: ginkgo-set tidy-vendor
.PHONY: unit-test
unit-test: ginkgo-set tidy-vendor ## Run unit tests.
@echo TAGS=$(GO_TEST_TAGS)
@echo GOENV=$(GOENV)
$(if $(VERBOSE),@echo GOENV=$(GOENV))
@$(GOENV) go test -tags $(GO_TEST_TAGS) \
-covermode=atomic -coverprofile=coverage.out \
-v $$(go list ./... | grep pkg | grep -v bpfassets) \
--race -cover --count=1 --vet=all
$(if $(VERBOSE),-v) \
-cover -covermode=atomic -coverprofile=coverage.out \
--race --count=1 \
$(TEST_PKGS)

.PHONY: bench
bench: ## Run benchmarks.
@echo TAGS=$(GO_TEST_TAGS)
$(GOENV) go test -tags $(GO_TEST_TAGS) \
$(if $(VERBOSE),-v) \
-test.run=dontrunanytests \
-bench=. --count=1 $(TEST_PKGS)

.PHONY: bpf-test
bpf-test: _build_ebpf_local ## Run BPF tests.
for pkg in $(SUDO_TEST_PKGS); do \
$(GOENV) go test -c $$pkg -tags $(GO_TEST_TAGS) -cover \
-covermode=atomic -coverprofile=coverage.bpf.out \
-o $(TMPDIR)/$$(basename $$pkg).test && \
$(SUDO) $(TMPDIR)/$$(basename $$pkg).test; \
done

.PHONY: test-mac-verbose
test-mac-verbose: ginkgo-set
@echo TAGS=$(GO_TEST_TAGS)
@go test $$(go list ./... | grep pkg | grep -v bpfassets) --race --bench=. -cover --count=1 --vet=all
@go test \
-covermode=atomic -coverprofile=coverage.out \
--race --count=1 \
$(TEST_PKGS)

escapes_detect: tidy-vendor
@$(GOENV) go build -tags $(GO_BUILD_TAGS) -gcflags="-m -l" ./... 2>&1 | grep "escapes to heap" || true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![GitHub Workflow Status (event)](https://img.shields.io/github/actions/workflow/status/sustainable-computing-io/kepler/unit_test.yml?branch=main&label=CI)

![Coverage](https://img.shields.io/badge/Coverage-49.5%25-yellow)
![Coverage](https://img.shields.io/badge/Coverage-47.5%25-yellow)
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7391/badge)](https://bestpractices.coreinfrastructure.org/projects/7391)[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sustainable-computing-io/kepler/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sustainable-computing-io/kepler)
<!--
[![GoDoc](https://godoc.org/github.com/kubernetes/kube-state-metrics?status.svg)](https://godoc.org/github.com/kubernetes/kube-state-metrics)
Expand Down
Loading

0 comments on commit 24acb5b

Please sign in to comment.