Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions .github/workflows/operator-pr-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# 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: Operator PR Test
run-name: "Operator PR #${{ github.event.client_payload.pr_number }} on ${{ github.event.client_payload.platform }}"

on:
repository_dispatch:
types: [operator-pr-test]

env:
PR_NUMBER: ${{ github.event.client_payload.pr_number }}
PR_REF: ${{ github.event.client_payload.pr_ref }}
PR_SHA: ${{ github.event.client_payload.pr_sha }}
OPERATOR_REPO: ${{ github.event.client_payload.operator_repo }}
PLATFORM: ${{ github.event.client_payload.platform }}
OPERATOR_IMAGE: ghcr.io/${{ github.repository_owner }}/openserverless-testing

NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}

jobs:
operator-pr-test:
name: "Test operator PR #${{ github.event.client_payload.pr_number }}"
runs-on: ubuntu-22.04
permissions:
packages: write
steps:
- name: Checkout testing repo
uses: actions/checkout@v4

- name: Clone operator PR branch with submodules
run: |
git clone --recurse-submodules --branch "$PR_REF" \
"https://github.com/$OPERATOR_REPO.git" _operator

- name: Verify submodule
run: |
echo "Checking olaris/ submodule content..."
ls _operator/olaris/opsfile.yml _operator/olaris/opsroot.json
echo "Submodule OK"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push operator image
id: build
run: |
SHORT_SHA="${PR_SHA:0:7}"
IMAGE_TAG="pr-${PR_NUMBER}-${SHORT_SHA}"
FULL_IMAGE="${OPERATOR_IMAGE}:${IMAGE_TAG}"
echo "Building ${FULL_IMAGE} from _operator/"
docker build -t "${FULL_IMAGE}" _operator/
docker push "${FULL_IMAGE}"
echo "image_ref=${FULL_IMAGE}" >> "$GITHUB_OUTPUT"

- name: Patch opsroot.json with PR image
run: |
jq --arg img "${{ steps.build.outputs.image_ref }}" \
'.config.images.operator = $img' \
_operator/olaris/opsroot.json > _operator/olaris/opsroot.json.tmp
mv _operator/olaris/opsroot.json.tmp _operator/olaris/opsroot.json
echo "Patched opsroot.json:"
cat _operator/olaris/opsroot.json

- name: Set OPS_ROOT
run: echo "OPS_ROOT=$(pwd)/_operator/olaris" >> "$GITHUB_ENV"

- name: Install ops
run: |
curl -sL bit.ly/get-ops | bash
ops -info
ops -t > /dev/null

- name: Load secrets from 1Password
uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SSH_KEY: op://OpenServerless/ops_testing_ssh/public key
NGROK_PASSWORD: op://OpenServerless/TESTING/NGROK_PASSWORD
ID_RSA_B64: op://OpenServerless/TESTING/ID_RSA_B64
K8S_KUBECONFIG_B64: op://OpenServerless/TESTING/K8S_KUBECONFIG_B64
K3S_AMD_APIHOST: op://OpenServerless/TESTING/K3S_AMD_APIHOST
K3S_ARM_APIHOST: op://OpenServerless/TESTING/K3S_ARM_APIHOST
K8S_APIHOST: op://OpenServerless/TESTING/K8S_APIHOST
APIHOST: op://OpenServerless/TESTING/APIHOST

- name: 1 Deploy
run: |
touch .secrets
tests/1-deploy.sh $PLATFORM
- name: 3 SysRedis
run: tests/3-sys-redis.sh $PLATFORM
- name: 4 SysMongo
run: tests/4a-sys-ferretdb.sh $PLATFORM
- name: 4b SysPostgres
run: tests/4b-sys-postgres.sh $PLATFORM
- name: 5 SysMinio
run: tests/5-sys-minio.sh $PLATFORM
- name: 6 Login
run: tests/6-login.sh $PLATFORM
- name: 7 Static
run: tests/7-static.sh $PLATFORM
- name: 8 UserRedis
run: tests/8-user-redis.sh $PLATFORM
- name: 9a UserFerretDB
run: tests/9a-user-ferretdb.sh $PLATFORM
- name: 9b UserPostgres
run: tests/9b-user-postgres.sh $PLATFORM
- name: 10 UserMinio
run: tests/10-user-minio.sh $PLATFORM
- name: 14 RuntimeTesting
run: tests/14-runtime-testing.sh $PLATFORM
136 changes: 53 additions & 83 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ on:
push:
tags:
- '*-*'
branches-ignore: '*'

