Skip to content

Commit ea8b055

Browse files
authored
feat(e2e): add e2e workflows, uptest and fix exmaples (#1)
* feat(e2e): add e2e workflows, uptest and fix exmaples Signed-off-by: Christopher Haar <[email protected]> * style(lint): add lint, render stuff Signed-off-by: Christopher Haar <[email protected]> --------- Signed-off-by: Christopher Haar <[email protected]>
1 parent b6de1e6 commit ea8b055

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1045
-695
lines changed

.github/renovate.json5

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended",
5+
"helpers:pinGitHubActionDigests",
6+
":semanticCommits"
7+
],
8+
"rebaseWhen": "conflicted",
9+
"prConcurrentLimit": 5,
10+
"baseBranches": ["main"],
11+
"labels": ["automated"],
12+
"customManagers": [
13+
{
14+
"customType": "regex",
15+
"description": "Bump up version in the Makefile",
16+
"fileMatch": ["^Makefile$"],
17+
"matchStrings": [
18+
"UP_VERSION = (?<currentValue>.*?)\\n"
19+
],
20+
"datasourceTemplate": "github-releases",
21+
"depNameTemplate": "upbound/up",
22+
}, {
23+
"customType": "regex",
24+
"description": "Bump uptest version in the Makefile",
25+
"fileMatch": ["^Makefile$"],
26+
"matchStrings": [
27+
"UPTEST_VERSION = (?<currentValue>.*?)\\n"
28+
],
29+
"datasourceTemplate": "github-releases",
30+
"depNameTemplate": "upbound/uptest",
31+
}, {
32+
"customType": "regex",
33+
"description": "Bump providers/functions/configurations in crossplane.yaml",
34+
"fileMatch": ["crossplane.yaml"],
35+
"matchStrings": [
36+
"#\\s*renovate:\\s*datasource=(?<datasource>[^\\s]+)\\s+depName=(?<depName>[^\\s]+)\\s*\\n\\s*version:\\s*\"(?<currentValue>[^\"]+)\""
37+
],
38+
"datasourceTemplate": "{{{datasource}}}",
39+
"depNameTemplate": "{{{depName}}}",
40+
}
41+
],
42+
}

