Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckCo committed Feb 14, 2024
2 parents f5caef7 + 8fc18a5 commit 5039d3c
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 138 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/ci-pr.yml

This file was deleted.

96 changes: 84 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,54 @@ name: Trevas CI

on:
push:
branches:
- master
- develop
- "feature/**"
paths-ignore:
- "docs/**"
pull_request:
types: [opened, synchronize, reopened]
branches:
- "master"
- "develop"

jobs:
build:
test:
# Fork or Trevas main repo branch with PR coming from fork
if: github.repository != 'inseefr/trevas' ||
github.event.pull_request.head.repo.full_name != 'inseefr/trevas'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- name: Test
run: mvn test
package:
# Fork or Trevas main repo branch with PR coming from fork
if: github.repository != 'inseefr/trevas' ||
github.event.pull_request.head.repo.full_name != 'inseefr/trevas'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- name: Test
run: mvn package
test-sonar-package:
# Trevas main repo branch with PR coming from main repo
if: github.repository == 'inseefr/trevas' &&
github.event.pull_request.head.repo.full_name == 'inseefr/trevas'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
Expand All @@ -31,3 +58,48 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
publish-release:
if: github.repository == 'inseefr/trevas' &&
startsWith(github.event.ref, 'refs/tags/v')
needs: test-sonar-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish Trevas
run: mvn -B -Prelease deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
publish-snapshot:
if: github.repository == 'inseefr/trevas' &&
github.ref == 'refs/heads/develop'
needs: package
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- name: Publish package
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.defaultLogLevel='warn'
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:
- "docs/**"
jobs:
deploy:
if: github.repository == 'inseefr/trevas'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.19.0
- name: Install dependencies
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/publish-maven.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/publish-snapshot.yml

This file was deleted.

24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contributing to Trevas

Interested in contributing to Trevas? Here's how to get started!

_First minimal version to improve_

## Contribution Guideline

### TDD

TODO

### Code formatting

TODO

## Creating a pull request

Pull requests have to come from branch prefixed by `feature/` or `fix/`.

Ideally, pull requests contain a reference to a previously filled [Trevas issue](https://github.com/InseeFr/Trevas/issues).

Your submissions must be targeted at the `develop` branch of the [main Trevas repository](https://github.com/InseeFr/Trevas).

14 changes: 7 additions & 7 deletions coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>fr.insee.trevas</groupId>
<artifactId>trevas-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>coverage</artifactId>
Expand All @@ -22,32 +22,32 @@
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-engine</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-jackson</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-jdbc</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-model</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-parser</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-spark</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
</dependencies>
<build>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>fr.insee.trevas</groupId>
<artifactId>trevas-parent</artifactId>
<packaging>pom</packaging>
<version>1.3.0</version>
<version>1.3.1</version>
<modules>
<module>vtl-parser</module>
<module>vtl-model</module>
Expand Down
8 changes: 4 additions & 4 deletions vtl-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>fr.insee.trevas</groupId>
<artifactId>trevas-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>vtl-engine</artifactId>
<name>VTL Engine</name>
<description>VTL engine framework for Trevas</description>
<version>1.3.0</version>
<version>1.3.1</version>

<properties>
<sonar.coverage.jacoco.xmlReportPaths>
Expand All @@ -25,13 +25,13 @@
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-parser</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-model</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package fr.insee.vtl.engine;

import com.github.hervian.reflection.Fun;
import fr.insee.vtl.engine.visitors.expression.ArithmeticExprOrConcatVisitor;
import fr.insee.vtl.engine.visitors.expression.ArithmeticVisitor;
import fr.insee.vtl.engine.visitors.expression.BooleanVisitor;
import fr.insee.vtl.engine.visitors.expression.ComparisonVisitor;
import fr.insee.vtl.engine.visitors.expression.ConditionalVisitor;
import fr.insee.vtl.engine.visitors.expression.UnaryVisitor;
import fr.insee.vtl.engine.visitors.expression.*;
import fr.insee.vtl.engine.visitors.expression.functions.ComparisonFunctionsVisitor;
import fr.insee.vtl.engine.visitors.expression.functions.DistanceFunctionsVisitor;
import fr.insee.vtl.engine.visitors.expression.functions.NumericFunctionsVisitor;
Expand Down Expand Up @@ -47,6 +42,8 @@ public class VtlNativeMethods {
Fun.<Boolean, Boolean, Boolean>toMethod(ConditionalVisitor::ifThenElse),
Fun.<Long, Long>toMethod(ConditionalVisitor::nvl),
Fun.<Double, Double>toMethod(ConditionalVisitor::nvl),
Fun.<Double, Long>toMethod(ConditionalVisitor::nvl),
Fun.<Long, Double>toMethod(ConditionalVisitor::nvl),
Fun.<String, String>toMethod(ConditionalVisitor::nvl),
Fun.<Boolean, Boolean>toMethod(ConditionalVisitor::nvl),
// ArithmeticVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public static Double nvl(Double value, Double defaultValue) {
return value == null ? defaultValue : value;
}

public static Double nvl(Double value, Long defaultValue) {
return value == null ? defaultValue.doubleValue() : value;
}
public static Double nvl(Long value, Double defaultValue) {
return value == null ? defaultValue : value.doubleValue();
}
public static String nvl(String value, String defaultValue) {
return value == null ? defaultValue : value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public void testNvlExpr() throws ScriptException {
.hasMessage("function 'nvl(Long, String)' not found");
}

@Test
public void testNvlImplicitCast() throws ScriptException {
ScriptContext context = engine.getContext();
engine.eval("s := nvl(0, 1.1);");
assertThat(context.getAttribute("s")).isEqualTo(0D);
engine.eval("s := nvl(1.1, 0);");
assertThat(context.getAttribute("s")).isEqualTo(1.1D);

engine.getContext().setAttribute("ds", DatasetSamples.ds1, ScriptContext.ENGINE_SCOPE);
engine.eval("res := nvl(ds[keep id, long1], 0.1);");
var res = engine.getContext().getAttribute("res");
assertThat(((Dataset) res).getDataAsMap()).containsExactlyInAnyOrder(
Map.of("id", "Toto", "long1", 30D),
Map.of("id", "Hadrien", "long1", 10D),
Map.of("id", "Nico", "long1", 20D),
Map.of("id", "Franck", "long1", 100D)
);
assertThat(((Dataset) res).getDataStructure().get("long1").getType()).isEqualTo(Double.class);
}

@Test
public void testIfTypeExceptions() {
assertThatThrownBy(() -> {
Expand Down
Loading

0 comments on commit 5039d3c

Please sign in to comment.