env:
PLATFORM: ${{ github.ref_name }}
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
OPS_REPO: https://github.com/apache/openserverless-task
OPS_BRANCH: main
OPS_REPO: ${{ vars.OPS_REPO || 'https://github.com/apache/openserverless-task' }}
OPS_BRANCH: ${{ vars.OPS_BRANCH || 'main' }}
NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
#NGROK_PASSWORD: ${{ secrets.NGROK_PASSWORD }}

jobs:
test-linux:
Expand All @@ -40,43 +37,34 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add Missing plugin
run: |
# fix for missing auth-plugin
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt update
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin kubectl
if: ${{ startsWith(github.ref_name, 'gke') }}
# Commented out -- GKE plugin not needed without GCP environment:
# - name: Add Missing plugin
# run: |
# # fix for missing auth-plugin
# echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
# sudo apt update
# sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin kubectl
# if: ${{ startsWith(github.ref_name, 'gke') }}
- name: Install ops
run: |
curl -sL bit.ly/get-ops | bash
curl -sL bit.ly/get-ops | bash
ops -info
ops -t > /dev/null
- name: Load secret
- name: Load secrets from 1Password
uses: 1password/load-secrets-action@v2
with:
# Export loaded secrets as environment variables
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SSH_KEY: op://OpenServerless/ops_testing_ssh/public key
NGROK_PASSWORD: op://OpenServerless/TESTING/NGROK_PASSWORD
K3S_IP: op://OpenServerless/TESTING/K3S_IP
MK8S_IP: op://OpenServerless/TESTING/MK8S_IP
ID_RSA_B64: op://OpenServerless/TESTING/ID_RSA_B64
AKS_KUBECONFIG_B64: op://OpenServerless/TESTING/AKS_KUBECONFIG_B64
AWS_ACCESS_KEY_ID: op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: op://OpenServerless/TESTING/AWS_DEFAULT_REGION
AWS_SSHKEY: op://OpenServerless/TESTING/AWS_SSHKEY
EKS_KUBECONFIG_B64: op://OpenServerless/TESTING/EKS_KUBECONFIG_B64
#GKE_KUBECONFIG_B64: op://OpenServerless/TESTING/GKE_KUBECONFIG_B64
#OPENSHIFT_KUBECONFIG_B64: op://OpenServerless/TESTING/OPENSHIFT_KUBECONFIG_B64
#AWS_ACCESS_KEY_ID: op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
#AWS_SECRET_ACCESS_KEY: op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
#GCLOUD_SERVICE_ACCOUNT_B64: op://OpenServerless/TESTING/GCLOUD_SERVICE_ACCOUNT_B64

K8S_KUBECONFIG_B64: op://OpenServerless/TESTING/K8S_KUBECONFIG_B64
K3S_AMD_APIHOST: op://OpenServerless/TESTING/K3S_AMD_APIHOST
K3S_ARM_APIHOST: op://OpenServerless/TESTING/K3S_ARM_APIHOST
K8S_APIHOST: op://OpenServerless/TESTING/K8S_APIHOST
APIHOST: op://OpenServerless/TESTING/APIHOST
- name: Debug Action (if requested)
run: .github/debugAction.sh
- name: Wait for Debug (if requested)
Expand Down Expand Up @@ -121,38 +109,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
# Install Git (which includes Git Bash)
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
if: ${{ startsWith(github.ref_name, 'gke') }}
- name: 'Update plugin'
if: ${{ startsWith(github.ref_name, 'gke') }}
run: gcloud components install gke-gcloud-auth-plugin
- name: Load secrets
uses: shyim/1password-load-secrets-action@v1
with:
# export also as environment variable
export: true
# mask the secrets in the logs
mask-secrets: true
# secret mapping
secrets: |
op://OpenServerless/TESTING/NGROK_PASSWORD
op://OpenServerless/TESTING/K3S_IP
op://OpenServerless/TESTING/MK8S_IP
op://OpenServerless/TESTING/ID_RSA_B64
op://OpenServerless/TESTING/AKS_KUBECONFIG_B64
op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
op://OpenServerless/TESTING/AWS_DEFAULT_REGION
op://OpenServerless/TESTING/AWS_SSHKEY
op://OpenServerless/TESTING/EKS_KUBECONFIG_B64
#GKE_KUBECONFIG_B64: op://OpenServerless/TESTING/GKE_KUBECONFIG_B64
#OPENSHIFT_KUBECONFIG_B64: op://OpenServerless/TESTING/OPENSHIFT_KUBECONFIG_B64
#AWS_ACCESS_KEY_ID: op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
#AWS_SECRET_ACCESS_KEY: op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
#GCLOUD_SERVICE_ACCOUNT_B64: op://OpenServerless/TESTING/GCLOUD_SERVICE_ACCOUNT_B64
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
# Commented out -- GKE plugin not needed without GCP environment:
# - name: 'Set up Cloud SDK'
# uses: 'google-github-actions/setup-gcloud@v1'
# if: ${{ startsWith(github.ref_name, 'gke') }}
# - name: 'Update plugin'
# if: ${{ startsWith(github.ref_name, 'gke') }}
# run: gcloud components install gke-gcloud-auth-plugin
- name: Install ops
shell: powershell
run: |
Expand All @@ -172,6 +135,21 @@ jobs:
run: |
ops -update
ops -info
- name: Load secrets from 1Password
uses: shyim/1password-load-secrets-action@v1
with:
export: true
mask-secrets: true
secrets: |
op://OpenServerless/TESTING/NGROK_PASSWORD
op://OpenServerless/TESTING/ID_RSA_B64
op://OpenServerless/TESTING/K8S_KUBECONFIG_B64
op://OpenServerless/TESTING/K3S_AMD_APIHOST
op://OpenServerless/TESTING/K3S_ARM_APIHOST
op://OpenServerless/TESTING/K8S_APIHOST
op://OpenServerless/TESTING/APIHOST
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

