Skip to content

Commit

Permalink
add binary release to gha CI
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>

add BRO CI to gha CI

Signed-off-by: Alexandre Lamarre <[email protected]>

rename K8S_VERSION_FROM_DRONE to K8S_VERSION_FROM_CI

Signed-off-by: Alexandre Lamarre <[email protected]>

publish images CI

Signed-off-by: Alexandre Lamarre <[email protected]>

ammend CI to use specific kubernetes versions

Signed-off-by: Alexandre Lamarre <[email protected]>

update platform format

Signed-off-by: Alexandre Lamarre <[email protected]>

remove integration tests from make CI

Signed-off-by: Alexandre Lamarre <[email protected]>

[DROP ME] temporarily disable CI action

Signed-off-by: Alexandre Lamarre <[email protected]>

add barebones e2e tests action, with k3d setup

Signed-off-by: Alexandre Lamarre <[email protected]>

modify integration to run off of kube context only

e2e test

Signed-off-by: Alexandre Lamarre <[email protected]>

standardize versioning info linkflags

Signed-off-by: Alexandre Lamarre <[email protected]>

temprorary changes to e2e gha

Signed-off-by: Alexandre Lamarre <[email protected]>

use k3d inside dapper

Signed-off-by: Alexandre Lamarre <[email protected]>

add kubectl to dapper

Signed-off-by: Alexandre Lamarre <[email protected]>

fix import image in cluster

Signed-off-by: Alexandre Lamarre <[email protected]>

temporarily disable e2e ci because its useless

Signed-off-by: Alexandre Lamarre <[email protected]>

re-enable CI

Signed-off-by: Alexandre Lamarre <[email protected]>

disable command tracing for setup cluster

Signed-off-by: Alexandre Lamarre <[email protected]>

copy /dist/artifacts to /tmp/dist/artifacts inside dapper container

Signed-off-by: Alexandre Lamarre <[email protected]>

change deploy script basedir in integration script

Signed-off-by: Alexandre Lamarre <[email protected]>

comment out code that handles 'k3s kubectl'

Signed-off-by: Alexandre Lamarre <[email protected]>

change integration path

Signed-off-by: Alexandre Lamarre <[email protected]>

tests should be ../tests

Signed-off-by: Alexandre Lamarre <[email protected]>

force specific kubectl context

Signed-off-by: Alexandre Lamarre <[email protected]>

try and use correct kube context

Signed-off-by: Alexandre Lamarre <[email protected]>

fix order

Signed-off-by: Alexandre Lamarre <[email protected]>

maybe setting up buildx fixes the nodes not coming up

Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed Apr 16, 2024
1 parent cf60789 commit 167296e
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 82 deletions.
8 changes: 4 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
- name: build
image: rancher/dapper:v0.6.0
commands:
- export K8S_VERSION_FROM_DRONE="v1.24"
- export K8S_VERSION_FROM_CI="v1.24"
- dapper ci
volumes:
- name: docker
Expand All @@ -21,7 +21,7 @@ steps:
- name: build_no_psp
image: rancher/dapper:v0.6.0
commands:
- export K8S_VERSION_FROM_DRONE="stable"
- export K8S_VERSION_FROM_CI="stable"
- dapper ci
volumes:
- name: docker
Expand Down Expand Up @@ -129,7 +129,7 @@ steps:
- name: build
image: rancher/dapper:v0.6.0
commands:
- export K8S_VERSION_FROM_DRONE="v1.24"
- export K8S_VERSION_FROM_CI="v1.24"
- dapper ci
volumes:
- name: docker
Expand All @@ -138,7 +138,7 @@ steps:
- name: build_no_psp
image: rancher/dapper:v0.6.0
commands:
- export K8S_VERSION_FROM_DRONE="stable"
- export K8S_VERSION_FROM_CI="stable"
- dapper ci
volumes:
- name: docker
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Backup Restore CI

on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'

jobs:
build:
name : CI
runs-on : ubuntu-latest
strategy:
matrix:
K8S_VERSION_FROM_CI : ["v1.24","stable"]
include:
- platform: linux/amd64
- platform: linux/arm64
steps:
- name : Checkout repository
uses : actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name : Setup environment variables
run : echo "K8S_VERSION_FROM_CI=${{ matrix.K8S_VERSION_FROM_CI }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name : CI
run : make ci
52 changes: 52 additions & 0 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# name: Backup Restore CI

# on:
# push:
# paths-ignore:
# - 'docs/**'
# - '*.md'
# - '.gitignore'
# - 'CODEOWNERS'
# - 'LICENSE'

# env :
# K3D_VERSION : v5.4.6
# CLUSTER_NAME : backup-restore

