Skip to content

Commit

Permalink
Merge branch 'main' into 30-memory-profiling-of-managercontroller
Browse files Browse the repository at this point in the history
  • Loading branch information
akyriako authored Nov 19, 2024
2 parents 2aa528a + f42fce5 commit c08ea8c
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 7 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build Image and Publish to Dockerhub

on:
release:
types: [ published ]
workflow_dispatch:
inputs:
tag:
description: 'Image tag'
required: true
default: 'test'
permissions:
contents: read

jobs:
image:
name: Build Image from Dockerfile and binaries
runs-on: ubuntu-latest
steps:
# environment
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'

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

- name: Get Image Tag Name
run: |
if [ x${{ github.event.inputs.tag }} == x"" ]; then
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
else
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# prepare image tags
- name: Prepare Image Tags
run: |
echo "TAG_MANAGER=akyriako78/rekuberate-io-sleepcycles:${{ env.TAG_NAME }}" >> $GITHUB_ENV
echo "TAG_RUNNER=akyriako78/rekuberate-io-sleepcycles:${{ env.TAG_NAME }}" >> $GITHUB_ENV
- name: Build and push manager
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
${{ env.TAG_MANAGER }}
- name: Build and push runner
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.runner
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
${{ env.TAG_RUNNER }}
50 changes: 50 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: golangci-lint
on:
push:
branches:
- master
- dev
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.61
args: --timeout 5m

- name: Go Format
run: gofmt -s -w . && git diff --exit-code

- name: Go Vet
run: go vet ./...

- name: Go Tidy
run: go mod tidy && git diff --exit-code

- name: Go Mod
run: go mod download

- name: Go Mod Verify
run: go mod verify

# TODO: enable tests
# - name: Go Test
# run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./...
45 changes: 45 additions & 0 deletions .github/workflows/lint-helm-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint and Test Charts

on: pull_request

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.14.4

- uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}
4 changes: 3 additions & 1 deletion controllers/sleepcycle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ package controllers
import (
"context"
"fmt"
"strings"

Check failure on line 22 in controllers/sleepcycle_controller.go

View workflow job for this annotation

GitHub Actions / lint

"strings" imported and not used) (typecheck)

Check failure on line 22 in controllers/sleepcycle_controller.go

View workflow job for this annotation

GitHub Actions / lint

"strings" imported and not used (typecheck)
"time"

"github.com/go-logr/logr"
"github.com/hashicorp/go-multierror"
corev1alpha1 "github.com/rekuberate-io/sleepcycles/api/v1alpha1"
Expand All @@ -31,7 +34,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"time"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions controllers/sleepcycle_runners_cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package controllers
import (
"context"
"fmt"
"strconv"
"strings"

"github.com/go-logr/logr"
corev1alpha1 "github.com/rekuberate-io/sleepcycles/api/v1alpha1"
batchv1 "k8s.io/api/batch/v1"
Expand All @@ -11,8 +14,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"strconv"
"strings"
)

var (
Expand Down
10 changes: 6 additions & 4 deletions runners/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"context"
"flag"
"fmt"
"os"
"strconv"
"strings"
"time"

"github.com/go-logr/logr"
"github.com/pkg/errors"
"go.uber.org/zap/zapcore"
Expand All @@ -17,12 +22,9 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
"k8s.io/utils/pointer"
"os"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"strconv"
"strings"
"time"
)

var (
Expand Down

0 comments on commit c08ea8c

Please sign in to comment.