- name: 1 Deploy
shell: bash
Expand Down Expand Up @@ -230,12 +208,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
if: ${{ startsWith(github.ref_name, 'gke') }}
- name: 'Update plugin'
if: ${{ startsWith(github.ref_name, 'gke') }}
run: gcloud components install gke-gcloud-auth-plugin
# Commented out -- GKE plugin not needed without GCP environment:
# - name: 'Set up Cloud SDK'
# uses: 'google-github-actions/setup-gcloud@v1'
# if: ${{ startsWith(github.ref_name, 'gke') }}
# - name: 'Update plugin'
# if: ${{ startsWith(github.ref_name, 'gke') }}
# run: gcloud components install gke-gcloud-auth-plugin
- name: Install ops
run: |
curl -sL bit.ly/get-ops | /bin/bash
Expand All @@ -244,29 +223,20 @@ jobs:
ops -t > /dev/null
OPS_BIN_PATH=$(ops -i | grep "OPS_HOME" | awk -v FS=: '{print $2}' | tr -d " ")/bin
echo "PATH=$OPS_BIN_PATH:$PATH" >> $GITHUB_ENV
- name: Load secret
- name: Load secrets from 1Password
uses: 1password/load-secrets-action@v2
with:
# Export loaded secrets as environment variables
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SSH_KEY: op://OpenServerless/ops_testing_ssh/public key
NGROK_PASSWORD: op://OpenServerless/TESTING/NGROK_PASSWORD
K3S_IP: op://OpenServerless/TESTING/K3S_IP
MK8S_IP: op://OpenServerless/TESTING/MK8S_IP
ID_RSA_B64: op://OpenServerless/TESTING/ID_RSA_B64
AKS_KUBECONFIG_B64: op://OpenServerless/TESTING/AKS_KUBECONFIG_B64
AWS_ACCESS_KEY_ID: op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: op://OpenServerless/TESTING/AWS_DEFAULT_REGION
AWS_SSHKEY: op://OpenServerless/TESTING/AWS_SSHKEY
EKS_KUBECONFIG_B64: op://OpenServerless/TESTING/EKS_KUBECONFIG_B64
#GKE_KUBECONFIG_B64: op://OpenServerless/TESTING/GKE_KUBECONFIG_B64
#OPENSHIFT_KUBECONFIG_B64: op://OpenServerless/TESTING/OPENSHIFT_KUBECONFIG_B64
#AWS_ACCESS_KEY_ID: op://OpenServerless/TESTING/AWS_ACCESS_KEY_ID
#AWS_SECRET_ACCESS_KEY: op://OpenServerless/TESTING/AWS_SECRET_ACCESS_KEY
#GCLOUD_SERVICE_ACCOUNT_B64: op://OpenServerless/TESTING/GCLOUD_SERVICE_ACCOUNT_B64
K8S_KUBECONFIG_B64: op://OpenServerless/TESTING/K8S_KUBECONFIG_B64
K3S_AMD_APIHOST: op://OpenServerless/TESTING/K3S_AMD_APIHOST
K3S_ARM_APIHOST: op://OpenServerless/TESTING/K3S_ARM_APIHOST
K8S_APIHOST: op://OpenServerless/TESTING/K8S_APIHOST
APIHOST: op://OpenServerless/TESTING/APIHOST
- name: Debug Action (if requested)
run: .github/debugAction.sh
- name: Wait for Debug (if requested)
Expand Down
Loading