Skip to content

Commit

Permalink
Merge branch 'master' into issue-26520-implement-translations-on-bloc…
Browse files Browse the repository at this point in the history
…k-editor
  • Loading branch information
oidacra authored Dec 4, 2023
2 parents 36b21d5 + c588fe9 commit d30e4c9
Show file tree
Hide file tree
Showing 7 changed files with 667 additions and 2 deletions.
213 changes: 213 additions & 0 deletions .github/workflows/maven-build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: Maven Build Docker Image
on:
workflow_call:
inputs:
ref:
description: 'Ref to checkout'
required: true
type: string
docker_platforms:
description: 'Docker platforms to build the image on'
required: true
type: string
default: 'linux/amd64'
docker_context_cache_key:
description: 'Cache key for the docker context'
required: true
type: string
docker_registry:
description: 'Docker registry to push the image to'
required: true
type: choice
options:
- DOCKER.IO
- GHCR.IO
- BOTH
default: 'DOCKER.IO'
jobs:
build_push_image:
name: Build and Push Image
runs-on: ubuntu-latest
env:
JAVA_VERSION: 11
JAVA_DISTRO: temurin
JVM_TEST_MAVEN_OPTS: '-e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
DOCKER_BUILD_CONTEXT: /home/runner/work/_temp/core-build
outputs:
tags: ${{ steps.meta.outputs.tags }}
if: success()
steps:
- name: Checkout core
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}

- name: Restore Docker Context
id: restore-docker-context
uses: actions/cache/restore@v3
with:
path: ${{ env.DOCKER_BUILD_CONTEXT }}/context
key: ${{ inputs.docker_context_cache_key }}
if: inputs.docker_context_cache_key != ''

- name: Build Status
id: build-status
run: |
rebuild=false
if [[ -z "${{ inputs.docker_context_cache_key }}" || ! -d ${DOCKER_BUILD_CONTEXT}/context ]]; then
rebuild=true
fi
echo "rebuild=${rebuild}" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
if: steps.build-status.outputs.rebuild == 'true'

- name: Build Core
run: |
mkdir -p ${DOCKER_BUILD_CONTEXT}/context
./mvnw -ntp \
${JVM_TEST_MAVEN_OPTS} \
-Dprod=true \
-Ddocker.buildArchiveOnly=${DOCKER_BUILD_CONTEXT} \
-DskipTests=true \
-DskipITs=true \
clean install \
--file pom.xml \
--show-version
rc=$?
if [[ $rc != 0 ]]; then
echo "Build failed with exit code $rc"
exit $rc
fi
if: steps.build-status.outputs.rebuild == 'true'

- name: Set Common Vars
id: set-common-vars
run: |
build_version=master
build_properties=${DOCKER_BUILD_CONTEXT}/context/maven/dotserver/tomcat-9.0.60/webapps/ROOT/WEB-INF/classes/build.properties
if [[ -f ${build_properties} ]]; then
version=$(cat ${build_properties} | grep version | cut -d'=' -f2)
if [[ ! ${version} =~ ^[0-9]{1}.[0-9]{1}.[0-9]{1}-SNAPSHOT$ ]]; then
build_version=${build_version}
fi
build_hash=$(cat ${build_properties} | grep revision | cut -d'=' -f2)
if [[ ! ${build_hash} =~ ^[0-9a-f]{7}$ ]]; then
build_hash=$(git log -1 --pretty=%h)
build_hash=${build_hash::7}
fi
fi
build_id=${{ inputs.ref }}
is_trunk=false
if [[ "${build_id}" == 'master' || ${build_id} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}_lts$ ]]; then
is_trunk=true
fi
is_lts=false
if [[ ${build_version} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}_lts(_v[0-9]{2})?$ ]]; then
is_lts=true
fi
version=${build_version}
is_snapshot=false
is_release=false
is_latest=false
is_custom=false
if [[ ${build_version} =~ ^[0-9]{1}.[0-9]{1}.[0-9]{1}-SNAPSHOT$ ]]; then
if [[ "${is_trunk}" == 'true' ]]; then
is_snapshot=true
version=${build_id}
fi
elif [[ ${build_version} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}$ ]]; then
is_release=true
is_latest=true
elif [[ ${build_version} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}_lts$ ]]; then
is_snapshot=true
version=${build_id}
elif [[ ${build_version} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}_lts_v[0-9]{2}$ ]]; then
is_release=true
else
is_custom=true
version=${build_id}
fi
echo "version=${version}" >> $GITHUB_OUTPUT
echo "build_hash=${build_hash}" >> $GITHUB_OUTPUT
echo "build_id=${build_id}" >> $GITHUB_OUTPUT
echo "is_trunk=${is_trunk}" >> $GITHUB_OUTPUT
echo "is_lts=${is_lts}" >> $GITHUB_OUTPUT
echo "is_snapshot=${is_snapshot}" >> $GITHUB_OUTPUT
echo "is_release=${is_release}" >> $GITHUB_OUTPUT
echo "is_latest=${is_latest}" >> $GITHUB_OUTPUT
echo "is_custom=${is_custom}" >> $GITHUB_OUTPUT
# Tag detected means release
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
dotcms/dotcms
tags: |
type=raw,value=${{ steps.set-common-vars.outputs.version }}_{{sha}},enable=true
type=raw,value=${{ steps.set-common-vars.outputs.version }}_SNAPSHOT,enable=${{ steps.set-common-vars.outputs.is_snapshot == true }}
type=raw,value=${{ steps.set-common-vars.outputs.version }},enable=${{ steps.set-common-vars.outputs.is_release == true }}
type=raw,value=latest,enable=${{ steps.set-common-vars.outputs.is_latest == true }}
type=raw,value={{sha}},enable=${{ steps.set-common-vars.outputs.is_latest == true }}
- name: Debug Docker Metadata
run: |
echo "${{ fromJSON(steps.meta.outputs.json) }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
with:
image: tonistiigi/binfmt:latest
platforms: ${{ input.docker_platforms }}

