Skip to content

Commit 84e105e

Browse files
committed
1st commit
0 parents  commit 84e105e

20 files changed

Lines changed: 1141 additions & 0 deletions
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Bug Report
3+
about: Help us diagnose and fix bugs in this Function
4+
labels: bug
5+
---
6+
<!--
7+
Thank you for helping to improve Crossplane!
8+
9+
Please be sure to search for open issues before raising a new one. We use issues
10+
for bug reports and feature requests. Please find us at https://slack.crossplane.io
11+
for questions, support, and discussion.
12+
-->
13+
14+
### What happened?
15+
<!--
16+
Please let us know what behaviour you expected and how this Function diverged
17+
from that behaviour.
18+
-->
19+
20+
21+
### How can we reproduce it?
22+
<!--
23+
Help us to reproduce your bug as succinctly and precisely as possible. Artifacts
24+
such as example manifests or a script that triggers the issue are highly
25+
appreciated!
26+
-->
27+
28+
### What environment did it happen in?
29+
Function version:
30+
31+
<!--
32+
Include at least the version or commit of Crossplane you were running. Consider
33+
also including your:
34+
35+
* Cloud provider or hardware configuration
36+
* Kubernetes version (use `kubectl version`)
37+
* Kubernetes distribution (e.g. Tectonic, GKE, OpenShift)
38+
* OS (e.g. from /etc/os-release)
39+
* Kernel (e.g. `uname -a`)
40+
-->
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Feature Request
3+
about: Help us make this Function more useful
4+
labels: enhancement
5+
---
6+
<!--
7+
Thank you for helping to improve Crossplane!
8+
9+
Please be sure to search for open issues before raising a new one. We use issues
10+
for bug reports and feature requests. Please find us at https://slack.crossplane.io
11+
for questions, support, and discussion.
12+
-->
13+
14+
### What problem are you facing?
15+
<!--
16+
Please tell us a little about your use case - it's okay if it's hypothetical!
17+
Leading with this context helps frame the feature request so we can ensure we
18+
implement it sensibly.
19+
--->
20+
21+
### How could this Function help solve your problem?
22+
<!--
23+
Let us know how you think this Function could help with your use case.
24+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!--
2+
Thank you for helping to improve Crossplane!
3+
4+
Please read through https://git.io/fj2m9 if this is your first time opening a
5+
Crossplane pull request. Find us in https://slack.crossplane.io/messages/dev if
6+
you need any help contributing.
7+
-->
8+
9+
### Description of your changes
10+
11+
<!--
12+
Briefly describe what this pull request does, and how it is covered by tests.
13+
Be proactive - direct your reviewers' attention to anything that needs special
14+
consideration.
15+
16+
You MUST either [x] check or ~strikethrough~ every item in the checklist below.
17+
18+
We love pull requests that fix an open issue. If yours does, use the below line
19+
to indicate which issue it fixes, for example "Fixes #500".
20+
-->
21+
22+
Fixes #
23+
24+
I have:
25+
26+
- [ ] Read and followed Crossplane's [contribution process].
27+
- [ ] Added or updated unit tests for my change.
28+
29+
[contribution process]: https://git.io/fj2m9
30+
[docs]: https://docs.crossplane.io/contribute/contribute

