Skip to content

Commit

Permalink
added qase integration
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakpunia-suse committed Feb 3, 2025
1 parent 27c70d8 commit dc3ae64
Show file tree
Hide file tree
Showing 12 changed files with 583 additions and 37 deletions.
117 changes: 116 additions & 1 deletion .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
key_name:
description: AWS key pair name for the EC2 instance.
required: true
qase_api_token:
description: Qase API token to use for Qase reporting
required: true
inputs:
rancher_version:
description: Rancher Manager version
Expand All @@ -40,6 +43,11 @@ on:
default: https://releases.rancher.com/server-charts/latest
type: string
required: true
qase_run_id:
description: Qase run ID to use for reporting (e.g. 'auto', 'none', or a valid numeric ID)
type: string
default: 'none'
required: false

env:
image_id: ami-00eb69d236edcfaf8
Expand Down Expand Up @@ -177,11 +185,13 @@ jobs:
# Install Rancher
helm install rancher rancher/rancher --namespace cattle-system \
--version "$(echo '${{ inputs.rancher_version }}' | tr -d 'v')" \
--set hostname=rancher.${{ steps.get_ip.outputs.PUBLIC_IP }}.sslip.io \
--set replicas=2 \
--set bootstrapPassword='${{ secrets.rancher_password }}' \
--set global.cattle.psp.enabled=false \
--set rancherImageTag='${{ inputs.rancher_version }}' \
--set rancherImage="$(if echo '${{ inputs.rancher_repo }}' | grep -q 'releases.rancher.com'; then echo 'rancher/rancher'; else echo 'stgregistry.suse.com/rancher/rancher'; fi)" \
--wait \
--timeout=10m \
--create-namespace \
Expand All @@ -191,9 +201,77 @@ jobs:
"
EOF
pre-qase:
runs-on: ubuntu-latest
env:
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
QASE_PROJECT_CODE: RM
outputs:
qase_run_description: ${{ steps.qase.outputs.qase_run_description }}
qase_run_id: ${{ steps.qase.outputs.qase_run_id }}
qase_run_name: ${{ steps.qase.outputs.qase_run_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

- name: Create/Export Qase Run
id: qase
env:
QASE_RUN_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.rancher_version || github.workflow }}
run: |
case ${{ inputs.qase_run_id }} in
'auto')
# Define and export URL of GH test run in Qase run description
GH_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
QASE_DESC="${GH_RUN_URL}"
export QASE_RUN_DESCRIPTION="${QASE_DESC}"
# Use full rancher version
QASE_RUN_NAME=$(echo "Observability E2E Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }}" | grep -P '[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+[0-9]+)?' || true)
# Or workflow name if the full rancher version is not found
if [ -z "$QASE_RUN_NAME" ]; then
QASE_RUN_NAME="Observability E2E Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }} | ${{ github.workflow }}"
fi
# Create a Qase run, get its ID
ID=$(make create-qase-run)
# Export outputs for future use
echo "qase_run_description=${QASE_DESC}" >> ${GITHUB_OUTPUT}
echo "qase_run_id=${ID}" >> ${GITHUB_OUTPUT}
echo "qase_run_name=${QASE_RUN_NAME}" >> ${GITHUB_OUTPUT}
# Just an info for debugging purposes
echo -e "Exported values:\nQASE_RUN_ID=${ID}\nQASE_RUN_DESCRIPTION=${QASE_DESC}\nQASE_RUN_NAME=${QASE_RUN_NAME}"
;;
'none')
echo "qase_run_id=" >> ${GITHUB_OUTPUT}
echo "### Test not reported in QASE!" >> ${GITHUB_STEP_SUMMARY}
;;
[0-9]*)
# If the run ID has been specified
echo "qase_run_id=${{ inputs.qase_run_id }}" >> ${GITHUB_OUTPUT}
;;
esac
run-e2e:
needs: [setup]
needs: [setup, pre-qase]
runs-on: ubuntu-latest
env:
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
# Adjust to your project code in Qase:
QASE_PROJECT_CODE: RM
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
# Needed for qase_ginkgo or Cypress integration if desired
QASE_REPORT: 1
# Rancher environment
RANCHER_VERSION: ${{ inputs.rancher_version }}
UPSTREAM_CLUSTER_VERSION: ${{ inputs.upstream_cluster_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -293,6 +371,43 @@ jobs:
name: test-artifacts
path: ~/artifacts

post-qase:
if: ${{ always() && needs.pre-qase.outputs.qase_run_id != '' }}
needs: [run-e2e, pre-qase]
runs-on: ubuntu-latest
env:
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
QASE_PROJECT_CODE: RM
QASE_REPORT: 1
QASE_RUN_COMPLETE: 1
QASE_RUN_ID: ${{ needs.pre-qase.outputs.qase_run_id }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

- name: Finalize Qase Run and publish Results
if: ${{ always() && !contains(needs.run-e2e.result, 'cancelled') }}
run: |
REPORT=$(make publish-qase-run)
echo "${REPORT}"
# If your tool prints "Report available: [URL]",
# parse that here for the summary
REPORT_URL=$(awk '/available:/ { print $NF }' <<<"${REPORT}")
if [[ -n "${REPORT_URL}" ]]; then
echo "## QASE Reporting" >> ${GITHUB_STEP_SUMMARY}
echo "Public Qase report: ${REPORT_URL}" >> ${GITHUB_STEP_SUMMARY}
fi
- name: Delete Qase Run if job cancelled/skipped AND qase_run_id was 'auto'
if: ${{ always() && (contains(needs.run-e2e.result, 'cancelled') || contains(needs.run-e2e.result, 'skipped')) && inputs.qase_run_id == 'auto' }}
run: make delete-qase-run

delete-resources:
if: ${{ always() && inputs.destroy_runner == true }}
needs: [setup, run-e2e]
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/observability-e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: RKE2 Observability E2E

run-name: >
Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }}, destroy=${{ inputs.destroy_runner }}
Rancher=${{ inputs.rancher_version }}, RKE2 Version=${{ inputs.upstream_cluster_version }}, destroy=${{ inputs.destroy_runner }}
on:
workflow_dispatch:
Expand All @@ -26,6 +26,13 @@ on:
type: string
required: true

# Add a Qase run ID input (can be 'auto', 'none', or a numeric run ID)
qase_run_id:
description: Qase run ID for reporting (e.g., 'auto', 'none', or an ID like '123')
default: 'none'
type: string
required: false

jobs:
e2e:
uses: ./.github/workflows/master-e2e.yaml
Expand All @@ -34,10 +41,12 @@ jobs:
rancher_version: ${{ inputs.rancher_version }}
upstream_cluster_version: ${{ inputs.upstream_cluster_version }}
rancher_repo: ${{ inputs.rancher_repo }}
qase_run_id: ${{ inputs.qase_run_id }}
secrets:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
rancher_password: ${{ secrets.RANCHER_PASSWORD }}
instance_ssh_key: ${{ secrets.INSTANCE_SSH_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
key_name: ${{ secrets.AWS_KEY_NAME }}
qase_api_token: ${{ secrets.QASE_API_TOKEN }}
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ deps:

e2e-install-rancher: deps
ginkgo --label-filter install -r -v ./test/e2e

# Qase commands
create-qase-run: deps
@go run tests/helper/qase/helper_qase.go -create
delete-qase-run: deps
@go run tests/helper/qase/helper_qase.go -delete
publish-qase-run: deps
@go run tests/helper/qase/helper_qase.go -publish
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9
github.com/rancher/shepherd v0.0.0-20240913161053-43e119d13724 // rancher/shepherd release/v2.9-HEAD commit
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sirupsen/logrus v1.9.3
k8s.io/apimachinery v0.30.2
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
)

require (
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/rancher-sandbox/qase-ginkgo v1.0.1
github.com/rancher/rancher v0.0.0-00010101000000-000000000000
github.com/rancher/rancher/pkg/apis v0.0.0-20240719121207-baeda6b89fe3
k8s.io/kubernetes v1.30.1
Expand All @@ -24,6 +25,7 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/antihax/optional v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.50.38 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
Expand Down Expand Up @@ -91,6 +93,7 @@ require (
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.qase.io/client v0.0.0-20231114201952-65195ec001fa // indirect
go.starlark.net v0.0.0-20231101134539-556fd59b42f6 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
Expand Down
Loading

0 comments on commit dc3ae64

Please sign in to comment.