Skip to content

Commit

Permalink
working on CI jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Parthiba-Hazra <parthibahazra@gmail.com>
  • Loading branch information
Parthiba-Hazra committed Jun 8, 2024
1 parent 4f69d8b commit 3c20f2b
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Check for updates to Go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
70 changes: 70 additions & 0 deletions .github/workflows/quickstart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and Deploy

on: [push, pull_request]

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
curl -sLo kind "$(curl -sL https://github.com/gitapi/repos/kubernetes-sigs/kind/releases/latest | jq -r '[.assets[] | select(.name == "kind-linux-amd64")] | first | .browser_download_url')"
chmod +x kind
sudo mv kind /bin/
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /bin/
sudo apt-get update
sudo apt-get install -y docker.io
- name: Build Docker image
run: |
sudo -E docker build -t checkpoint-restore-operator:ci .
# sudo -E docker tag checkpoint-restore-operator:ci docker.io/remontada007/checkpoint-restore-operator:v2
# - name: Log in to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Push Docker image to Docker Hub
# run: sudo -E docker push docker.io/remontada007/checkpoint-restore-operator:v2

- name: Create Kubernetes cluster
run: |
kind create cluster
kind export kubeconfig
- name: Deploy to Kubernetes
run: |
make deploy IMG=checkpoint-restore-operator:ci
# /home/ubuntu/checkpoint-restore-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
# cd config/manager && /home/ubuntu/checkpoint-restore-operator/bin/kustomize edit set image controller=docker.io/remontada007/checkpoint-restore-operator:v2
# /home/ubuntu/checkpoint-restore-operator/bin/kustomize build config/default | kubectl apply -f -
- name: Wait for deployments to be ready
run: |
wait_for_deployment() {
local deployment_name=$1
timeout=60
i=1
echo "Checking if the ${deployment_name} deployment is ready"
until kubectl -n checkpoint-restore-operator-system get deployment ${deployment_name} -o jsonpath='{.status.conditions[?(@.status=="True")].type}' | grep "Available" 2>/dev/null; do
((i++))
if [[ ${i} -gt ${timeout} ]]; then
echo "the ${deployment_name} deployment has not become ready before the timeout period"
exit 1
fi
echo "waiting for ${deployment_name} deployment to report a ready status"
sleep 5
done
echo "The ${deployment_name} deployment is ready"
}
wait_for_deployment checkpoint-restore-operator-controller-manager
- name: Check resources
run: kubectl get all -n checkpoint-restore-operator-system
79 changes: 79 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: verify

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m --out-format=colored-line-number
only-new-issues: true
- name: codespell
uses: codespell-project/actions-codespell@v2
with:
skip: vendor,*.svg

gomod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: verify go.mod/go.sum
run: |
make vendor
git diff --exit-code
- name: Upload go.sum diff if exists
if: failure()
uses: actions/upload-artifact@v3
with:
name: go-sum-diff
path: go.sum.diff

lint_markdown:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
base: 'main'
filters: |
md:
- 'README.md'
- '.github/workflows/verify.yml'
- name: Lint markdown
if: steps.changes.outputs.md == 'true'
uses: DavidAnson/markdownlint-cli2-action@v10
with:
globs: |
README.md
.github/workflows/verify.yml
- name: Upload Markdown lint results
if: failure()
uses: actions/upload-artifact@v3
with:
name: markdown-lint-results
path: .github/workflows/verify.yml.md-lint-results.txt
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ test: manifests generate fmt vet envtest ## Run tests.
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go

.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go
Expand Down
19 changes: 12 additions & 7 deletions config/crd/bases/criu.org_checkpointrestoreoperators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.15.0
name: checkpointrestoreoperators.criu.org
spec:
group: criu.org
Expand All @@ -21,14 +21,19 @@ spec:
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: controller
newTag: latest
newName: docker.io/remontada007/checkpoint-restore-operator
newTag: v2

0 comments on commit 3c20f2b

Please sign in to comment.