# jobs:
# e2e:
# name : e2e-test
# runs-on : ubuntu-latest
# strategy:
# matrix:
# K8S_VERSION_FROM_CI : ["v1.24","stable"]
# include:
# - platform: linux/amd64
# - platform: linux/arm64
# steps:
# - name : Checkout repository
# uses : actions/checkout@v4
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name : Install K3D
# run : ./.github/workflows/e2e/scripts/install-k3d.sh
# - name : Install minio client
# run : |
# curl https://dl.min.io/client/mc/release/linux-amd64/mc > mc
# mv mc /usr/local/bin/
# - name : Setup environment variables
# run : echo "K8S_VERSION_FROM_CI=${{ matrix.K8S_VERSION_FROM_CI }}" >> $GITHUB_ENV
# - name : CI
# run : make ci
# - name : Setup Cluster
# run : ./.github/workflows/e2e/scripts/setup-cluster.sh
# - name : Cluster info
# run: |
# kubectl cluster-info --context k3d-${{ env.CLUSTER_NAME }}
# kubectl config use-context k3d-${{ env.CLUSTER_NAME }}
# kubectl get nodes -o wide
# - name : Import BRO images
# run : k3d image import ${{ env.REPO }}/rancher/backup-restore-operator:${{ env.TAG}} -c ${{ env.CLUSTER_NAME }}
# - name : e2e test
# run : ./scripts/integration

19 changes: 19 additions & 0 deletions .github/workflows/e2e/scripts/install-k3d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e
set -x

K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION=v5.4.6

install_k3d(){
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}}
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}"
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
}



install_k3d

k3d version
40 changes: 40 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name : Publish Images

on:
push:
tags:
- "*"

env:
REGISTRY: docker.io
REPO : rancher

jobs:
push:
name : Build and push BRO images
runs-on : ubuntu-latest
steps:
- name : Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name : CI
run : make ci
# setup tag name
- if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo TAG_NAME=$(echo $GITHUB_REF | sed -e "s|refs/tags/||") >> $GITHUB_ENV
- name: Build and push BRO image
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO }}/backup-restore-operator:${{ env.TAG_NAME }}
platforms: linux/amd64,linux/arm64
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- id: backup-restore-operator
main: ./main.go
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
binary: backup-restore-operator
ldflags:
- -extldflags
- -static
- -s
flags:
- -trimpath
env:
- CGO_ENABLED=0
# same archives as opentelemetry-collector releases
archives:
- id: backup-restore-operator
builds:
- pushprox-client
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
10 changes: 7 additions & 3 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ ENV K3S_BINARY_amd64=k3s \
K3S_BINARY_arm64=k3s-arm64 \
K3S_BINARY=K3S_BINARY_${ARCH}

ARG K8S_VERSION_FROM_DRONE
ENV K8S_VERSION $K8S_VERSION_FROM_DRONE
ARG K8S_VERSION_FROM_CI
ENV K8S_VERSION $K8S_VERSION_FROM_CI

RUN if [ -z "${K8S_VERSION}" ]; then export K8S_VERSION="v1.24" && echo $(date +%s%N); fi
# ENV K8S_VERSION="${K8S_VERSION_FROM_DRONE:-'v1.24'}"
# ENV K8S_VERSION="${K8S_VERSION_FROM_CI:-'v1.24'}"

RUN echo "${K8S_VERSION}"

Expand All @@ -36,6 +36,10 @@ RUN if [ "${ARCH}" != "s390x" ]; then \
curl -sL https://dl.min.io/client/mc/release/linux-${ARCH}/mc > /usr/local/bin/mc && \
chmod +x /usr/local/bin/mc; \
fi
RUN curl --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.6 K3D_INSTALL_DIR="/usr/local/bin" bash
RUN curl -LO --fail "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl" && \
chmod +x kubectl && \
mv kubectl /usr/local/bin/kubectl

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS CROSS_ARCH USE_DOCKER_BUILDX
ENV DAPPER_SOURCE /go/src/github.com/rancher/backup-restore-operator/
Expand Down
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ const (
)

var (
Version = "v0.0.0-dev"
GitCommit = "HEAD"
version = "v0.0.0-dev"
commit = "HEAD"
date = "1970-01-01T00:00:00Z"
)

var (
LocalBackupStorageLocation = "/var/lib/backups" // local within the pod, this is the mountPath for PVC
KubeConfig string
OperatorPVEnabled string
Expand Down Expand Up @@ -81,7 +85,7 @@ func main() {
logrus.Tracef("Loglevel set to [%v]", logrus.TraceLevel)
}

logrus.Infof("Starting backup-restore controller version %s (%s)", Version, GitCommit)
logrus.Infof("Starting backup-restore controller version %s (%s), built at : %s", version, commit, date)
ctx := signals.SetupSignalContext()
restKubeConfig, err := kubeconfig.GetNonInteractiveClientConfig(KubeConfig).ClientConfig()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ mkdir -p bin
if [ "$(uname)" = "Linux" ]; then
OTHER_LINKFLAGS="-extldflags -static -s"
fi
LINKFLAGS="-X main.Version=$VERSION"
LINKFLAGS="-X main.GitCommit=$COMMIT $LINKFLAGS"

LINKFLAGS="-X main.version=$VERSION"
LINKFLAGS="-X main.commit=$COMMIT $LINKFLAGS"
LINKFLAGS="-X main.date=$DATE $LINKFLAGS"


ARCHES=( "$ARCH" )
Expand Down
5 changes: 5 additions & 0 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ set -e

cd $(dirname $0)

export CLUSTER_NAME="backup-restore-operator"

./build
./test
./validate
./validate-ci
./package
./chart/test
./hull
# integration tests
./cleanup-cluster.sh
./setup-cluster.sh
./integration
4 changes: 4 additions & 0 deletions scripts/cleanup-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e
set -x

k3d cluster delete ${CLUSTER_NAME} || true
Loading

0 comments on commit 167296e

Please sign in to comment.