Skip to content

Commit bb43304

Browse files
author
Francesco Timperi Tiberi
authored
Merge pull request #22 from francescotimperi/main
gh action includes test and uses kind 1.25.3 for testing purposes
2 parents 3149c21 + 20371bb commit bb43304

File tree

13 files changed

+127
-92
lines changed

13 files changed

+127
-92
lines changed

.github/workflows/check.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
name: openserverless-operator-check
3232
on:
3333
push:
34-
tags-ignore:
35-
- '*'
34+
branches: [main]
35+
pull_request:
36+
branches: [main]
3637

3738
jobs:
3839
check:
39-
name: Build
40+
name: Check OpenServerless Operator
4041
runs-on: ubuntu-latest
4142
steps:
4243
- name: Checkout
@@ -46,29 +47,32 @@ jobs:
4647
- name: License
4748
uses: apache/skywalking-eyes@main
4849
continue-on-error: true
49-
- name: Make envfile
50-
if: ${{ env.GITHUB_USER != 'nuvolaris'}}
51-
uses: SpicyPizza/[email protected]
52-
with:
53-
envkey_MY_OPERATOR_IMAGE: ${{ secrets.MY_OPERATOR_IMAGE }}
54-
file_name: .env
55-
fail_on_empty: false
50+
- name: Assign TAG from pull request
51+
if: ${{ github.event_name == 'pull_request' }}
52+
run: |
53+
echo "IMG_TAG=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
54+
- name: Assign TAG from push
55+
if: ${{ github.event_name != 'pull_request' }}
56+
run: |
57+
echo "IMG_TAG=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
58+
- name: Assign Custom Image Name
59+
if: ${{ github.repository_owner != 'apache'}}
60+
run: |
61+
echo "MY_OPERATOR_IMAGE=${{ vars.MY_OPERATOR_IMAGE }}" >> "$GITHUB_ENV"
5662
- name: Kind
57-
uses: helm/kind-action@v1.2.0
63+
uses: container-tools/kind-action@v2.0.4
5864
with:
59-
cluster_name: nuvolaris
60-
config: .github/kind.yaml
65+
version: v0.17.0
66+
cluster_name: nuvolaris
67+
config: .github/kind.yaml
6168
- name: Setup
6269
run: bash .github/cisetup.sh
6370
- name: Install
6471
run: task setup
6572
- name: BuildAndLoad
66-
run: task build-and-load
73+
run: task build-and-load TAG="$IMG_TAG"
6774
- name: AddIngress
68-
run: task kind:ingress
69-
- name: Test
70-
run: task test
71-
continue-on-error: true
75+
run: task kind:ingress
7276
- name: Ngrok
7377
if: ${{ env.NGROK == 'on' }}
7478
run: bash .github/debug-github-actions.sh
@@ -77,4 +81,10 @@ jobs:
7781
USER_PASS: ${{ secrets.USER_PASS }}
7882
- name: Wait
7983
if: ${{ env.NGROK == 'on' }}
80-
run: bash .github/wait.sh
84+
run: bash .github/wait.sh
85+
- name: Unit Test
86+
run: task utest
87+
continue-on-error: false
88+
- name: Integration Test
89+
run: task itest
90+
continue-on-error: false

.github/workflows/image.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@
2929
# See the License for the specific language governing permissions and
3030
# limitations under the License.
3131

32-
name: Build Openserverless-operator Image
32+
name: Build OpenServerless Operator
3333

