Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker-compose): move camuda compose files from camunda/camunda-platform #11

Merged
merged 2 commits into from
Oct 21, 2024
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
46 changes: 46 additions & 0 deletions .github/actions/generate-versions-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Generate version matrix
description: Find changed/unchanged versions and generate matrix for them to be used in GHA workflow matrix.

inputs:
versions-path:
description: Versions path to match.
required: true

outputs:
unchanged:
description: JSON matrix of unchanged versions which will be used as and input for GHA workflow matrix exclude.
value: ${{ steps.get-versions.outputs.matrix-unchanged }}

runs:
using: composite
steps:
- name: Get changed dirs
id: changed-files
uses: tj-actions/changed-files@48d8f15b2aaa3d255ca5af3eba4870f807ce6b3c # v45
with:
dir_names: "true"
- name: Generate matrix
shell: bash
id: get-versions
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
UNCHANGED_VERSIONS_TMP_FILE: unchanged_versions.txt
run: |
echo "Setting matrix based on changed files"
echo "Changed files:"
printf "%s\n" ${ALL_CHANGED_FILES}
touch ${UNCHANGED_VERSIONS_TMP_FILE}

ls -d ${{ inputs.versions-path }} | while read version_dir; do
if [[ $(echo ${ALL_CHANGED_FILES} | grep "${version_dir}") ]]; then
continue
else
camunda_version="$(echo ${version_dir} | rev | cut -d '-' -f 1 | rev)";
echo "Camunda version: ${camunda_version}"
echo "${camunda_version}" >> ${UNCHANGED_VERSIONS_TMP_FILE};
fi
done
# NOTE: The keys "versions" and "camunda-version" are hard-coded and should be used in the workflow matrix.
matrix_unchanged="$(cat ${UNCHANGED_VERSIONS_TMP_FILE} |
jq -s -c -R 'split("\n") | .[:-1] | map({"versions": {"camunda-version": .}})')"
echo "matrix-unchanged=${matrix_unchanged}" | tee -a $GITHUB_OUTPUT
40 changes: 40 additions & 0 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Install Playwright
description: Install Playwright and its dependencies

inputs:
working-directory:
description: Path of Playwright config and tests
browsers:
description: Playwright browsers to install
default: chromium

runs:
using: composite
steps:
- uses: actions/cache@v4
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Check cache hit
shell: bash
run: |
echo "Cache hit: ${{ steps.npm-cache.outputs.cache-hit }}"

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
working-directory: ${{ inputs.working-directory }}
shell: bash
run: npm ci

- name: Install Playwright browsers
working-directory: ${{ inputs.working-directory }}
shell: bash
run: npx playwright install --with-deps ${{ inputs.browsers }}
59 changes: 59 additions & 0 deletions .github/workflows/docker-compose-test-e2e-full-setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Docker Compose | Test - E2E - Full Setup"
on:
push:
branches:
- main
paths:
- docker-compose/versions/**
pull_request:
paths:
- .github/workflows/docker-compose-test-e2e-template.yaml
- .github/workflows/docker-compose-test-e2e-full-setup.yaml
- docker-compose/versions/**

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true

jobs:
init:
name: Generate version matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Generate versions
id: generate-versions-matrix
uses: ./.github/actions/generate-versions-matrix
with:
versions-path: "docker-compose/versions/camunda-8.*"
outputs:
unchanged-versions: ${{ steps.generate-versions-matrix.outputs.unchanged }}

exec:
needs: [init]
name: ${{ matrix.versions.name }}
strategy:
fail-fast: false
matrix:
versions:
- name: Camunda 8.3
camunda-version: "8.3"
compose-args: "-f docker-compose.yaml -f docker-compose-web-modeler.yaml"
- name: Camunda 8.4
camunda-version: "8.4"
compose-args: "-f docker-compose.yaml -f docker-compose-web-modeler.yaml"
- name: Camunda 8.5
camunda-version: "8.5"
compose-args: "-f docker-compose.yaml -f docker-compose-web-modeler.yaml"
- name: Camunda 8.6
camunda-version: "8.6"
compose-args: "--profile full"
- name: Camunda Alpha
camunda-version: "alpha"
compose-args: "--profile full"
exclude: ${{ fromJson(needs.init.outputs.unchanged-versions) }}
uses: ./.github/workflows/docker-compose-test-e2e-template.yaml
secrets: inherit
with:
camunda-version: ${{ matrix.versions.camunda-version }}
compose-args: ${{ matrix.versions.compose-args }}
96 changes: 96 additions & 0 deletions .github/workflows/docker-compose-test-e2e-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: "Docker Compose | Test - E2E - Template"

on:
workflow_call:
inputs:
camunda-version:
description: Camunda minor version in format x.y
required: true
type: string
compose-args:
description: Arguments supplied to Docker Compose
required: true
type: string
e2e-test-enabled:
description: Run Playwright tests
type: boolean
default: true
e2e-test-directory:
description: Directory of the E2E files
required: false
type: string
default: docker-compose/test/e2e
e2e-test-args:
description: Arguments supplied to Playwright
required: false
type: string

env:
COMPOSE_WORKING_DIRECTORY: docker-compose/versions/camunda-${{ inputs.camunda-version }}

jobs:
run:
# if: contains(inputs.changed-versions, inputs.camunda-version)
name: Run
runs-on: ubuntu-latest
steps:
- name: disable and stop mono-xsp4.service
run: |
sudo systemctl stop mono-xsp4.service || true
sudo systemctl disable mono-xsp4.service || true
sudo killall mono || true
sudo killall xsp4 || true

- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker registries
run: |
# DockerHub registry.
echo '${{ secrets.DISTRO_CI_DOCKER_PASSWORD_DOCKERHUB }}' |
docker login -u '${{ secrets.DISTRO_CI_DOCKER_USERNAME_DOCKERHUB }}' --password-stdin
# Camunda registry.
echo '${{ secrets.DISTRO_CI_DOCKER_PASSWORD_CAMUNDA }}' |
docker login -u '${{ secrets.DISTRO_CI_DOCKER_USERNAME_CAMUNDA }}' --password-stdin registry.camunda.cloud

#
# Docker Compose.

- name: Bring up containers
working-directory: ${{ env.COMPOSE_WORKING_DIRECTORY }}
run: |
docker compose ${{ inputs.compose-args }} \
up --quiet-pull -d

- name: Wait until all containers are healthy
timeout-minutes: 5
run: |
while $(docker container ls | grep -q -e 'unhealthy' -e 'health: starting'); do
echo "Some containers are not healthy yet"
docker container ls --format "table {{.Image}}\t{{.Status}}";
sleep 15;
done

#
# End-to-End tests.

- name: Install Playwright
uses: ./.github/actions/install-playwright
if: ${{ inputs.e2e-test-enabled }}
with:
working-directory: ${{ inputs.e2e-test-directory }}

- name: Run Playwright tests
if: ${{ inputs.e2e-test-enabled }}
id: test
working-directory: ${{ inputs.e2e-test-directory }}
run: |
npx playwright test ${{ inputs.e2e-test-args }}

- name: Upload Playwright reports
if: always() && steps.test.conclusion != 'skipped'
uses: actions/upload-artifact@v4
with:
name: docker-compose-playwright-report-${{ inputs.camunda-version }}-${{ steps.test.conclusion }}-${{ github.run_id }}
path: ${{ inputs.e2e-test-directory }}/playwright-report/
retention-days: 30
Loading