Skip to content

Commit

Permalink
Added post-main e2e with lifecycle manager job (#83)
Browse files Browse the repository at this point in the history
* Added post-main e2e with lifecycle manager job

* test

* Revert "test"

This reverts commit cdaa9c4.
  • Loading branch information
mfaizanse authored Jul 19, 2023
1 parent 9241d3b commit 46d9dda
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 4 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/push-with-lifecycle-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: push-with-lifecycle-manager

env:
E2E_LOG_LEVEL: debug
KYMA_STABILITY: "unstable"
KYMA: "./hack/kyma"

on:
push:
branches: [ "main" ]

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install k3d tools
uses: nolar/setup-k3d-k3s@v1
with:
# This is the Kubernetes version used by k3d. See https://kubernetes.io/releases/
version: v1.26.5
skip-creation: true

- name: Install Kyma CLI & setup k3d cluster using kyma CLI
run: |
make kyma
make -C hack/ci/ create-k3d
kubectl version
kubectl cluster-info
- name: Deploy lifecycle-manager
run: |
make -C hack/ci/ install-lifecycle-manager
- name: Wait for the 'post-nats-manager-build' job to succeed
uses: mfaizanse/[email protected]
with:
context: "post-nats-manager-build"
commit_ref: "${{ github.sha }}"
timeout: 600000 # 10 minutes in milliseconds
# The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting)
check_interval: 60000 # 1 minute in milliseconds
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "nats-manager"

- name: Wait for the 'post-nats-module-build' job to succeed
id: wait-nats-module-build
uses: mfaizanse/[email protected]
with:
context: "post-nats-module-build"
commit_ref: "${{ github.sha }}"
timeout: 600000 # 10 minutes in milliseconds
# The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting)
check_interval: 60000 # 1 minute in milliseconds
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "nats-manager"

- name: Download & validate NATS module template
env:
COMMIT_STATUS_JSON: "${{ steps.wait-nats-module-build.outputs.json }}"
run: |
make -C hack/ci/ download-module-template
kubectl apply -f module-template.yaml --dry-run=client
- name: Install & enabled NATS module template
run: |
make -C hack/ci/ install-module-template
make -C hack/ci/ enable-module-without-default-cr
- name: Setup and test NATS CR
run: |
make e2e-setup
- name: Run NATS bench
run: |
go install github.com/nats-io/natscli/nats@latest
export PATH=$HOME/go/bin:$PATH
make e2e-bench
- name: Test NATS-server
run: |
make e2e-nats-server
- name: Cleanup NATS CR
run: |
make e2e-cleanup
26 changes: 22 additions & 4 deletions hack/get_module_template_from_build_job.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

## This script requires the following env variables:
# PR_NUMBER (e.g. 82)
# COMMIT_STATUS_JSON
# PROJECT_ROOT (e.g. "../")
# PR_NUMBER (optional, int, If not set then will run for main branch. e.g. 82)
# COMMIT_STATUS_JSON (required, json)
# PROJECT_ROOT (required, string, e.g. "../")

# Example of `COMMIT_STATUS_JSON`
# {
Expand All @@ -19,12 +19,30 @@
# "updated_at": "2023-07-18T11:39:23Z"
# }

## check if required ENVs are provided.
if [[ -z "${COMMIT_STATUS_JSON}" ]]; then
echo "ERROR: COMMIT_STATUS_JSON is not set!"
exit 1
fi

if [[ -z "${PROJECT_ROOT}" ]]; then
echo "ERROR: PROJECT_ROOT is not set!"
exit 1
fi

## define variables
MODULE_TEMPLATE_FILE="${PROJECT_ROOT}/module-template.yaml"

# set links for artifacts of pull requests.
ARTIFACTS_BASE_URL="https://gcsweb.build.kyma-project.io/gcs/kyma-prow-logs/pr-logs/pull/kyma-project_nats-manager"
TEMPLATE_FILE_BASE_URL="${ARTIFACTS_BASE_URL}/${PR_NUMBER}/pull-nats-module-build"
# if PR_NUMBER is not set, then set links for artifacts of main branch.
if [[ -z "${PR_NUMBER}" ]]; then
ARTIFACTS_BASE_URL="https://gcsweb.build.kyma-project.io/gcs/kyma-prow-logs/logs/post-nats-module-build"
TEMPLATE_FILE_BASE_URL="${ARTIFACTS_BASE_URL}"
fi

### Extract the prow job ID.
## Extract the prow job ID.
echo "Extracting prow job Id from: ${COMMIT_STATUS_JSON}"
TARGET_URL=$(echo ${COMMIT_STATUS_JSON} | jq -r '.target_url')
PROW_JOB_ID=$(echo ${TARGET_URL##*/})
Expand Down

0 comments on commit 46d9dda

Please sign in to comment.