Skip to content

Commit

Permalink
Migrate Jenkins tests to GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson committed Sep 10, 2024
1 parent c8d84c0 commit ccbd18c
Show file tree
Hide file tree
Showing 12 changed files with 421 additions and 149 deletions.
42 changes: 42 additions & 0 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Operator Build Dependencies
description: Install Operator Build Dependencies

runs:
using: composite
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Init variables action variables
id: go-cache-paths
shell: bash
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

# Cache local bin dependencies
- name: Local Dependencies Cache
uses: actions/cache@v4
with:
path: bin
key: ${{ runner.os }}-bin-${{ hashFiles('Makefile') }}

- name: Install Local Dependencies
shell: bash
run: |
make oc operator-sdk yq jq
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
22 changes: 22 additions & 0 deletions .github/actions/inspect/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: OC Inspect
description: Inspect k8s cluster to obtain debugging data in the event of failure

inputs:
artifactPrefix:
description: 'The prefix to be applied to all artifacts uploaded by this action'
required: true

runs:
using: composite
steps:
- name: Inspect Cluster
if: failure()
run: oc adm inspect ns
shell: bash

- name: Inspect Artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ inputs.artifactPrefix}}-oc-inspect
path: inspect.*
29 changes: 29 additions & 0 deletions .github/actions/kind/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Initialize Kind Cluster
description: Initialize Kind Cluster with Operator image and optional OLM CatalogSource

inputs:
olm:
description: 'Install OLM Operator if true'
default: 'true'
required: false

runs:
using: composite
steps:

- name: Install Kind
run: go install sigs.k8s.io/[email protected]
shell: bash

- name: Create Kind Cluster
run: ./scripts/ci/kind-with-olm.sh
shell: bash

- name: Build Operator Image
run: make operator-build operator-push IMG="localhost:5001/infinispan-operator"
shell: bash

- name: Create OLM Catalog Source
if: ${{ inputs.olm == 'true' }}
run: ./scripts/ci/install-catalog-source.sh
shell: bash
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/dependencies

- name: Lint
run: make lint

- name: Unit Test
run: make test

- name: Check for unstaged changes
run: git diff --name-only --exit-code

infinispan:
needs: unit
uses: ./.github/workflows/test_without_olm.yml
with:
args: 'infinispan-test PARALLEL_COUNT=5'
artifactPrefix: 'infinispan'

cache:
needs: unit
uses: ./.github/workflows/test_without_olm.yml
with:
args: 'cache-test PARALLEL_COUNT=5'
artifactPrefix: 'cache'

batch:
needs: unit
uses: ./.github/workflows/test_without_olm.yml
with:
args: 'batch-test PARALLEL_COUNT=5'
artifactPrefix: 'batch'

multinamespace:
needs: unit
uses: ./.github/workflows/test_without_olm.yml
with:
args: 'multinamespace-test'
artifactPrefix: 'multinamespace'

backup-restore:
needs: unit
uses: ./.github/workflows/test_without_olm.yml
with:
args: 'backuprestore-test'
artifactPrefix: 'backup-restore'

webhook:
needs: unit
uses: ./.github/workflows/test_webhooks.yml

upgrades:
needs: unit
uses: ./.github/workflows/test_upgrades.yml

hr-rolling-upgrades:
needs: unit
uses: ./.github/workflows/test_hr_rolling_upgrades.yml

xsite:
needs: unit
uses: ./.github/workflows/test_xsite.yml
13 changes: 0 additions & 13 deletions .github/workflows/pull_request.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/test_hr_rolling_upgrades.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Hot Rod Rolling Upgrade Tests

on:
workflow_call:

env:
TESTING_LOG_DIR: ${{ github.workspace }}/test/reports

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/dependencies

- name: Initialize Kubernetes Cluster
uses: ./.github/actions/kind

- name: Run Hot Rod Rolling Upgrade Tests
run: make upgrade-test SUBSCRIPTION_STARTING_CSV=infinispan-operator.v2.3.2