.github/workflows/ci.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
pull_request: {}
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: Package version (e.g. v0.1.0)
13+
required: false
14+
15+
env:
16+
# Common versions
17+
PYTHON_VERSION: '3.11'
18+
HATCH_VERSION: '1.12.0'
19+
DOCKER_BUILDX_VERSION: 'v0.24.0'
20+
21+
# These environment variables are important to the Crossplane CLI install.sh
22+
# script. They determine what version it installs.
23+
XP_CHANNEL: stable
24+
XP_VERSION: v1.20.0
25+
26+
# The package to push, without a version tag. The default matches GitHub. For
27+
# example xpkg.crossplane.io/crossplane/function-template-go. Note that
28+
# xpkg.crossplane.io is just an alias for ghcr.io, so we upload to ghcr.io but
29+
# this'll be pulled from xpkg.crossplane.io.
30+
XPKG: ghcr.io/${{ github.repository}}
31+
32+
# The package version to push. The default is 0.0.0-gitsha.
33+
XPKG_VERSION: ${{ inputs.version }}
34+
35+
jobs:
36+
lint:
37+
runs-on: ubuntu-24.04
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v6
41+
42+
- name: Setup Python
43+
uses: actions/setup-python@v6
44+
with:
45+
python-version: ${{ env.PYTHON_VERSION }}
46+
47+
- name: Setup Hatch
48+
run: pipx install hatch==${{ env.HATCH_VERSION }}
49+
50+
- name: Lint
51+
run: hatch fmt
52+
53+
unit-test:
54+
runs-on: ubuntu-24.04
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v6
58+
59+
- name: Setup Python
60+
uses: actions/setup-python@v6
61+
with:
62+
python-version: ${{ env.PYTHON_VERSION }}
63+
64+
- name: Setup Hatch
65+
run: pipx install hatch==${{ env.HATCH_VERSION }}
66+
67+
- name: Run Unit Tests
68+
run: hatch test --all --randomize
69+
70+
# We want to build most packages for the amd64 and arm64 architectures. To
71+
# speed this up we build single-platform packages in parallel. We then upload
72+
# those packages to GitHub as a build artifact. The push job downloads those
73+
# artifacts and pushes them as a single multi-platform package.
74+
build:
75+
runs-on: ubuntu-24.04
76+
strategy:
77+
fail-fast: true
78+
matrix:
79+
arch:
80+
- amd64
81+
- arm64
82+
steps:
83+
- name: Setup QEMU
84+
uses: docker/setup-qemu-action@v3
85+
with:
86+
platforms: all
87+
88+
- name: Setup Docker Buildx
89+
uses: docker/setup-buildx-action@v3
90+
with:
91+
version: ${{ env.DOCKER_BUILDX_VERSION }}
92+
install: true
93+
94+
- name: Checkout
95+
uses: actions/checkout@v6
96+
97+
# We ask Docker to use GitHub Action's native caching support to speed up
98+
# the build, per https://docs.docker.com/build/cache/backends/gha/.
99+
- name: Build Runtime
100+
id: image
101+
uses: docker/build-push-action@v6
102+
with:
103+
context: .
104+
platforms: linux/${{ matrix.arch }}
105+
cache-from: type=gha
106+
cache-to: type=gha,mode=max
107+
target: image
108+
build-args:
109+
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
110+
outputs: type=docker,dest=runtime-${{ matrix.arch }}.tar
111+
112+
- name: Setup the Crossplane CLI
113+
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"
114+
115+
- name: Build Package
116+
run: ./crossplane xpkg build --package-file=${{ matrix.arch }}.xpkg --package-root=package/ --embed-runtime-image-tarball=runtime-${{ matrix.arch }}.tar
117+
118+
- name: Upload Single-Platform Package
119+
uses: actions/upload-artifact@v6
120+
with:
121+
name: package-${{ matrix.arch }}
122+
path: "*.xpkg"
123+
if-no-files-found: error
124+
retention-days: 1
125+
126+
# This job downloads the single-platform packages built by the build job, and
127+
# pushes them as a multi-platform package.
128+
push:
129+
if: ${{ github.event_name != 'pull_request' }}
130+
runs-on: ubuntu-24.04
131+
needs:
132+
- build
133+
steps:
134+
- name: Checkout
135+
uses: actions/checkout@v6
136+
137+
- name: Download Single-Platform Packages
138+
uses: actions/download-artifact@v7
139+
with:
140+
# See https://github.com/docker/build-push-action/blob/263435/README.md#summaries
141+
pattern: "!*.dockerbuild"
142+
path: .
143+
merge-multiple: true
144+
145+
- name: Setup the Crossplane CLI
146+
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"
147+
148+
- name: Login to GitHub Container Registry
149+
uses: docker/login-action@v3
150+
with:
151+
registry: ghcr.io
152+
username: ${{ github.repository_owner }}
153+
password: ${{ secrets.GITHUB_TOKEN }}
154+
155+
# If a version wasn't explicitly passed as a workflow_dispatch input we
156+
# default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example
157+
# v0.0.0-20231101115142-1091066df799. This is a simple implementation of
158+
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
159+
- name: Set Default Multi-Platform Package Version
160+
if: env.XPKG_VERSION == ''
161+
run: echo "XPKG_VERSION=v0.0.0-$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV
162+
163+
- name: Push Multi-Platform Package to GitHub Container Registry
164+
run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"

0 commit comments

Comments
 (0)