This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
feat: Improve ScoreAnalysis debug information #90
Workflow file for this run
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 Timefold Solver Python main branch after a PR is merged. | |
name: SonarCloud Analysis | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'LICENSE*' | |
- '.gitignore' | |
- '**.md' | |
- '**.adoc' | |
- '*.txt' | |
- '.ci/**' | |
pull_request_target: # This workflow will be triggered by the opening, reopening, or updating of a PR, and the first run will not require approval. | |
types: | |
- opened | |
- reopened | |
- synchronize | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
sonarcloud-analysis: | |
runs-on: ubuntu-latest | |
steps: | |
# Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. | |
- name: Checkout timefold-solver (PR) # Checkout the PR branch first, if it exists | |
id: checkout-solver | |
uses: actions/checkout@v4 | |
continue-on-error: true | |
with: | |
repository: ${{ github.actor }}/timefold-solver | |
ref: ${{ github.head_ref }} | |
path: ./timefold-solver | |
fetch-depth: 0 # Otherwise merge will fail on account of not having history. | |
- name: Checkout timefold-solver (main) # Checkout the main branch if the PR branch does not exist | |
if: steps.checkout-solver.outcome != 'success' | |
uses: actions/checkout@v4 | |
with: | |
repository: TimefoldAI/timefold-solver | |
ref: main | |
path: ./timefold-solver | |
fetch-depth: 0 # Otherwise merge will fail on account of not having history. | |
- name: Prevent stale fork of timefold-solver | |
env: | |
BLESSED_REPO: "timefold-solver" | |
BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} | |
shell: bash | |
working-directory: ./timefold-solver | |
run: .github/scripts/prevent_stale_fork.sh | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
ref: ${{ github.event.pull_request.head.sha }} # The GHA event will pull the main branch by default, and we must specify the PR reference version | |
path: './timefold-solver-python' | |
# Build and test | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
# Need to install all Python versions in the same run for tox | |
- name: Python 3.10, Python 3.11, Python 3.12 Setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: | | |
3.10 | |
3.11 | |
3.12 | |
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: Quickly build timefold-solver | |
working-directory: ./timefold-solver | |
run: mvn -B -Dquickly clean install | |
- name: Build with Maven to measure code coverage | |
working-directory: ./timefold-solver-python | |
run: mvn -B --fail-at-end clean install -Prun-code-coverage | |
- name: Get JaCoCo Agent | |
working-directory: ./timefold-solver-python | |
run: mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.jacoco:org.jacoco.agent:0.8.11:jar:runtime -Ddest=target/jacocoagent.jar | |
- name: Run tox to measure timefold solver python code coverage from Python tests | |
working-directory: ./timefold-solver-python | |
run: python -m tox -- --cov=timefold --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 | |
working-directory: ./timefold-solver-python/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 | |
- name: Run SonarCloud analysis | |
working-directory: ./timefold-solver-python | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -B -Psonarcloud-analysis validate org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.organization=timefold -Dsonar.projectKey=TimefoldAI_timefold-solver-python -Dsonar.host.url=https://sonarcloud.io -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} -Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} |