- name: Inspect Cluster
uses: ./.github/actions/inspect
with:
artifactPrefix: "hr-rolling-upgrade"

- name: Test Logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: hr-rolling-upgrade-test-logs
path: ${{ env.TESTING_LOG_DIR }}
78 changes: 78 additions & 0 deletions .github/workflows/test_upgrades.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Upgrade Tests

on:
workflow_call:
inputs:
operand:
description: 'The FQN of the Operand image to be used. If left blank the most recent Operand defined in the Operator repository is used.'
required: false
type: string
operandArtifact:
description: 'The name of the GH artifact containing the Operand image'
required: false
type: string
ref:
type: string
required: false
repository:
type: string
required: false

env:
TESTING_LOG_DIR: ${{ github.workspace }}/test/reports

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository }}

- name: Install Dependencies
uses: ./.github/actions/dependencies

- if: ${{ inputs.operandArtifact != '' }}
name: Download operand artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.operandArtifact }}
path: /tmp/operand

- if: ${{ inputs.operandArtifact != '' }}
name: Load Operand image from Artifact
run: docker load --input /tmp/operand/${{ inputs.operandArtifact }}.tar

- name: Update Operands
if: ${{ inputs.operand != '' }}
run: ./scripts/ci/add_operand_to_csv.sh ${{ inputs.operand }}

- name: Log CSV Deployment
run: yq config/manager/manager.yaml

- if: ${{ inputs.operandArtifact != '' }}
name: Push Operand image to kind cluster
run: |
docker push ${{ inputs.operand }}
kind load docker-image ${{ inputs.operand }}
- name: Initialize Kubernetes Cluster
uses: ./.github/actions/kind

- name: Run GracefulShutdown Upgrade Tests
run: make upgrade-test SUBSCRIPTION_STARTING_CSV=infinispan-operator.v2.3.2

- name: Inspect Cluster
uses: ./.github/actions/inspect
with:
artifactPrefix: "upgrades"

- name: Test Logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: upgrade-test-logs
path: ${{ env.TESTING_LOG_DIR }}
36 changes: 36 additions & 0 deletions .github/workflows/test_webhooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Hot Rod Rolling Upgrade Tests

on:
workflow_call:

env:
TESTING_LOG_DIR: ${{ github.workspace }}/test/reports

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/dependencies

- name: Initialize Kubernetes Cluster
uses: ./.github/actions/kind

- name: Webhook Tests
run: make webhook-test PARALLEL_COUNT=5

- name: Inspect Cluster
uses: ./.github/actions/inspect
with:
artifactPrefix: "webhooks"

- name: Test Logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: webhook-test-logs
path: ${{ env.TESTING_LOG_DIR }}
55 changes: 55 additions & 0 deletions .github/workflows/test_without_olm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Local Operator Test

on:
workflow_call:
inputs:
args:
description: 'Arguments to pass to make in order to execute the tests'
required: true
type: string
artifactPrefix:
description: 'The prefix to be applied to all artifacts uploaded by this workflow'
required: true
type: string

env:
CONFIG_LISTENER_IMAGE: 'localhost:5001/infinispan-operator'
KUBECONFIG: ${{ github.workspace }}/kind-kube-config.yaml
MAKE_DATADIR_WRITABLE: 'true'
RUN_SA_OPERATOR: 'true'
TESTING_LOG_DIR: ${{ github.workspace }}/test/reports

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/dependencies

- name: Initialize Kubernetes Cluster
uses: ./.github/actions/kind
with:
olm: 'false'

- name: Run Tests
run: |
kubectl create namespace namespace-for-testing
make ${MAKE_TARGET}
env:
MAKE_TARGET: ${{ inputs.args }}

- name: Inspect Cluster
uses: ./.github/actions/inspect
with:
artifactPrefix: ${{ inputs.artifactPrefix }}

- name: Test Logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: ${{ inputs.artifactPrefix}}-test-logs
path: ${{ env.TESTING_LOG_DIR }}
Loading

0 comments on commit ccbd18c

Please sign in to comment.