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

IntelliJ plugin, Gradle, Kotlin, Java version upgrade #429

Merged
merged 1 commit into from
Aug 21, 2022
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
160 changes: 130 additions & 30 deletions .github/workflows/build-and-run-tests-from-branch.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,145 @@
name: "[M] UTBot Java: build and run tests"

on:
workflow_dispatch

workflow_dispatch:
inputs:
commit_sha:
required: false
type: string
description: "Commit SHA (optional -- otherwise the last commit from the branch will be taken)"

workflow_call:
inputs:
commit_sha:
required: false
type: string

env:
REGISTRY: ghcr.io
IMAGE_NAME: utbot_java_cli
DOCKERFILE_PATH: docker/Dockerfile_java_cli
# Environment variable setting gradle options.
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -javaagent:/tmp/jmx-exporter.jar=12345:/tmp/jmx-exporter.yml -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"

jobs:
build-and-run-tests:
runs-on: ubuntu-20.04
prepare-tests-matrix:
runs-on: ubuntu-latest
# Outputs are used for passing data to dependent jobs.
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'zulu'
java-package: jdk+fx
cache: gradle
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.8
- name: Print environment variables
run: printenv

- name: Build and run tests in UTBot Java
- name: Checkout repository
uses: actions/checkout@v3

- name: Check out ${{ github.event.inputs.commit_sha }} commit
if: github.event.inputs.commit_sha != ''
run: |
git fetch
git checkout ${{ github.event.inputs.commit_sha }}
- id: set-matrix
name: Read and print config from framework-tests-matrix.json
run: |
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
echo "::set-output name=matrix::$TASKS"
echo $TASKS
framework:
# This job does not need to wait for 'prepare-tests-matrix' result.
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# to start execution early.
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
fail-fast: false
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
steps:
- name: Print environment variables
run: printenv

- name: Checkout repository
uses: actions/checkout@v3

- name: Check out ${{ github.event.inputs.commit_sha }} commit
if: github.event.inputs.commit_sha != ''
run: |
export KOTLIN_HOME="/usr"
gradle clean build --no-daemon

