Skip to content

Commit

Permalink
Ref #3023: Add native compilation with sources
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo committed Feb 3, 2023
1 parent fe7e1ef commit 8f5d4fa
Show file tree
Hide file tree
Showing 31 changed files with 744 additions and 55 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

name: native

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
pull_request:
branches:
- main
- "release-*"
paths-ignore:
- 'docs/**'
- 'proposals/**'
- '**.adoc'
- '**.md'
- 'KEYS'
- 'LICENSE'
- 'NOTICE'
push:
branches:
- main
- "release-*"
paths-ignore:
- 'docs/**'
- 'proposals/**'
- '**.adoc'
- '**.md'
- 'KEYS'
- 'LICENSE'
- 'NOTICE'
workflow_dispatch:
inputs:
log-level:
description: 'Set the operator log level (info or debug)'
required: false
pre-built-kamel-image:
description: 'Kamel image url for skipping building of kamel stages. Used for debugging'
required: false
skip-problematic:
description: 'Whether tests marked as problematic should be skipped - false by default (sets CAMEL_K_TEST_SKIP_PROBLEMATIC)'
required: false
default: false
test-filters:
description: |
Filter the tests in this test suite by assigning the test pattern to TEST_NATIVE_RUN,
eg. TEST_NATIVE_RUN=TestBasic will only run tests prefixed with 'TestBasic'
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
install-native:

runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
persist-credentials: false
submodules: recursive
- name: Convert input parameters to env vars
shell: bash
run: |
./.github/workflows/manual-exec-process-inputs.sh \
-i "${{ github.event.inputs.pre-built-kamel-image }}" \
-p "${{ github.event.inputs.skip-problematic }}" \
-q "${{ github.event.inputs.log-level }}" \
-t "${{ github.event.inputs.test-filters }}"
- name: Native smoke tests
uses: ./.github/actions/e2e-install-native
with:
cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }}
cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }}
61 changes: 61 additions & 0 deletions config/crd/bases/camel.apache.org_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,67 @@ spec:
- provider
- version
type: object
sources:
description: the sources to add at build time
items:
description: SourceSpec defines the configuration for
one or more routes to be executed in a certain Camel
DSL language
properties:
compression:
description: if the content is compressed (base64
encrypted)
type: boolean
content:
description: the source code (plain text)
type: string
contentKey:
description: the confimap key holding the source content
type: string
contentRef:
description: the confimap reference holding the source
content
type: string
contentType:
description: the content type (tipically text or binary)
type: string
interceptors:
description: Interceptors are optional identifiers
the org.apache.camel.k.RoutesLoader uses to pre/post
process sources
items:
type: string
type: array
language:
description: specify which is the language (Camel
DSL) used to interpret this source code
type: string
loader:
description: Loader is an optional id of the org.apache.camel.k.RoutesLoader
that will interpret this source at runtime
type: string
name:
description: the name of the specification
type: string
path:
description: the path where the file is stored
type: string
property-names:
description: List of property names defined in the
source (e.g. if type is "template")
items:
type: string
type: array
rawContent:
description: the source code (binary)
format: byte
type: string
type:
description: Type defines the kind of source described
by this object
type: string
type: object
type: array
steps:
description: the list of steps to execute (see pkg/builder/)
items:
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/camel.apache.org_camelcatalogs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ spec:
items:
type: string
type: array
metadata:
additionalProperties:
type: string
description: the metadata of the loader
type: object
version:
description: Maven Version
type: string
Expand Down
57 changes: 57 additions & 0 deletions config/crd/bases/camel.apache.org_integrationkits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,63 @@ spec:
items:
type: string
type: array
sources:
description: the sources to add at build time
items:
description: SourceSpec defines the configuration for one or more
routes to be executed in a certain Camel DSL language
properties:
compression:
description: if the content is compressed (base64 encrypted)
type: boolean
content:
description: the source code (plain text)
type: string
contentKey:
description: the confimap key holding the source content
type: string
contentRef:
description: the confimap reference holding the source content
type: string
contentType:
description: the content type (tipically text or binary)
type: string
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
items:
type: string
type: array
language:
description: specify which is the language (Camel DSL) used
to interpret this source code
type: string
loader:
description: Loader is an optional id of the org.apache.camel.k.RoutesLoader
that will interpret this source at runtime
type: string
name:
description: the name of the specification
type: string
path:
description: the path where the file is stored
type: string
property-names:
description: List of property names defined in the source (e.g.
if type is "template")
items:
type: string
type: array
rawContent:
description: the source code (binary)
format: byte
type: string
type:
description: Type defines the kind of source described by this
object
type: string
type: object
type: array
traits:
description: traits that the kit will execute
properties:
Expand Down
31 changes: 26 additions & 5 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ string
workspace directory to use
|`sources` +
*xref:#_camel_apache_org_v1_SourceSpec[[\]SourceSpec]*
|
the sources to add at build time
|===
Expand Down Expand Up @@ -873,6 +880,13 @@ a list of DSLs supported
a list of additional dependencies required beside the base one
|`metadata` +
map[string]string
|
the metadata of the loader
|===
Expand Down Expand Up @@ -1491,6 +1505,13 @@ configuration used by the kit
Maven repositories that can be used by the kit
|`sources` +
*xref:#_camel_apache_org_v1_SourceSpec[[\]SourceSpec]*
|
the sources to add at build time
|===
Expand Down Expand Up @@ -3107,6 +3128,8 @@ string
*Appears on:*
* <<#_camel_apache_org_v1_BuilderTask, BuilderTask>>
* <<#_camel_apache_org_v1_IntegrationKitSpec, IntegrationKitSpec>>
* <<#_camel_apache_org_v1_IntegrationSpec, IntegrationSpec>>
* <<#_camel_apache_org_v1_IntegrationStatus, IntegrationStatus>>
Expand Down Expand Up @@ -5406,11 +5429,9 @@ The Quarkus trait configures the Quarkus runtime.
It's enabled by default.
NOTE: Compiling to a native executable, i.e. when using `package-type=native`, is only supported
for kamelets, as well as YAML and XML integrations.
It also requires at least 4GiB of memory, so the Pod running the native build, that is either
the operator Pod, or the build Pod (depending on the build strategy configured for the platform),
must have enough memory available.
NOTE: Compiling to a native executable, i.e. when using `package-type=native`, requires at least
4GiB of memory, so the Pod running the native build, that is either the operator Pod, or the build
Pod (depending on the build strategy configured for the platform), must have enough memory available.
[cols="2,2a",options="header"]
Expand Down
8 changes: 3 additions & 5 deletions docs/modules/traits/pages/quarkus.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ The Quarkus trait configures the Quarkus runtime.