- name: Docker Setup Buildx
id: docker-setup-buildx
uses: docker/setup-buildx-action@v3.0.0
with:
version: latest
platforms: ${{ inputs.docker_platforms }}
driver-opts: |
image=moby/buildkit:v0.12.2
- name: Docker Hub login
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
if: docker_registry == 'DOCKER.IO' || docker_registry == 'BOTH'

- name: GHCR login
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
if: docker_registry == 'GHCR.IO' || docker_registry == 'BOTH'

- name: Build Docker Image
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_BUILD_CONTEXT }}/context
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ inputs.docker_platforms }}
pull: true
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
if: success()
Original file line number Diff line number Diff line change
Expand Up @@ -4291,11 +4291,155 @@ public void countAllWorkflowSteps() throws DotDataException, DotSecurityExceptio
* @throws DotDataException
*/
@Test(expected = DotSecurityException.class)
public void countSteosWithLimitedUser() throws DotDataException, DotSecurityException {
public void countStepsWithLimitedUser() throws DotDataException, DotSecurityException {
final User user = new UserDataGen().nextPersisted();
APILocator.getWorkflowAPI().countAllSchemasSteps(user);
}

/**
* Method to test: {@link WorkflowAPIImpl#countAllSchemasActions(User)}
* When: create a new Workflow with 4 actions
* Should: the count must be 4 more than before
*
* @throws DotDataException
*/
@Test
public void countAllWorkflowActions() throws DotDataException, DotSecurityException {

final long firstCount = APILocator.getWorkflowAPI().countAllSchemasActions(APILocator.systemUser());

final List<Tuple2<String, List<Tuple3<String, String, Set<WorkflowState>>>>> workflowStepsAndActions = Arrays
.asList(
Tuple.of("Editing",
Arrays.asList(
// First component of the Tuple is the desired Action-Name.
// The Second Component is The Next-Step we desire to be pointed to by the current action.
// Third is the show-When definition.
Tuple.of("Save as Draft", "Current Step", EnumSet.of(EDITING, UNLOCKED, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of("Send for Review", "Review", EnumSet.of(EDITING, UNLOCKED, NEW, UNPUBLISHED))
)
),
Tuple.of("Review",
Arrays.asList(
Tuple.of("Save as Draft", "Current Step", EnumSet.of(EDITING, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of("Return for Edits", "Editing", EnumSet.of(LISTING, UNLOCKED, NEW, PUBLISHED, UNPUBLISHED))
)
)
);

final WorkflowScheme workflow_1= new WorkflowDataGen()
.stepAndAction(workflowStepsAndActions).nextPersistedWithStepsAndActions();

final long secondCount = APILocator.getWorkflowAPI().countAllSchemasActions(APILocator.systemUser());
assertEquals(firstCount + 3, secondCount);

final WorkflowScheme workflow_2 = new WorkflowDataGen()
.stepAndAction(workflowStepsAndActions).nextPersistedWithStepsAndActions();

final long thirdCount = APILocator.getWorkflowAPI().countAllSchemasActions(APILocator.systemUser());
assertEquals(secondCount + 3, thirdCount);
}

/**
* Method to test: {@link WorkflowAPIImpl#countAllSchemasActions(User)}
* When: Try to count Steos with limited USer
* Should: throw a {@link DotSecurityException}
*
* @throws DotDataException
*/
@Test(expected = DotSecurityException.class)
public void countActionsWithLimitedUser() throws DotDataException, DotSecurityException {
final User user = new UserDataGen().nextPersisted();
APILocator.getWorkflowAPI().countAllSchemasActions(user);
}

/**
* Method to test: {@link WorkflowAPIImpl#countAllSchemasSubActions(User)}
* When: create a new Workflow with 7 Sub actions
* Should: the count must be 7 more than before
*
* @throws DotDataException
*/
@Test
public void countAllWorkflowSubActions() throws DotDataException, DotSecurityException {

final String workflow_step_1 = "countAllWorkflowSubActions_step_1_" + System.currentTimeMillis();
final String workflow_step_2 = "countAllWorkflowSubActions_step_2_" + System.currentTimeMillis();
final String workflow_step_3 = "countAllWorkflowSubActions_step_3_" + System.currentTimeMillis();
final String workflow_step_4 = "countAllWorkflowSubActions_step_4_" + System.currentTimeMillis();

final String workflow_action_1 = "countAllWorkflowSubActions_action_1_" + System.currentTimeMillis();
final String workflow_action_2 = "countAllWorkflowSubActions_action_2_" + System.currentTimeMillis();
final String workflow_action_3 = "countAllWorkflowSubActions_action_3_" + System.currentTimeMillis();
final String workflow_action_4 = "countAllWorkflowSubActions_action_4_" + System.currentTimeMillis();
final String workflow_action_5 = "countAllWorkflowSubActions_action_5_" + System.currentTimeMillis();
final String workflow_action_6 = "countAllWorkflowSubActions_action_6_" + System.currentTimeMillis();
final String workflow_action_7 = "countAllWorkflowSubActions_action_7_" + System.currentTimeMillis();
final String workflow_action_8 = "countAllWorkflowSubActions_action_8_" + System.currentTimeMillis();

final List<Tuple2<String, List<Tuple3<String, String, Set<WorkflowState>>>>> workflowStepsAndActions_1 = Arrays
.asList(
Tuple.of(workflow_step_1,
Arrays.asList(
// First component of the Tuple is the desired Action-Name.
// The Second Component is The Next-Step we desire to be pointed to by the current action.
// Third is the show-When definition.
Tuple.of(workflow_action_1, "Current Step", EnumSet.of(EDITING, UNLOCKED, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of(workflow_action_2, workflow_step_2, EnumSet.of(EDITING, UNLOCKED, NEW, UNPUBLISHED))
)
),
Tuple.of(workflow_step_2,
Arrays.asList(
Tuple.of(workflow_action_3, "Current Step", EnumSet.of(EDITING, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of(workflow_action_4, workflow_step_1, EnumSet.of(LISTING, UNLOCKED, NEW, PUBLISHED, UNPUBLISHED))
)
)
);

final long firstCount = APILocator.getWorkflowAPI().countAllSchemasSubActions(APILocator.systemUser());

final WorkflowScheme workflow_1 = new WorkflowDataGen()
.stepAndAction(workflowStepsAndActions_1).nextPersistedWithStepsAndActions();

final List<WorkflowAction> actions_1 = APILocator.getWorkflowAPI().findActions(workflow_1, APILocator.systemUser());
new WorkflowActionClassDataGen(actions_1.get(0).getId()).nextPersisted();
new WorkflowActionClassDataGen(actions_1.get(0).getId()).nextPersisted();
new WorkflowActionClassDataGen(actions_1.get(1).getId()).nextPersisted();

final long secondCount = APILocator.getWorkflowAPI().countAllSchemasSubActions(APILocator.systemUser());
assertEquals(firstCount + 7, secondCount);

final List<Tuple2<String, List<Tuple3<String, String, Set<WorkflowState>>>>> workflowStepsAndActions_2 = Arrays
.asList(
Tuple.of(workflow_step_3,
Arrays.asList(
// First component of the Tuple is the desired Action-Name.
// The Second Component is The Next-Step we desire to be pointed to by the current action.
// Third is the show-When definition.
Tuple.of(workflow_action_5, "Current Step", EnumSet.of(EDITING, UNLOCKED, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of(workflow_action_6, workflow_step_4, EnumSet.of(EDITING, UNLOCKED, NEW, UNPUBLISHED))
)
),
Tuple.of(workflow_step_4,
Arrays.asList(
Tuple.of(workflow_action_7, "Current Step", EnumSet.of(EDITING, LOCKED, NEW, PUBLISHED, UNPUBLISHED)),
Tuple.of(workflow_action_8, workflow_step_3, EnumSet.of(LISTING, UNLOCKED, NEW, PUBLISHED, UNPUBLISHED))
)
)
);

final WorkflowScheme workflow_2 = new WorkflowDataGen()
.stepAndAction(workflowStepsAndActions_2).nextPersistedWithStepsAndActions();

final List<WorkflowAction> actions_2 = APILocator.getWorkflowAPI().findActions(workflow_2, APILocator.systemUser());
new WorkflowActionClassDataGen(actions_2.get(2).getId()).nextPersisted();
new WorkflowActionClassDataGen(actions_2.get(2).getId()).nextPersisted();
new WorkflowActionClassDataGen(actions_2.get(2).getId()).nextPersisted();

final long thirdCount = APILocator.getWorkflowAPI().countAllSchemasSubActions(APILocator.systemUser());
assertEquals(secondCount + 7, thirdCount);
}

private static List<Tuple2<String, List<Tuple3<String, String, Set<WorkflowState>>>>> getStepsAndActions() {
final List<Tuple2<String, List<Tuple3<String, String, Set<WorkflowState>>>>> workflowStepsAndActions = Arrays
.asList(
Expand Down
Loading

0 comments on commit d30e4c9

Please sign in to comment.