Skip to content

Commit

Permalink
move stuff around
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

some more stuff

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

integration tests in CI

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

do the thing

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

print mc version

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

did not fix path

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

fix mc binary

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

fix things

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

will it work first try?

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

the answer was no

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

check to see if dynamic strategy works

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

does this work?

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

test dynamic strategy matrix again

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

remove platform strategy

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

basic supported versions script

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

try to fix supported versions

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

does the anti pattern work?

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

try fetching history

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

properly echo versions into matrix

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

broken pipe with re-echo

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

do the stupid

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

what

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

update ref

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

no newline echo

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

actually pipe variable into GITHUB_OUTPUT

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

try, and try again

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

let on PR fail

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

save image

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

make sure we load the CI image into the docker ci context

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

remove unused k8s env handling

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>

clean

Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>
  • Loading branch information
alexandreLamarre committed Apr 22, 2024
1 parent 167296e commit 04b8afd
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 181 deletions.
62 changes: 50 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,63 @@ on:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'

pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
jobs:
build:
name : CI
runs-on : ubuntu-latest
outputs:
k3sversions: ${{ steps.support.outputs.k3sversions }}
steps:
- name : Checkout repository
uses : actions/checkout@v4
with :
fetch-depth : 0
- name: Set K3s support output
id : support
run: ./.github/workflows/scripts/supported-versions.sh | awk '{print "k3sversions="$0}' >> $GITHUB_OUTPUT
- name : CI
run : make ci
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bro-build-artifacts
path: ./dist/artifacts

test:
name : integration-test
needs : [
build
]
runs-on : ubuntu-latest
strategy:
matrix:
K8S_VERSION_FROM_CI : ["v1.24","stable"]
include:
- platform: linux/amd64
- platform: linux/arm64
K3S_VERSION : ${{ fromJSON(needs.build.outputs.k3sversions) }}
steps:
- name : Checkout repository
uses : actions/checkout@v4
- name : Fetch build artifacts
uses: actions/download-artifact@v4
with:
name: bro-build-artifacts
path: ./dist/artifacts
- name : Debug
run : ls -R ./dist/artifacts
- 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
uses: docker/setup-buildx-action@v3
- name : Load backup-restore-operator image
run : docker image load -i ./dist/artifacts/backup-restore-operator.img
- name : Setup up K3d
run : ./.github/workflows/scripts/install-k3d.sh
- name : Setup up mc
run : ./.github/workflows/scripts/install-mc.sh
- name : Setup k3d cluster
run : CLUSTER_NAME=backup-restore K3S_VERSION=${{ matrix.K3S_VERSION }} ./.github/workflows/scripts/setup-cluster.sh
- name : Run integration tests
run : ./scripts/integration
52 changes: 0 additions & 52 deletions .github/workflows/e2e-test.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ install_k3d(){
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
}



install_k3d

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

set -e
set -x


# initArch discovers the architecture for this system.
initArch() {
ARCH=$(uname -m)
case $ARCH in
armv7*) ARCH="arm";;
aarch64) ARCH="arm64";;
x86_64) ARCH="amd64";;
esac
}


initArch

curl -sL --fail https://dl.min.io/client/mc/release/linux-${ARCH}/mc > mc;
chmod +x mc;

cp mc /usr/local/bin/mc

mc --version
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

set -e

source $(dirname $0)/version
source ./scripts/version

if [ -z "$CLUSTER_NAME" ]; then
echo "CLUSTER_NAME must be specified when setting up a cluster"
exit 1
fi

if [ -z "$K3S_VERSION" ]; then
echo "K3S_VERSION must be specified when setting up a cluster, use `k3d version list k3s` to find valid versions"
exit 1
fi

# waits until all nodes are ready
wait_for_nodes(){
Expand All @@ -29,8 +39,8 @@ wait_for_nodes(){
done
}

k3d cluster create ${CLUSTER_NAME}

k3d cluster delete ${CLUSTER_NAME} || true
k3d cluster create ${CLUSTER_NAME} --image "docker.io/rancher/k3s:${K3S_VERSION}"

wait_for_nodes

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/scripts/supported-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Prints supported versions based on the current release branch targeted
# Version output is in JSON

set -e
set -x

if git merge-base --is-ancestor origin/release/v5.0 HEAD
then
echo -n "[\"v1.23.9-k3s1\", \"v1.29.3-k3s1\"]"
exit 0
elif git merge-base --is-ancestor origin/release/v4.0 HEAD
then
echo -n "[\"v1.23.9-k3s1\", \"v1.28.8-k3s1\"]"
exit 0
elif git merge-base --is-ancestor origin/release/v3.0 HEAD
then
echo -n "[\"v1.16.9-k3s1\", \"v1.27.9-k3s1\"]"
exit 0
fi


exit 1
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ builds:
- -extldflags
- -static
- -s
- -X main.Version={{.Version}} -X main.GitCommit={{.Commit}}
flags:
- -trimpath
env:
- CGO_ENABLED=0
# same archives as opentelemetry-collector releases
archives:
- id: backup-restore-operator
builds:
Expand Down
23 changes: 0 additions & 23 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,6 @@ RUN if [ "${ARCH}" != "s390x" ]; then \
helm plugin install https://github.com/quintush/helm-unittest; \
fi

ENV K3S_BINARY_amd64=k3s \
K3S_BINARY_arm64=k3s-arm64 \
K3S_BINARY=K3S_BINARY_${ARCH}

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_CI:-'v1.24'}"

RUN echo "${K8S_VERSION}"

RUN curl -sL https://github.com/rancher/k3s/releases/download/$(curl -Ls -o /dev/null -w %{url_effective} https://update.k3s.io/v1-release/channels/${K8S_VERSION} | awk -F/ '{ print $NF }')/${!K3S_BINARY} > /usr/local/bin/k3s && \
chmod +x /usr/local/bin/k3s

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
22 changes: 22 additions & 0 deletions docs/integration-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Integration testing

### Requirements

- [mc](https://min.io/docs/minio/linux/reference/minio-mc.html), a command line client for minio
- [k3d](https://k3d.io/v5.6.3/), a command line tool for managing k3s clusters in docker

See CI install scripts in `./.github/workflows/scripts/`

### Running

Set up a test cluster:

```bash
CLUSTER_NAME="test-cluster" ./.github/workflows/scripts/setup-cluster.sh
```

Run:

```bash
./scripts/integration
```
10 changes: 3 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ const (
)

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

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

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

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


ARCHES=( "$ARCH" )
Expand Down
6 changes: 0 additions & 6 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ 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: 0 additions & 4 deletions scripts/cleanup-cluster.sh

This file was deleted.

Loading

0 comments on commit 04b8afd

Please sign in to comment.