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

V3 next #797

Merged
merged 7 commits into from
Nov 25, 2023
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
16 changes: 8 additions & 8 deletions .github/workflows/gandalf.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Eno V3 test

on:
pull_request:
branches:
- 'v3-main'
- 'v3-next'
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore: ['docs/**', 'logo/**', 'Dockerfile', 'README**.md']
on: workflow_dispatch # replaced by sonar workflow
# pull_request:
# branches:
# - 'v3-main'
# - 'v3-next'
# types: [opened, synchronize, reopened, ready_for_review]
# paths-ignore: ['docs/**', 'logo/**', 'Dockerfile', 'README**.md']

jobs:
test:
if: ${{ (github.event.pull_request.draft == false) && !contains(github.event.pull_request.labels.*.name, 'deploy-snapshot') }}
# if: ${{ (github.event.pull_request.draft == false) && !contains(github.event.pull_request.labels.*.name, 'deploy-snapshot') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test and Sonar Analysis

on:
pull_request:
branches:
- 'v3-main'
- 'v3-next'
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore: ['docs/**', 'logo/**', 'Dockerfile', 'README**.md']

jobs:
build:
if: ${{ (github.event.pull_request.draft == false) && !contains(github.event.pull_request.labels.*.name, 'deploy-snapshot') }}
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew clean build test codeCoverageReport
58 changes: 56 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@ plugins {
id 'net.saliman.properties' version '1.5.2'
id 'java'
id 'org.springframework.boot' version '3.1.5' apply false
id 'io.spring.dependency-management' version '1.1.3' apply false
id 'io.spring.dependency-management' version '1.1.4' apply false
id 'jacoco'
id "org.sonarqube" version "4.4.1.3373"
}

allprojects {
group = 'fr.insee.eno'
version = '3.12.0'
version = '3.12.4'
sourceCompatibility = '17'
}

subprojects {
apply plugin: 'org.sonarqube'
sonar {
properties {
property 'sonar.coverage.jacoco.xmlReportPaths', "$projectDir.parentFile.path/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
}
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
}

compileJava {
options.release = 17
}
Expand All @@ -22,6 +35,47 @@ subprojects {
}
}

apply from: "$project.rootDir/sonar.gradle"

// See here for more info: https://docs.gradle.org/6.4-rc-1/samples/sample_jvm_multi_project_with_code_coverage.html
//
// task to gather code coverage from multiple subprojects
// NOTE: the `JacocoReport` tasks do *not* depend on the `test` task by default. Meaning you have to ensure
// that `test` (or other tasks generating code coverage) run before generating the report.
// You can achieve this by calling the `test` lifecycle task manually
// $ ./gradlew test codeCoverageReport
tasks.register("codeCoverageReport", JacocoReport) {
// If a subproject applies the 'jacoco' plugin, add the result it to the report
subprojects { subproject ->
subproject.plugins.withType(JacocoPlugin).configureEach {
subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).configureEach { testTask ->
//the jacoco extension may be disabled for some projects
if (testTask.extensions.getByType(JacocoTaskExtension).isEnabled()) {
sourceSets subproject.sourceSets.main
executionData(testTask)
} else {
logger.warn('Jacoco extension is disabled for test task \'{}\' in project \'{}\'. this test task will be excluded from jacoco report.',testTask.getName(),subproject.getName())
}
}

// To automatically run `test` every time `./gradlew codeCoverageReport` is called,
// you may want to set up a task dependency between them as shown below.
// Note that this requires the `test` tasks to be resolved eagerly (see `forEach`) which
// may have a negative effect on the configuration time of your build.
subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).forEach {
rootProject.tasks.codeCoverageReport.dependsOn(it)
}
}
}

// enable the different report types (html, xml, csv)
reports {
xml.required = true
html.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}