3434
on:
3535
push:
3636
tags:
3737
- '[0-9]*'
3838
branches-ignore:
3939
- '*'
40-
pull_request:
41-
branches: [main]
42-
4340
jobs:
4441
image:
45-
name: Image
42+
name: Build OpenServerless Operator Image
4643
runs-on: ubuntu-latest
4744
steps:
4845
- name: Remove unnecessary files
@@ -69,8 +66,33 @@ jobs:
6966
echo "MY_OPERATOR_IMAGE=${{ vars.MY_OPERATOR_IMAGE }}" >> "$GITHUB_ENV"
7067
- name: Setup
7168
run: bash .github/cisetup.sh
69+
- name: Kind
70+
uses: container-tools/[email protected]
71+
with:
72+
version: v0.17.0
73+
cluster_name: nuvolaris
74+
config: .github/kind.yaml
7275
- name: Install
7376
run: poetry install
77+
- name: BuildAndLoad
78+
run: task build-and-load TAG="$IMG_TAG"
79+
- name: Ngrok
80+
if: ${{ env.NGROK == 'on' }}
81+
run: bash .github/debug-github-actions.sh
82+
env:
83+
NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
84+
USER_PASS: ${{ secrets.USER_PASS }}
85+
- name: Wait
86+
if: ${{ env.NGROK == 'on' }}
87+
run: bash .github/wait.sh
88+
- name: AddIngress
89+
run: task kind:ingress
90+
- name: Unit Test
91+
run: task utest
92+
continue-on-error: false
93+
- name: Integration Test
94+
run: task itest
95+
continue-on-error: false
7496
- name: Registry login
7597
uses: docker/login-action@v3
7698
with:
@@ -82,4 +104,4 @@ jobs:
82104
- name: Set up Docker Buildx
83105
uses: docker/setup-buildx-action@v3
84106
- name: Image
85-
run: task buildx-and-push TAG="$IMG_TAG"
107+
run: task buildx-and-push TAG="$IMG_TAG"

Taskfile.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vars:
2222
N: ""
2323
T: ""
2424
P: ""
25-
BASETAG: 0.1.0-testing
25+
BASETAG: 0.1.0-incubating
2626
KUBE:
2727
sh: ./detect.sh
2828
NS: "nuvolaris"
@@ -185,6 +185,7 @@ tasks:
185185
186186
# update configuration files from openwhisk source
187187
update-files-from-openwhisk:
188+
ignore_error: true
188189
cmds:
189190
- |
190191
cp -v ../nuvolaris/nuvolaris-controller/openwhisk/ansible/files/*.json nuvolaris/files
@@ -236,7 +237,7 @@ tasks:
236237

237238
iclean: rm -f deploy/*/kustomization.yaml deploy/*/__* deploy/*/*_generated.yaml
238239

239-
itest:
240+
itest:
240241
cmds:
241242
- task: iclean
242243
- |
@@ -272,7 +273,6 @@ tasks:
272273
- task: t:hello
273274
- task: t:redis
274275
- task: t:echo
275-
- task: t:api
276276

277277
test:
278278
- task: clean

nuvolaris/ip_util.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ class IpUtil:
2828
_machine_ip = None
2929

3030
def __init__(self):
31-
self.IPIFY_API_URI = 'https://api.ipify.org'
32-
self.IFCONFIG_API_URI = 'https://ifconfig.me/ip'
31+
self.IPIFY_API_URI = 'https://api.ipify.org'
3332
self.IP_INFO_API_URI = 'https://ipinfo.io/ip'
34-
self.IDENT_ME_API_URI = 'https://ident.me/'
33+
self.IDENT_ME_API_URI = 'https://4.ident.me/'
3534
self.USER_AGENT = 'nuvolaris-ip-resolver'
3635
# The maximum amount of tries to attempt when making API calls.
3736
self.MAX_TRIES = 3
@@ -53,17 +52,14 @@ def _get_ip_resp(self,api_uri: str):
5352
logging.debug(f"querying ip from {api_uri}")
5453
return get(api_uri, headers={'user-agent': self.USER_AGENT})
5554

