This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
Merge pull request #1 from Christopher-Chianelli/rename-to-timefold #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }} |