Skip to content

Commit b31e35e

Browse files
authored
Merge pull request #15 from upbound/feature/more-tests
feat(tests): add more tests for python and adopt new folder structure , add ci
2 parents 78164e8 + 0be08f5 commit b31e35e

File tree

17 files changed

+320
-38
lines changed

17 files changed

+320
-38
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Composition Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request: {}
8+
9+
jobs:
10+
composition-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
id: checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install up
18+
uses: upbound/action-up@v1
19+
with:
20+
skip-login: true
21+
22+
- name: Build project
23+
run: up project build
24+
25+
- name: Run composition tests
26+
run: up test run tests/*

.github/workflows/e2e.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: End to End Testing
2+
3+
on:
4+
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
5+
# pull_request_target is potentially dangerous target so we keep it strict
6+
# under the label and benefit from secret propagation
7+
pull_request_target:
8+
types:
9+
- synchronize
10+
- labeled
11+
12+
env:
13+
UP_API_TOKEN: ${{ secrets.UP_API_TOKEN }}
14+
UP_ORG: ${{ secrets.UP_ORG }}
15+
16+
jobs:
17+
e2e:
18+
if: contains(github.event.pull_request.labels.*.name, 'run-e2e-tests')
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
id: checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install and login with up
26+
if: env.UP_API_TOKEN != '' && env.UP_ORG != ''
27+
uses: upbound/action-up@v1
28+
with:
29+
api-token: ${{ secrets.UP_API_TOKEN }}
30+
organization: ${{ secrets.UP_ORG }}
31+
32+
- name: Build project
33+
run: up project build
34+
35+
- name: Switch up context
36+
if: env.UP_API_TOKEN != '' && env.UP_ORG != ''
37+
run: up ctx ${{ secrets.UP_ORG }}/upbound-gcp-us-central-1/default
38+
39+
- name: Run e2e tests
40+
if: env.UP_API_TOKEN != '' && env.UP_ORG != ''
41+
run: up test run tests/* --e2e

.github/workflows/tag.yaml

Lines changed: 26 additions & 0 deletions
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-24.04
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 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 }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "e2etest-xstoragebucket"
3+
version = "0.0.1"
4+
5+
[dependencies]
6+
models = { path = "./model" }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[dependencies]
2+
[dependencies.model]
3+
name = "model"
4+
full_name = "models_0.0.1"
5+
version = "0.0.1"
6+
reg = "ghcr.io"
7+
repo = "kcl-lang/model"
8+
oci_tag = "0.0.1"
9+
[dependencies.models]
10+
name = "models"
11+
full_name = "models_0.0.1"
12+
version = "0.0.1"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import models.com.example.platform.v1alpha1 as platformv1alpha1
2+
import models.io.upbound.aws.v1beta1 as awsv1beta1
3+
import models.io.upbound.dev.meta.v1alpha1 as metav1alpha1
4+
5+
_items = [
6+
metav1alpha1.E2ETest{
7+
metadata.name = "e2etest-xstoragebucket-kcl"
8+
spec = {
9+
crossplane = {
10+
version="1.18.3-up.1"
11+
autoUpgrade = {
12+
channel= "None"
13+
}
14+
}
15+
defaultConditions = [
16+
"Ready"
17+
]
18+
manifests = [
19+
platformv1alpha1.XStorageBucket{
20+
metadata.name = "uptest-bucket-xr"
21+
spec.parameters = {
22+
acl = "private"
23+
region = "eu-central-1"
24+
versioning: True
25+
}
26+
}
27+
]
28+
extraResources = [
29+
awsv1beta1.ProviderConfig{
30+
metadata.name = "default"
31+
spec.credentials = {
32+
source = "Upbound"
33+
upbound.webIdentity = {
34+
roleARN = "arn:aws:iam::609897127049:role/example-project-aws-uptest"
35+
}
36+
}
37+
}
38+
]
39+
skipDelete = False
40+
timeoutSeconds = 4500
41+
}
42+
}
43+
]
44+
items = _items
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.up/kcl/models
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from .model.io.upbound.dev.meta.e2etest import v1alpha1 as e2etest
2+
from .model.io.k8s.apimachinery.pkg.apis.meta import v1 as k8s
3+
from .model.com.example.platform.xstoragebucket import v1alpha1 as xstoragebucket
4+
from .model.io.upbound.aws.providerconfig import v1beta1 as providerconfig
5+
6+
bucket_manifest = xstoragebucket.XStorageBucket(
7+
metadata=k8s.ObjectMeta(
8+
name="uptest-bucket-xr",
9+
),
10+
spec=xstoragebucket.Spec(
11+
parameters=xstoragebucket.Parameters(
12+
acl="private",
13+
region="eu-central-1",
14+
versioning=True,
15+
),
16+
),
17+
)
18+
19+
provider_config = providerconfig.ProviderConfig(
20+
metadata=k8s.ObjectMeta(
21+
name="default",
22+
),
23+
spec=providerconfig.Spec(
24+
credentials=providerconfig.Credentials(
25+
source="Upbound",
26+
upbound=providerconfig.Upbound(
27+
webIdentity=providerconfig.WebIdentity(
28+
roleARN="arn:aws:iam::609897127049:role/example-project-aws-uptest",
29+
),
30+
),
31+
),
32+
),
33+
)
34+
35+
test = e2etest.E2ETest(
36+
metadata=k8s.ObjectMeta(
37+
name="e2etest-xstoragebucket-python",
38+
),
39+
spec=e2etest.Spec(
40+
crossplane=e2etest.Crossplane(
41+
autoUpgrade=e2etest.AutoUpgrade(
42+
channel=e2etest.Channel.None_,
43+
),
44+
version="1.18.3-up.1",
45+
),
46+
defaultConditions=[
47+
"Ready",
48+
],
49+
manifests=[bucket_manifest.model_dump()],
50+
extraResources=[provider_config.model_dump()],
51+
skipDelete=False,
52+
timeoutSeconds=4500,
53+
)
54+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.up/python/models
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydantic==2.10.6

0 commit comments

Comments
 (0)