Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from Christopher-Chianelli/rename-to-timefold
Browse files Browse the repository at this point in the history
Rename packages and update dependencies to use Timefold
  • Loading branch information
Christopher-Chianelli authored Feb 29, 2024
2 parents f734b62 + 8919673 commit cc21658
Show file tree
Hide file tree
Showing 450 changed files with 76,410 additions and 10 deletions.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
time: '03:00'
open-pull-requests-limit: 10
target-branch: "main"
commit-message:
prefix: "[bot]"

- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: '03:00'
open-pull-requests-limit: 10
target-branch: "main"
commit-message:
prefix: "[bot]"

83 changes: 83 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Tests PRs on multiple operating systems and Python/Java versions
name: Test Build

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
paths-ignore:
- 'LICENSE*'
- '.gitignore'
- '**.md'
- '**.adoc'
- '*.txt'
- '.ci/**'

defaults:
run:
shell: bash

jobs:
test-build:
strategy:
matrix:
os: [ ubuntu-latest ]
java-version: [ 11, 17 ]
maven-version: [ '3.8.6' ]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Java and Maven Setup
uses: kiegroup/kogito-pipelines/.ci/actions/maven@main
with:
java-version: ${{ matrix.java-version }}
maven-version: ${{ matrix.maven-version }}
cache-key-prefix: ${{ runner.os }}-${{ matrix.java-version }}-maven${{ matrix.maven-version }}

# Need to install both Python 3.9, Python 3.10 and Python 3.11 for tox (has to be in the same run)
# Feature Request for setup action: https://github.com/actions/setup-python/issues/98
- name: Python 3.9 Setup
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Python 3.10 Setup
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Python 3.11 Setup
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Install tox
run:
python -m pip install --upgrade pip
pip install tox pytest

- name: Build with Maven to install parent poms for python build
run: mvn -B --fail-at-end clean install

- name: Run tox on optapy test suite
run: python -m tox

- name: Run tox on jpyinterpreter test suite
working-directory: ./jpyinterpreter
run: python -m tox
107 changes: 107 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Runs the SonarCloud analysis of the optapy main branch after a PR is merged.
name: SonarCloud Analysis

on:
push:
branches:
- main
paths-ignore:
- 'LICENSE*'
- '.gitignore'
- '**.md'
- '**.adoc'
- '*.txt'
- '.ci/**'

defaults:
run:
shell: bash

jobs:
sonarcloud-analysis:
strategy:
matrix:
os: [ ubuntu-latest ]
java-version: [ 17 ] # JaCoCo segfaults Java 11 JVM but not Java 17 JVM when Python tests finish
maven-version: [ '3.8.6' ]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Java and Maven Setup
uses: kiegroup/kogito-pipelines/.ci/actions/maven@main
with:
java-version: ${{ matrix.java-version }}
maven-version: ${{ matrix.maven-version }}
cache-key-prefix: ${{ runner.os }}-${{ matrix.java-version }}-maven${{ matrix.maven-version }}

# Need to install both Python 3.9, Python 3.10 and Python 3.11 for tox (has to be in the same run)
# Feature Request for setup action: https://github.com/actions/setup-python/issues/98
- name: Python 3.9 Setup
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Python 3.10 Setup
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Python 3.11 Setup
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
**/setup.py
- name: Install tox
run:
python -m pip install --upgrade pip
pip install tox coverage pytest pytest-cov

- name: Build with Maven to measure code coverage
run: mvn -B --fail-at-end clean install -Prun-code-coverage

- name: Get JaCoCo Agent
run: mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.jacoco:org.jacoco.agent:0.8.8:jar:runtime -Ddest=target/jacocoagent.jar

- name: Run tox to measure optapy code coverage from Python tests
continue-on-error: true # Sometimes the JVM segfaults on SUCCESSFUL tests with Java 17 (and always with Java 11)
run: python -m tox -- --cov=optapy --cov-report=xml:target/coverage.xml --cov-config=tox.ini --cov-branch --cov-append --jacoco-agent=./target/jacocoagent.jar

- name: Run tox to measure jpyinterpreter code coverage from Python tests
continue-on-error: true # Sometimes the JVM segfaults on SUCCESSFUL tests with Java 17 (and always with Java 11)
working-directory: ./jpyinterpreter
run: python -m tox -- --cov=jpyinterpreter --cov-report=xml:target/coverage.xml --cov-config=tox.ini --cov-branch --cov-append --jacoco-agent=../target/jacocoagent.jar --jacoco-output=../target/jacoco.exec

# Because we are using JPype, and JPype add it own import hook, we need to use --import-mode=importlib in pytest
# This seems to create an issue in test coverage, where it reports coverage inside the tox virtual environment,
# instead of coverage inside sources. For instance, for a package, it will report:
# package name=".tox.py39.lib.python3.9.site-packages.jpyinterpreter"
# and for a file it will report:
# class name="jvm_setup.py" filename=".tox/py39/lib/python3.9/site-packages/jpyinterpreter/jvm_setup.py"
# We need to convert the package and file names into their true names; i.e. for the example above:
# package name="jpyinterpreter"
# class name="jvm_setup.py" filename="jpyinterpreter/src/main/python/jvm_setup.py"
# fix-coverage-paths.py is a Python script that does the above transformation for us and merge the two
# separate coverage files into one.
- name: Fix Python test coverage paths
run: python fix-coverage-paths.py

- name: Run SonarCloud analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: mvn -B --fail-at-end validate -Psonarcloud-analysis -Dsonar.projectKey=optapy_optapy -Dsonar.login=${{ env.SONARCLOUD_TOKEN }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
__pycache__
/target
/build
/local
/venv*
graalvenv
/dist
/*.egg-info
/*-stubs

# Eclipse, Netbeans and IntelliJ files
/.*
!.gitignore
!.dockerignore
!.mvn
!.github
/nbproject
*.ipr
*.iws
*.iml
5 changes: 5 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
-Dmaven.wagon.http.retryHandler.requestSentEnabled=true
-Dmaven.wagon.http.retryHandler.count=10
-Dkotlin.environment.keepalive=true
-Xmx5g
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Loading

0 comments on commit cc21658

Please sign in to comment.