Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove CI dependency on dapper #66

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: ci

env:
CGO_ENABLED: 0
YQ_VERSION: v4.25.1

on: [ pull_request ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : setup Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
- name : Install helm
run : |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version
- name: Perform CI
run : make ci
push-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Export image version
run : |
source ./scripts/version
echo IMAGE=$IMAGE >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Helm Project Operator image
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile
push: false
tags: ${{ env.IMAGE }}
platforms: linux/amd64
44 changes: 15 additions & 29 deletions .github/workflows/e2e-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ on:
- 'Makefile'

env:
GOARCH: amd64
CGO_ENABLED: 0
YQ_VERSION: v4.25.1
E2E_CI: true
Expand All @@ -49,25 +48,21 @@ jobs:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.20.15-k3s1' }}
steps:
-
uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : setup Go
uses : actions/setup-go@v5
with:
go-version: 1.22
-
name: Install mikefarah/yq
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
-
name: Perform CI
- name: Perform CI
run: |
REPO=${REPO} TAG=${TAG} ./scripts/build;
REPO=${REPO} TAG=${TAG} ./scripts/package;
-
name: Provision k3d Cluster
- name: Provision k3d Cluster
uses: AbsaOSS/k3d-action@v2
# k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
with:
Expand All @@ -76,40 +71,31 @@ jobs:
--agents 1
--network "nw01"
--image docker.io/rancher/k3s:${{matrix.k3s_version}}
-
name: Import Images Into k3d
- name: Import Images Into k3d
run: |
k3d image import ${REPO}/helm-project-operator:${TAG} -c e2e-ci-helm-project-operator;
-
name: Setup kubectl context
- name: Setup kubectl context
run: |
kubectl config use-context k3d-e2e-ci-helm-project-operator;
-
name: Set Up Tmate Debug Session
- name: Set Up Tmate Debug Session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
with:
limit-access-to-actor: true
-
name: Install Helm Project Operator
- name: Install Helm Project Operator
run: ./.github/workflows/e2e/scripts/install-helm-project-operator.sh;
-
name: Check if Helm Project Operator is up

- name: Check if Helm Project Operator is up
run: ./.github/workflows/e2e/scripts/validate-helm-project-operator.sh;
-
name: Check if Project Registration Namespace is auto-created on namespace detection
- name: Check if Project Registration Namespace is auto-created on namespace detection
run: ./.github/workflows/e2e/scripts/create-project-namespace.sh;
-
name: Deploy Example Chart via ProjectHelmChart CR
- name: Deploy Example Chart via ProjectHelmChart CR
run: ./.github/workflows/e2e/scripts/create-projecthelmchart.sh;
-
name: Delete Example Chart
- name: Delete Example Chart
run: ./.github/workflows/e2e/scripts/delete-projecthelmchart.sh;
-
name: Uninstall Helm Project Operator
- name: Uninstall Helm Project Operator
run: ./.github/workflows/e2e/scripts/uninstall-helm-project-operator.sh;
-
name: Delete k3d cluster
- name: Delete k3d cluster
if: always()
run: k3d cluster delete e2e-ci-helm-project-operator
13 changes: 0 additions & 13 deletions .github/workflows/pull-request.yaml

This file was deleted.

13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
TARGETS := $(shell ls scripts)

.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/latest/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper

$(TARGETS): .dapper
./.dapper $@
$(TARGETS):
./scripts/$@

.DEFAULT_GOAL := default

.PHONY: $(TARGETS)
.PHONY: $(TARGETS)
22 changes: 20 additions & 2 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
FROM registry.suse.com/bci/bci-micro:15.4
FROM registry.suse.com/bci/golang:1.22 AS helm
RUN zypper -n install git
RUN git -C / clone --branch release-v3.9.0 --depth=1 https://github.com/rancher/helm
RUN make -C /helm

FROM registry.suse.com/bci/golang:1.22 as builder
WORKDIR /usr/src/app
ENV YQ_VERSION=v4.25.1
RUN zypper -n install git curl wget make
RUN export ARCH=$(go env GOHOSTARCH)
RUN wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq;
COPY --from=helm ./helm/bin/helm /usr/local/bin/
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build-chart
RUN make build

FROM registry.suse.com/bci/bci-micro:15.5
RUN echo 'helmprojectoperator:x:1000:1000::/home/helmprojectoperator:/bin/bash' >> /etc/passwd && \
echo 'helmprojectoperator:x:1000:' >> /etc/group && \
mkdir /home/helmprojectoperator && \
chown -R helmprojectoperator:helmprojectoperator /home/helmprojectoperator
COPY bin/helm-project-operator /usr/bin/
COPY --from=builder /usr/src/app/bin/helm-project-operator /usr/bin/
USER helmprojectoperator
CMD ["helm-project-operator"]
10 changes: 1 addition & 9 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ set -e
source $(dirname $0)/version

cd $(dirname $0)/..

mkdir -p dist/artifacts
cp bin/helm-project-operator dist/artifacts/helm-project-operator${SUFFIX}

IMAGE=${REPO}/helm-project-operator:${TAG}
echo Building ${IMAGE} ...
DOCKERFILE=package/Dockerfile
if [ -e ${DOCKERFILE}.${ARCH} ]; then
DOCKERFILE=${DOCKERFILE}.${ARCH}
fi

docker build -f ${DOCKERFILE} -t ${IMAGE} .
echo Built ${IMAGE}
9 changes: 2 additions & 7 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ else
VERSION="${COMMIT}${DIRTY}"
fi

if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi

SUFFIX="-${ARCH}"

TAG=${TAG:-${VERSION}${SUFFIX}}
TAG=${TAG:-${VERSION}}
REPO=${REPO:-rancher}

if echo $TAG | grep -q dirty; then
TAG=dev
fi
IMAGE=${IMAGE:-${REPO}/helm-project-operator:${TAG}}