.github/workflows/ci.yaml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
workflow_dispatch: {}
9+
10+
env:
11+
DOCKER_BUILDX_VERSION: 'v0.8.2'
12+
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
13+
14+
jobs:
15+
detect-noop:
16+
runs-on: ubuntu-22.04
17+
outputs:
18+
noop: ${{ steps.noop.outputs.should_skip }}
19+
steps:
20+
- name: Detect No-op Changes
21+
id: noop
22+
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
paths_ignore: '["**.md", "**.png", "**.jpg"]'
26+
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
27+
28+
publish-artifacts:
29+
runs-on: ubuntu-22.04
30+
needs: detect-noop
31+
if: needs.detect-noop.outputs.noop != 'true'
32+
33+
steps:
34+
- name: Setup QEMU
35+
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3
36+
with:
37+
platforms: all
38+
39+
- name: Setup Docker Buildx
40+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
41+
with:
42+
version: ${{ env.DOCKER_BUILDX_VERSION }}
43+
install: true
44+
45+
- name: Checkout
46+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
47+
with:
48+
submodules: true
49+
50+
- name: Fetch History
51+
run: git fetch --prune --unshallow
52+
53+
- name: Build Artifacts
54+
run: make -j2 build.all
55+
env:
56+
# We're using docker buildx, which doesn't actually load the images it
57+
# builds by default. Specifying --load does so.
58+
BUILD_ARGS: "--load"
59+
60+
- name: Publish Artifacts to GitHub
61+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
62+
with:
63+
name: output
64+
path: _output/**
65+
66+
- name: Login to Upbound
67+
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
68+
if: env.XPKG_ACCESS_ID != ''
69+
with:
70+
registry: xpkg.upbound.io
71+
username: ${{ secrets.XPKG_ACCESS_ID }}
72+
password: ${{ secrets.XPKG_TOKEN }}
73+
74+
- name: Publish Artifacts
75+
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}

.github/workflows/e2e.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: End to End Testing
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
e2e:
9+
uses: upbound/official-providers-ci/.github/workflows/pr-comment-trigger.yml@main
10+
with:
11+
package-type: configuration
12+
secrets:
13+
UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }}
14+
UPTEST_DATASOURCE: ${{ secrets.UPTEST_DATASOURCE }}

.github/workflows/tag.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g. v0.1.0)'
8+
required: true
9+
message:
10+
description: 'Tag message'
11+
required: true
12+
13+
jobs:
14+
create-tag:
15+
runs-on: ubuntu-22.04
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
20+
21+
- name: Create Tag
22+
uses: negz/create-tag@39bae1e0932567a58c20dea5a1a0d18358503320 # v1
23+
with:
24+
version: ${{ github.event.inputs.version }}
25+
message: ${{ github.event.inputs.message }}
26+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/yamllint.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: yamllint
2+
on: [pull_request]
3+
jobs:
4+
yamllint:
5+
name: runner / yamllint
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
9+
- name: yamllint
10+
uses: reviewdog/action-yamllint@8d79c3d034667db2792e328936811ed44953d691 # v1.14.0
11+
with:
12+
reporter: github-pr-review
13+
filter_mode: nofilter
14+
yamllint_flags: 'apis/'
15+
fail_on_error: true

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.cache
2+
/.work
3+
/_output
4+
/results
5+
/.idea
6+
7+
*.xpkg
8+
kubeconfig

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "build"]
2+
path = build
3+
url = https://github.com/upbound/build

.yamllint

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extends: default
2+
3+
rules:
4+
line-length: disable
5+
document-start: disable

Makefile

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Project Setup
2+
PROJECT_NAME := configuration-getting-started
3+
PROJECT_REPO := github.com/upbound/$(PROJECT_NAME)
4+
5+
# NOTE(hasheddan): the platform is insignificant here as Configuration package
6+
# images are not architecture-specific. We constrain to one platform to avoid
7+
# needlessly pushing a multi-arch image.
8+
PLATFORMS ?= linux_amd64
9+
-include build/makelib/common.mk
10+
11+
# ====================================================================================
12+
# Setup Kubernetes tools
13+
14+
UP_VERSION = v0.30.0
15+
UP_CHANNEL = stable
16+
UPTEST_VERSION = v0.11.1
17+
18+
-include build/makelib/k8s_tools.mk
19+
# ====================================================================================
20+
# Setup XPKG
21+
XPKG_DIR = $(shell pwd)
22+
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml
23+
XPKG_REG_ORGS ?= xpkg.upbound.io/upbound
24+
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
25+
# inferred.
26+
XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/upbound
27+
XPKGS = $(PROJECT_NAME)
28+
-include build/makelib/xpkg.mk
29+
30+
CROSSPLANE_NAMESPACE = upbound-system
31+
CROSSPLANE_ARGS = "--enable-usages"
32+
-include build/makelib/local.xpkg.mk
33+
-include build/makelib/controlplane.mk
34+
35+
# ====================================================================================
36+
# Targets
37+
38+
# run `make help` to see the targets and options
39+
40+
# We want submodules to be set up the first time `make` is run.
41+
# We manage the build/ folder and its Makefiles as a submodule.
42+
# The first time `make` is run, the includes of build/*.mk files will
43+
# all fail, and this target will be run. The next time, the default as defined
44+
# by the includes will be run instead.
45+
fallthrough: submodules
46+
@echo Initial setup complete. Running make again . . .
47+
@make
48+
49+
# Update the submodules, such as the common build scripts.
50+
submodules:
51+
@git submodule sync
52+
@git submodule update --init --recursive
53+
54+
# We must ensure up is installed in tool cache prior to build as including the k8s_tools machinery prior to the xpkg
55+
# machinery sets UP to point to tool cache.
56+
build.init: $(UP)
57+
58+
# ====================================================================================
59+
# End to End Testing
60+
61+
# This target requires the following environment variables to be set:
62+
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
63+
# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately.
64+
# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl.
65+
# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
66+
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
67+
@$(INFO) running automated tests
68+
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/XAccountScaffold/xr.yaml,examples/XCluster/xr.yaml,examples/XCompositeCluster/xr.yaml,examples/XDatabase/xr.yaml,examples/XNetwork/xr.yaml,examples/XNodePool/xr.yaml,examples/XServiceAccount/xr.yaml,examples/XSubnetwork/xr.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
69+
@$(OK) running automated tests
70+
71+
# This target requires the following environment variables to be set:
72+
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
73+
e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest
74+
75+
render:
76+
@indir="./examples"; \
77+
for file in $$(find $$indir -type f -name '*.yaml' ); do \
78+
doc_count=$$(grep -c '^---' "$$file"); \
79+
if [[ $$doc_count -gt 0 ]]; then \
80+
continue; \
81+
fi; \
82+
COMPOSITION=$$(yq eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \
83+
FUNCTION=$$(yq eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \
84+
if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \
85+
continue; \
86+
fi; \
87+
crossplane beta render $$file $$COMPOSITION $$FUNCTION -x -r; \
88+
done
89+
90+
yamllint:
91+
@$(INFO) running yamllint
92+
@yamllint ./apis || $(FAIL)
93+
@$(OK) running yamllint
94+
95+
.PHONY: uptest e2e render yamllint

apis/composition-basics/XAccountScaffold/composition.yaml

+47-46
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,50 @@ spec:
88
kind: XAccountScaffold
99
mode: Pipeline
1010
pipeline:
11-
- step: compose
12-
functionRef:
13-
name: crossplane-contrib-function-kcl
14-
input:
15-
apiVersion: krm.kcl.dev/v1alpha1
16-
kind: KCLRun
17-
metadata:
18-
name: compose-account-scaffold
19-
spec:
20-
target: Resources
21-
params:
22-
name: "input-instance"
23-
source: |
24-
oxr = option("params").oxr
25-
items = [{
26-
apiVersion: "platform.acme.co/v1alpha1"
27-
kind: "XServiceAccount"
28-
metadata.name = "{}-sa".format(oxr.metadata.name)
29-
spec.parameters = {
30-
displayName: oxr.spec.parameters.name
31-
}
32-
}, {
33-
apiVersion: "platform.acme.co/v1alpha1"
34-
kind: "XNetwork"
35-
metadata.name = "{}-net".format(oxr.metadata.name)
36-
spec.parameters = {
37-
autoCreateSubnetworks: True
38-
routingMode: "GLOBAL"
39-
}
40-
}, {
41-
apiVersion: "platform.acme.co/v1alpha1"
42-
kind: "XSubnetwork"
43-
metadata.name = "{}-subnet".format(oxr.metadata.name)
44-
spec.parameters = {
45-
ipCidrRange: "10.2.0.0/16"
46-
networkRef.name: "{}-net".format(oxr.metadata.name)
47-
region: "us-central1"
48-
secondaryIpRange = [{
49-
ipCidrRange: "192.168.10.0/24"
50-
rangeName: "test-secondary-range-update1"
51-
}]
52-
}
53-
}]
54-
- step: automatically-detect-ready-composed-resources
55-
functionRef:
56-
name: crossplane-contrib-function-auto-ready
11+
- step: compose
12+
functionRef:
13+
name: crossplane-contrib-function-kcl
14+
input:
15+
apiVersion: krm.kcl.dev/v1alpha1
16+
kind: KCLRun
17+
metadata:
18+
name: compose-account-scaffold
19+
spec:
20+
target: Resources
21+
params:
22+
name: "input-instance"
23+
source: |
24+
oxr = option("params").oxr
25+
items = [{
26+
apiVersion: "platform.acme.co/v1alpha1"
27+
kind: "XServiceAccount"
28+
metadata.name = "{}-sa".format(oxr.metadata.name)
29+
spec.parameters = {
30+
displayName: oxr.spec.parameters.name
31+
}
32+
}, {
33+
apiVersion: "platform.acme.co/v1alpha1"
34+
kind: "XNetwork"
35+
metadata.name = "{}-net".format(oxr.metadata.name)
36+
spec.parameters = {
37+
autoCreateSubnetworks: True
38+
routingMode: "GLOBAL"
39+
}
40+
}, {
41+
apiVersion: "platform.acme.co/v1alpha1"
42+
kind: "XSubnetwork"
43+
metadata.name = "{}-subnet".format(oxr.metadata.name)
44+
spec.parameters = {
45+
ipCidrRange: "10.2.0.0/16"
46+
networkRef.name: "{}-net".format(oxr.metadata.name)
47+
region: "us-central1"
48+
secondaryIpRange = [{
49+
ipCidrRange: "192.168.10.0/24"
50+
rangeName: "test-secondary-range-update1"
51+
}]
52+
}
53+
}]
54+
55+
- step: automatically-detect-ready-composed-resources
56+
functionRef:
57+
name: crossplane-contrib-function-auto-ready

0 commit comments

Comments
 (0)