- name: Upload utbot-framework logs
git fetch
git checkout ${{ github.event.inputs.commit_sha }}
- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/monitoring.sh
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
- name: Run tests
run: |
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
- name: Upload logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: utbot_framework_logs
name: logs ${{ matrix.project.PART_NAME }}
path: utbot-framework/logs/*

- name: Upload utbot-framework tests report artifacts if tests have failed

- name: Upload UTBot temp directory content
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: utbot_temp ${{ matrix.project.PART_NAME }}
path: |
/tmp/UTBot/generated*/*
/tmp/UTBot/utbot-childprocess-errors/*
- name: Upload test report if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: utbot_framework_tests_report
name: test_report ${{ matrix.project.PART_NAME }}
path: utbot-framework/build/reports/tests/test/*

- name: Upload utbot-intellij tests report artifacts if tests have failed


project:
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
fail-fast: false
matrix:
project: [utbot-api, utbot-cli, utbot-core, utbot-framework-api, utbot-fuzzers, utbot-gradle, utbot-instrumentation, utbot-instrumentation-tests, utbot-intellij, utbot-junit-contest, utbot-sample, utbot-summary, utbot-summary-tests]
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
steps:
- name: Print environment variables
run: printenv

- name: Checkout repository
uses: actions/checkout@v3

- name: Check out ${{ github.event.inputs.commit_sha }} commit
if: github.event.inputs.commit_sha != ''
run: |
git fetch
git checkout ${{ github.event.inputs.commit_sha }}
- uses: actions/checkout@v3
with:
ref: ${{ env.COMMIT_SHA }}

- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/monitoring.sh
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
- name: Run tests
run: |
cd ${{ matrix.project }}
gradle build --no-daemon
- name: Upload test report if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: utbot_intellij_tests_report
path: utbot-intellij/build/reports/tests/test/*
name: test_report ${{ matrix.project }}
path: ${{ matrix.project }}/build/reports/tests/test/*
104 changes: 72 additions & 32 deletions .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,87 @@
name: "UTBot Java: build and run tests"

on:
on:
push:
branches: [main]
pull_request:
branches: [main]

env:
REGISTRY: ghcr.io
IMAGE_NAME: utbot_java_cli
DOCKERFILE_PATH: docker/Dockerfile_java_cli
# Environment variable setting gradle options.
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -javaagent:/tmp/jmx-exporter.jar=12345:/tmp/jmx-exporter.yml -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"

jobs:
build_and_run_tests:
build-and-run-tests:
uses: ./.github/workflows/build-and-run-tests-from-branch.yml


publish-cli-image:
needs: build-and-run-tests
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'zulu'
java-package: jdk+fx
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.8

- name: Build and run tests in UTBot Java
- name: Print environment variables
run: printenv

- uses: actions/checkout@v3

- name: Set environment variables
run: |
export KOTLIN_HOME="/usr"
gradle clean build --no-daemon
# "You can make an environment variable available to any subsequent steps in a workflow job by
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV

- name: Upload utbot-framework logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
- name: Build UTBot Java CLI
run: |
cd utbot-cli
gradle build --no-daemon -x test -PsemVer=${{ env.VERSION }}
- name: Set docker tag
run:
# "You can make an environment variable available to any subsequent steps in a workflow job by
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
name: utbot_framework_logs
path: utbot-framework/logs/*

- name: Upload utbot-framework tests report artifacts if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
name: utbot_framework_tests_report
path: utbot-framework/build/reports/tests/test/*

- name: Upload utbot-intellij tests report artifacts if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
name: utbot_intellij_tests_report
path: utbot-intellij/build/reports/tests/test/*
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.DOCKER_TAG }}
- name: Docker Buildx (build and push)
run: |
docker buildx build \
-f ${{ env.DOCKERFILE_PATH }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
--tag ${{ steps.meta.outputs.tags }} \
--build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
--push .
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
60 changes: 60 additions & 0 deletions .github/workflows/framework-tests-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"project": [
{
"PART_NAME": "composite",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.manual.*\" --tests \"org.utbot.examples.stream.*\" --tests \"org.utbot.engine.*\" --tests \"org.utbot.framework.*\" --tests \"org.utbot.sarif.*\"",
},
{
"PART_NAME": "collections-part1",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.CustomerExamplesTest\" --tests \"org.utbot.examples.collections.GenericListsExampleTest\" --tests \"org.utbot.examples.collections.LinkedListsTest\" --tests \"org.utbot.examples.collections.ListAlgorithmsTest\" --tests \"org.utbot.examples.collections.ListIteratorsTest\" --tests \"org.utbot.examples.collections.ListWrapperReturnsVoidTest\" --tests \"org.utbot.examples.collections.MapEntrySetTest\" --tests \"org.utbot.examples.collections.MapKeySetTest\"",
},
{
"PART_NAME": "collections-part2",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapValuesTest\" --tests \"org.utbot.examples.collections.OptionalsTest\" --tests \"org.utbot.examples.collections.SetIteratorsTest\"",
},
{
"PART_NAME": "collections-part3",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.SetsTest\"",
},
{
"PART_NAME": "examples-part1",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.algorithms.*\" --tests \"org.utbot.examples.annotations.*\" --tests \"org.utbot.examples.arrays.*\" --tests \"org.utbot.examples.casts.*\" --tests \"org.utbot.examples.codegen.*\" --tests \"org.utbot.examples.controlflow.*\" --tests \"org.utbot.examples.enums.*\"",
},
{
"PART_NAME": "examples-part2",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.exceptions.*\" --tests \"org.utbot.examples.invokes.*\" --tests \"org.utbot.examples.lambda.*\" --tests \"org.utbot.examples.make.symbolic.*\" --tests \"org.utbot.examples.math.*\"",
},
{
"PART_NAME": "examples-part3",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.mixed.*\" --tests \"org.utbot.examples.mock.*\" --tests \"org.utbot.examples.models.*\" --tests \"org.utbot.examples.natives.*\" --tests \"org.utbot.examples.objects.*\" --tests \"org.utbot.examples.primitives.*\" --tests \"org.utbot.examples.recursion.*\"",
},
{
"PART_NAME": "examples-part4",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.statics.substitution.*\" --tests \"org.utbot.examples.stdlib.*\" --tests \"org.utbot.examples.structures.*\" --tests \"org.utbot.examples.thirdparty.numbers.*\" --tests \"org.utbot.examples.types.*\" --tests \"org.utbot.examples.unsafe.*\" --tests \"org.utbot.examples.wrappers.*\"",
},
{
"PART_NAME": "examples-lists-part1",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart1Test\"",
},
{
"PART_NAME": "examples-lists-part2",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart2Test\"",
},
{
"PART_NAME": "examples-lists-part3",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.ListsPart3Test\"",
},
{
"PART_NAME": "examples-maps-part1",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart1Test\"",
},
{
"PART_NAME": "examples-maps-part2",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.collections.MapsPart2Test\"",
},
{
"PART_NAME": "examples-strings",
"TESTS_TO_RUN": "--tests \"org.utbot.examples.strings.*\"",
}
]
}
Loading