keycloak-scim/.github/workflows/operator-ci.yml

199 lines
8 KiB
YAML
Raw Normal View History

name: Keycloak Operator CI
on:
push:
branches-ignore: [main]
pull_request:
schedule:
- cron: '0 0 * * *'
env:
JDK_VERSION: 11
concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ci-operator-keycloak-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build distribution
if: ${{ ( github.event_name != 'schedule' ) || ( github.event_name == 'schedule' && github.repository == 'keycloak/keycloak' ) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=version::0.0.1-$(git rev-parse --short HEAD)"
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- uses: actions/setup-java@v2
with:
2022-03-30 15:45:31 +00:00
distribution: 'temurin'
java-version: ${{ env.JDK_VERSION }}
cache: 'maven'
- name: Create the Keycloak distribution
run: |
mvn clean install -Pdistribution -DskipTests -DskipExamples -DskipTestsuite
- name: Login to docker registry
uses: docker/login-action@v1.14.1
with:
registry: ${{ secrets.TEST_DOCKER_REGISTRY }}
username: ${{ secrets.TEST_DOCKER_USERNAME }}
password: ${{ secrets.TEST_DOCKER_TOKEN }}
- name: Build and push the Keycloak Docker image
working-directory: quarkus/container
run: |
cp ../dist/target/keycloak-*.tar.gz ./
docker build --label "quay.expires-after=20h" --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak:${{ steps.vars.outputs.version }}
docker push ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak:${{ steps.vars.outputs.version }}
- name: Build and push a custom pre-augmented Keycloak Docker image
working-directory: operator
run: |
./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/custom-keycloak
docker push ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/custom-keycloak:${{ steps.vars.outputs.version }}
test-local:
name: Test local
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=version::0.0.1-$(git rev-parse --short HEAD)"
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: ${{ env.JDK_VERSION }}
cache: 'maven'
- name: Setup Minikube-Kubernetes
uses: manusa/actions-setup-minikube@v2.4.3
with:
minikube version: v1.24.0
kubernetes version: v1.22.3
github token: ${{ secrets.GITHUB_TOKEN }}
driver: docker
start args: '--addons=ingress'
- name: Test operator running locally
working-directory: operator
run: |
mvn clean verify \
-Dquarkus.kubernetes.deployment-target=kubernetes \
-Doperator.keycloak.image=${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak:${{ steps.vars.outputs.version }} \
-Dtest.operator.custom.image=${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/custom-keycloak:${{ steps.vars.outputs.version }} \
-Dtest.operator.kubernetes.ip=$(minikube ip)
test-remote:
name: Test remote
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=version::0.0.1-$(git rev-parse --short HEAD)"
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: ${{ env.JDK_VERSION }}
cache: 'maven'
- name: Setup Minikube-Kubernetes
uses: manusa/actions-setup-minikube@v2.4.3
with:
minikube version: v1.24.0
kubernetes version: v1.22.3
github token: ${{ secrets.GITHUB_TOKEN }}
driver: docker
start args: '--addons=ingress'
- name: Test operator running in cluster
working-directory: operator
run: |
eval $(minikube -p minikube docker-env)
mvn clean verify \
-Dquarkus.container-image.build=true \
-Dquarkus.kubernetes.deployment-target=kubernetes \
-Dquarkus.jib.jvm-arguments="-Djava.util.logging.manager=org.jboss.logmanager.LogManager","-Doperator.keycloak.image=${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak:${{ steps.vars.outputs.version }}" \
-Dtest.operator.custom.image=${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/custom-keycloak:${{ steps.vars.outputs.version }} \
--no-transfer-progress -Dtest.operator.deployment=remote \
-Dtest.operator.kubernetes.ip=$(minikube ip)
test-olm:
name: Test OLM installation
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=version::0.0.1-$(git rev-parse --short HEAD)"
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: ${{ env.JDK_VERSION }}
cache: 'maven'
- name: Setup Minikube-Kubernetes
uses: manusa/actions-setup-minikube@v2.4.3
with:
minikube version: v1.24.0
kubernetes version: v1.22.3
github token: ${{ secrets.GITHUB_TOKEN }}
driver: docker
start args: '--addons=ingress'
- name: Login to docker registry
uses: docker/login-action@v1.14.1
with:
registry: ${{ secrets.TEST_DOCKER_REGISTRY }}
username: ${{ secrets.TEST_DOCKER_USERNAME }}
password: ${{ secrets.TEST_DOCKER_TOKEN }}
- name: Build and push the operator image
working-directory: operator
run: |
mvn clean package \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.image="${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }}/keycloak-operator:${{ steps.vars.outputs.version }}" \
-Dquarkus.container-image.labels."\"quay.expires-after\""="20h" \
-DskipTests
- name: Install OPM
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
opm: "1.21.0"
- name: Install Yq
run: sudo snap install yq
- name: Install OLM
working-directory: operator
run: ./scripts/install-olm.sh
- name: Prepare resources for testing on OLM
working-directory: operator
run: |
./scripts/prepare-olm-test.sh ${{ secrets.TEST_DOCKER_REGISTRY }}/${{ secrets.TEST_DOCKER_REPOSITORY }} ${{ steps.vars.outputs.version }} NONE
- name: Install the operator with OLM
working-directory: operator
run: ./scripts/install-keycloak-operator.sh
- name: Deploy an example Keycloak and wait for it to be ready
working-directory: operator
run: |
kubectl apply -f src/main/resources/example-postgres.yaml
./scripts/check-crds-installed.sh
kubectl apply -f src/main/resources/example-keycloak.yml
kubectl apply -f src/main/resources/example-realm.yaml
# Wait for the CRs to be ready
./scripts/check-examples-installed.sh