Skip to content

Commit

Permalink
Merge pull request #63 from hasheddan/bundle-and-to-crossplanecontrib
Browse files Browse the repository at this point in the history
Update to Go 1.18, use bundled images, and push to xpkg.upbound.io
  • Loading branch information
ADustyOldMuffin committed Oct 9, 2022
2 parents a4257b6 + 788577c commit be2a1f0
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 167 deletions.
52 changes: 23 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ on:

env:
# Common versions
GO_VERSION: '1.17'
GOLANGCI_VERSION: 'v1.45.2'
DOCKER_BUILDX_VERSION: 'v0.4.2'
GO_VERSION: '1.18'
GOLANGCI_VERSION: 'v1.47.1'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
DOCKER_USR: ${{ secrets.DOCKER_USR }}
AWS_USR: ${{ secrets.AWS_USR }}
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}

jobs:
detect-noop:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
Expand All @@ -36,7 +35,7 @@ jobs:


lint:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand All @@ -46,6 +45,11 @@ jobs:
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go
run: echo "::set-output name=cache::$(make go.cachedir)"
Expand Down Expand Up @@ -77,7 +81,7 @@ jobs:
version: ${{ env.GOLANGCI_VERSION }}

check-diff:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -117,7 +121,7 @@ jobs:
run: make check-diff

unit-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -166,7 +170,7 @@ jobs:
file: _output/tests/linux_amd64/coverage.txt

e2e-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -228,7 +232,7 @@ jobs:
run: make e2e USE_HELM3=true