It's enabled by default.

NOTE: Compiling to a native executable, i.e. when using `package-type=native`, is only supported
for kamelets, as well as YAML and XML integrations.
It also requires at least 4GiB of memory, so the Pod running the native build, that is either
the operator Pod, or the build Pod (depending on the build strategy configured for the platform),
must have enough memory available.
NOTE: Compiling to a native executable, i.e. when using `package-type=native`, requires at least
4GiB of memory, so the Pod running the native build, that is either the operator Pod, or the build
Pod (depending on the build strategy configured for the platform), must have enough memory available.


This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
Expand Down
8 changes: 4 additions & 4 deletions e2e/namespace/native/files/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
public class Java extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:tick")
.setHeader("m").constant("string!")
.setBody().simple("Magic${header.m}")
.log("${body}");
from("timer:tick")
.setHeader("m").constant("string!")
.setBody().simple("Magic${header.m}")
.log("Java ${body}");
}
}
21 changes: 21 additions & 0 deletions e2e/namespace/native/files/JavaScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

from('timer:tick')
.setHeader('m').constant('string!')
.setBody().simple('Magic${header.m}')
.log('JavaScript ${body}')
33 changes: 33 additions & 0 deletions e2e/namespace/native/files/Xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://camel.apache.org/schema/spring
https://camel.apache.org/schema/spring/camel-spring.xsd">

<route id="hello">
<from uri="timer:tick"/>
<setHeader name="m">
<constant>string!</constant>
</setHeader>
<setBody>
<simple>Magic${header.m}</simple>
</setBody>
<log message="XML ${body}"/>
</route>

</routes>
Loading

0 comments on commit 8f5d4fa

Please sign in to comment.