tasks.register('printVersion') {
doLast {
println project.version
Expand Down
2 changes: 1 addition & 1 deletion ddi-beans/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jar {
description = 'ddi-beans'

dependencies {
api 'org.apache.xmlbeans:xmlbeans:5.1.1'
api 'org.apache.xmlbeans:xmlbeans:5.2.0'
implementation 'org.apache.logging.log4j:log4j-core'
}

Expand Down
1 change: 1 addition & 0 deletions eno-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'io.spring.dependency-management'
id 'java-library'
id 'maven-publish'
id 'jacoco'
}

// https://stackoverflow.com/a/61671513/13425151
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public enum Context {HOUSEHOLD, BUSINESS, DEFAULT}
public enum ModeParameter {CAPI, CATI, CAWI, PAPI, PROCESS}
public enum Language {FR, EN, IT, ES, DE}
public enum QuestionNumberingMode {NONE, SEQUENCE, ALL}
public enum LunaticPaginationMode {NONE, SEQUENCE, QUESTION}

public static final String DEFAULT_CAMPAIGN_NAME = "test-2020-x00";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
@Setter
public class LunaticParameters {

public enum LunaticPaginationMode {NONE, SEQUENCE, QUESTION}

private boolean controls;
private boolean toolTip; // Not implemented yet in Lunatic
private boolean missingVariables;
private boolean filterResult;
private boolean filterDescription;
private EnoParameters.LunaticPaginationMode lunaticPaginationMode;
private LunaticPaginationMode lunaticPaginationMode;

private LunaticParameters() {}

Expand Down Expand Up @@ -41,8 +43,8 @@ private void lunaticValues(EnoParameters.Context context, EnoParameters.ModePara
this.setMissingVariables(isInterview);
this.setLunaticPaginationMode(
EnoParameters.Context.BUSINESS.equals(context) ?
EnoParameters.LunaticPaginationMode.SEQUENCE :
EnoParameters.LunaticPaginationMode.QUESTION);
LunaticPaginationMode.SEQUENCE :
LunaticPaginationMode.QUESTION);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ private int insertSequenceInLoop(
private void insertComponentsInLoop(
Questionnaire lunaticQuestionnaire, Loop lunaticLoop, String sequenceReference) {
AbstractSequence enoSequence = (AbstractSequence) enoIndex.get(sequenceReference);
enoSequence.getSequenceStructure().forEach(structureItemReference ->
relocateComponent(lunaticQuestionnaire, lunaticLoop, structureItemReference.getId()));
enoSequence.getSequenceStructure().forEach(structureItemReference -> {
relocateComponent(lunaticQuestionnaire, lunaticLoop, structureItemReference.getId());
if (StructureItemType.SUBSEQUENCE.equals(structureItemReference.getType()))
insertComponentsInLoop(lunaticQuestionnaire, lunaticLoop, structureItemReference.getId());
});
}

/** Relocate the component with given reference (id) from the questionnaire's components
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package fr.insee.eno.core.processing.out.steps.lunatic.pagination;

import fr.insee.eno.core.parameter.EnoParameters;
import fr.insee.eno.core.parameter.LunaticParameters;
import fr.insee.eno.core.processing.ProcessingStep;
import fr.insee.lunatic.model.flat.Questionnaire;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LunaticAddPageNumbers implements ProcessingStep<Questionnaire> {

private final EnoParameters.LunaticPaginationMode mode;
private final LunaticParameters.LunaticPaginationMode mode;

public LunaticAddPageNumbers(EnoParameters.LunaticPaginationMode mode) {
public LunaticAddPageNumbers(LunaticParameters.LunaticPaginationMode mode) {
this.mode = mode;
}

Expand All @@ -37,7 +37,7 @@ public void apply(Questionnaire lunaticQuestionnaire) {
}

// TODO: enum in Lunatic-Model for this...
public static String lunaticNumberingMode(EnoParameters.LunaticPaginationMode paginationMode) {
public static String lunaticNumberingMode(LunaticParameters.LunaticPaginationMode paginationMode) {
return switch (paginationMode) {
case NONE -> "none";
case SEQUENCE -> "sequence";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void applyNumPageOnLoop(Loop loop, String numPagePrefix, int pageCount) {
.count();

loop.setMaxPage(Long.toString(maxPage));
}
} // Note: shouldn't be max page equal to "1" if non paginated loop?
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static String rawSerialization(Questionnaire lunaticQuestionnaire) {
* @return json string of the questionnaire with resize included
* @throws LunaticSerializationException serialization exception
*/
public static String extendedSerialization(String lunaticJson, Questionnaire lunaticQuestionnaire)
private static String extendedSerialization(String lunaticJson, Questionnaire lunaticQuestionnaire)
throws LunaticSerializationException {
ObjectMapper mapper = new ObjectMapper();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void lunaticParameters_DefaultCAWILunatic_testLunaticValues() {
assertFalse(lunaticParameters.isFilterDescription());
assertTrue(lunaticParameters.isFilterResult());
assertFalse(lunaticParameters.isMissingVariables());
assertEquals(EnoParameters.LunaticPaginationMode.QUESTION, lunaticParameters.getLunaticPaginationMode());
assertEquals(LunaticParameters.LunaticPaginationMode.QUESTION, lunaticParameters.getLunaticPaginationMode());
}

@Test
Expand Down Expand Up @@ -65,7 +65,7 @@ void parameters_BusinessCAPILunatic_lunaticPagination() {
EnoParameters.Context.BUSINESS, EnoParameters.ModeParameter.CAPI, Format.LUNATIC);
//
LunaticParameters lunaticParameters = enoParameters.getLunaticParameters();
assertEquals(EnoParameters.LunaticPaginationMode.SEQUENCE, lunaticParameters.getLunaticPaginationMode());
assertEquals(LunaticParameters.LunaticPaginationMode.SEQUENCE, lunaticParameters.getLunaticPaginationMode());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fr.insee.eno.core.mappers.LunaticMapper;
import fr.insee.eno.core.model.EnoQuestionnaire;
import fr.insee.eno.core.parameter.EnoParameters;
import fr.insee.eno.core.parameter.LunaticParameters;
import fr.insee.eno.core.processing.common.steps.EnoAddPrefixInQuestionLabels;
import fr.insee.eno.core.processing.common.steps.EnoAddResponseTimeSection;
import fr.insee.eno.core.processing.out.steps.lunatic.pagination.LunaticAddPageNumbers;
Expand Down Expand Up @@ -31,7 +32,7 @@ void questionPaginationMode_hoursAndMinutesQuestionShouldHaveTheSameNumber() {
LunaticMapper lunaticMapper = new LunaticMapper();
lunaticMapper.mapQuestionnaire(enoQuestionnaire, lunaticQuestionnaire);
//
new LunaticAddPageNumbers(EnoParameters.LunaticPaginationMode.QUESTION).apply(lunaticQuestionnaire);
new LunaticAddPageNumbers(LunaticParameters.LunaticPaginationMode.QUESTION).apply(lunaticQuestionnaire);

// When
new LunaticResponseTimeQuestionPagination().apply(lunaticQuestionnaire);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ void init() {

questionnaire.getComponents().addAll(components);

//JSONSerializer jsonSerializer = new JSONSerializer();
//System.out.println(jsonSerializer.serialize2(questionnaire));
processing.apply(questionnaire);
//System.out.println(jsonSerializer.serialize2(questionnaire));
}

@Test
Expand Down Expand Up @@ -139,7 +136,7 @@ void shouldComponentsInPairwiseLinksToHaveSamePage() {
}

@Test
void shouldComponentsInPaginatedLoopToHaveDifferentsPage() {
void shouldComponentsInPaginatedLoopToHaveDifferentPage() {
// l7 is paginated loop so we'll increment subcomponents
assertTrue(l7.getPaginatedLoop());
assertEquals("7", l7.getPage());
Expand Down
Loading