publish-artifacts:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -290,28 +294,18 @@ jobs:
with:
name: output
path: _output/**
- name: Login to Docker

- name: Login to Upbound
uses: docker/login-action@v1
if: env.DOCKER_USR != ''
if: env.XPKG_ACCESS_ID != ''
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PSW }}
registry: xpkg.upbound.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Publish Artifacts to S3 and Docker Hub
- name: Publish Artifacts to Upbound
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.AWS_USR != '' && env.DOCKER_USR != ''
if: env.CONTRIB_DOCKER_USR != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Promote Artifacts in S3 and Docker Hub
if: github.ref == 'refs/heads/main' && env.AWS_USR != '' && env.DOCKER_USR != ''
run: make -j2 promote
env:
BRANCH_NAME: main
CHANNEL: main
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}

48 changes: 0 additions & 48 deletions .github/workflows/promote.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
create-tag:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Checkout
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,30 @@ GO111MODULE = on
# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.13.0
UP_CHANNEL = stable
-include build/makelib/k8s_tools.mk

# ====================================================================================
# Setup Images

REGISTRY_ORGS = docker.io/crossplane
IMAGES = provider-digitalocean provider-digitalocean-controller
IMAGES = provider-digitalocean
-include build/makelib/imagelight.mk

# ====================================================================================
# Setup XPKG

XPKG_REG_ORGS ?= xpkg.upbound.io/digitalocean
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/digitalocean
XPKGS = provider-digitalocean
-include build/makelib/xpkg.mk

# NOTE(hasheddan): we force image building to happen prior to xpkg build so that
# we ensure image is present in daemon.
xpkg.build.provider-digitalocean: do.build.images

# ====================================================================================
# Targets

Expand Down Expand Up @@ -107,6 +122,11 @@ submodules:
go.cachedir:
@go env GOCACHE

# NOTE(hasheddan): we must ensure up is installed in tool cache prior to build
# as including the k8s_tools machinery prior to the xpkg machinery sets UP to
# point to tool cache.
build.init: $(UP)

# This is for running out-of-cluster locally, and is for convenience. Running
# this make target will print out the command which was used. For more control,
# try running the binary directly with different arguments.
Expand Down
10 changes: 0 additions & 10 deletions cluster/images/provider-digitalocean-controller/Dockerfile

This file was deleted.

35 changes: 0 additions & 35 deletions cluster/images/provider-digitalocean-controller/Makefile

This file was deleted.

11 changes: 9 additions & 2 deletions cluster/images/provider-digitalocean/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
FROM scratch
FROM gcr.io/distroless/static@sha256:d2b0ec3141031720cf5eedef3493b8e129bc91935a43b50562fbe5429878d96b

COPY package.yaml .
ARG TARGETOS
ARG TARGETARCH

ADD bin/$TARGETOS\_$TARGETARCH/provider /usr/local/bin/crossplane-digitalocean-provider

EXPOSE 8080
USER 65532
ENTRYPOINT ["crossplane-digitalocean-provider"]
10 changes: 4 additions & 6 deletions cluster/images/provider-digitalocean/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ img.build:
@$(OK) docker build $(IMAGE)

img.publish:
@$(INFO) docker publish $(IMAGE)
@$(MAKE) BUILD_ARGS="--push" img.build.shared
@$(OK) docker publish $(IMAGE)
@$(INFO) Skipping image publish for $(IMAGE)
@echo Publish is deferred to xpkg machinery
@$(OK) Image publish skipped for $(IMAGE)

img.build.shared:
@cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL)
@cp -R ../../../package $(IMAGE_TEMP_DIR) || $(FAIL)
@cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|VERSION|$(VERSION)|g' package/crossplane.yaml || $(FAIL)
@cd $(IMAGE_TEMP_DIR) && find package -type f -name '*.yaml' -exec cat {} >> 'package.yaml' \; -exec printf '\n---\n' \; || $(FAIL)
@cp -r $(OUTPUT_DIR)/bin/ $(IMAGE_TEMP_DIR)/bin || $(FAIL)
@docker buildx build $(BUILD_ARGS) \
--platform $(IMAGE_PLATFORMS) \
-t $(IMAGE) \
Expand Down
12 changes: 4 additions & 8 deletions cluster/local/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ eval $(make --no-print-directory -C ${projectdir} build.vars)
# ------------------------------

SAFEHOSTARCH="${SAFEHOSTARCH:-amd64}"
BUILD_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}"
PACKAGE_IMAGE="crossplane.io/inttests/${PROJECT_NAME}:${VERSION}"
CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}"
CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}"

version_tag="$(cat ${projectdir}/_output/version)"
# tag as latest version to load into kind cluster
PACKAGE_CONTROLLER_IMAGE="crossplane/${PROJECT_NAME}-controller:${VERSION}"
K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}"

CROSSPLANE_NAMESPACE="crossplane-system"
Expand All @@ -69,8 +66,7 @@ echo_step "setting up local package cache"
CACHE_PATH="${projectdir}/.work/inttest-package-cache"
mkdir -p "${CACHE_PATH}"
echo "created cache dir at ${CACHE_PATH}"
docker tag "${BUILD_IMAGE}" "${PACKAGE_IMAGE}"
"${UP}" xpkg xp-extract --from-daemon "${PACKAGE_IMAGE}" -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz"
"${UP}" alpha xpkg xp-extract --from-xpkg "${OUTPUT_DIR}"/xpkg/"${HOSTOS}"_"${SAFEHOSTARCH}"/"${PACKAGE_NAME}"-"${VERSION}".xpkg -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz"

# create kind cluster with extra mounts
KIND_NODE_IMAGE="kindest/node:${KIND_NODE_IMAGE_TAG}"
Expand All @@ -88,8 +84,8 @@ EOF
echo "${KIND_CONFIG}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --wait=5m --image="${KIND_NODE_IMAGE}" --config=-

# tag controller image and load it into kind cluster
docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_CONTROLLER_IMAGE}"
"${KIND}" load docker-image "${PACKAGE_CONTROLLER_IMAGE}" --name="${K8S_CLUSTER}"
docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_NAME}"
"${KIND}" load docker-image "${PACKAGE_NAME}" --name="${K8S_CLUSTER}"

echo_step "create crossplane-system namespace"
"${KUBECTL}" create ns crossplane-system
Expand Down
Loading

0 comments on commit be2a1f0

Please sign in to comment.