56-
def handle_ip_request(self,url):
55+
def handle_ip_request(self,url, extra=None):
5756
"""
58-
Query a public api retuning the machine's public ip address
57+
Query a public api returning the machine's public ip address
5958
>>> from nuvolaris.ip_util import IpUtil
6059
>>> ip_util = IpUtil()
6160
>>> ipify_ip = ip_util.handle_ip_request('https://api.ipify.org')
62-
>>> ifconfig_ip = ip_util.handle_ip_request('https://ifconfig.me/ip')
6361
>>> ifinfo_ip = ip_util.handle_ip_request('https://ipinfo.io/ip')
64-
>>> identme_ip = ip_util.handle_ip_request('https://ident.me/')
65-
>>> ipify_ip == ifconfig_ip
66-
True
62+
>>> identme_ip = ip_util.handle_ip_request('https://4.ident.me/')
6763
>>> ipify_ip == ifinfo_ip
6864
True
6965
>>> ipify_ip == identme_ip
@@ -100,7 +96,6 @@ def get_public_ip(self):
10096
True
10197
"""
10298
self.get_ip_chain(self.IPIFY_API_URI)
103-
self.get_ip_chain(self.IFCONFIG_API_URI)
10499
self.get_ip_chain(self.IP_INFO_API_URI)
105100
self.get_ip_chain(self.IDENT_ME_API_URI)
106101

nuvolaris/minio_deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _annotate_nuv_metadata(data):
106106
openwhisk.annotate(f"s3_host={minio_host}")
107107
openwhisk.annotate(f"s3_access_key={access_key}")
108108
openwhisk.annotate(f"s3_secret_key={secret_key}")
109-
openwhisk.annotate(f"s3_provider=minio")
109+
openwhisk.annotate("s3_provider=minio")
110110

111111
ports = list(minio_service['spec']['ports'])
112112
for port in ports:

nuvolaris/testutil.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,14 @@ def load_image_env():
182182
r = run('grep MY_OPERATOR_IMAGE .env', shell=True, capture_output=True)
183183
if r.returncode == 0:
184184
opimg = r.stdout.strip().decode("ascii").split("=")[-1]
185-
os.environ["OPERATOR_IMAGE"] = opimg
185+
g = run('grep GITHUB_USER= .env', shell=True, capture_output=True)
186+
if g.returncode == 0 and opimg:
187+
ghuser = g.stdout.strip().decode("ascii").split("=")[-1]
188+
opimg = opimg.replace("${GITHUB_USER}",ghuser)
189+
190+
# gives precedence to env variable if set
191+
os.environ["OPERATOR_IMAGE"] = os.getenv("MY_OPERATOR_IMAGE", opimg)
192+
186193
# operator tag is the git tag of the operator
187194
r = run('git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD', shell=True, capture_output=True)
188195
tag = r.stdout.strip().decode("ascii")

nuvolaris/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def get_minio_config_data():
349349
"applypodsecurity":get_enable_pod_security(),
350350
"name":"minio-deployment",
351351
"container":"minio",
352-
"minio_host": cfg.get('minio.host') or "minio",
352+
"minio_host": cfg.get('minio.host') or 'minio',
353353
"minio_volume_size": cfg.get('minio.volume-size') or "5",
354354
"minio_root_user": cfg.get('minio.admin.user') or "minio",
355355
"minio_root_password": cfg.get('minio.admin.password') or "minio123",

tests/couchdb_test.ipy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ cfg.detect()
3030
cdb.create(None)
3131
r = !kubectl -n nuvolaris wait --for=condition=complete job/couchdb-init --timeout=600s
3232
assert(r[0].find("condition met") != -1)
33-
r = !kubectl -n nuvolaris logs -l job=couchdb-init | grep "OK: add_subjects"
33+
r = !kubectl -n nuvolaris logs -l job=couchdb-init | grep "OK: enable_db_compaction: subjects"
3434
assert(r[0].find("OK:") != -1)

tests/kind/minio_static_test.ipy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import nuvolaris.config as cfg
2222
import nuvolaris.testutil as tu
2323
import nuvolaris.minio_deploy as minio
2424
import nuvolaris.util as util
25-
import nuvolaris.minio_static as nginx
25+
import nuvolaris.storage_static as static
2626
import logging
2727
import os
2828

@@ -34,7 +34,7 @@ assert(cfg.detect_storage()["nuvolaris.storageclass"])
3434
os.environ['MINIO_API_HOST']='localhost'
3535

3636
assert(minio.create())
37-
assert(nginx.create())
37+
assert(static.create())
3838

39-
assert(nginx.delete())
39+
assert(static.delete())
4040
assert(minio.delete())

tests/kind/runtime_preloader_test.ipy

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)