Test new fixes for coverage. #113
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
name: Application tests | |
on: | |
push: | |
branches: | |
- master | |
- unit-tests | |
- develop | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
app-tests-analyze: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: test_database | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cache Maven packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-m2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17' | |
- name: Add exec permission to mvnw | |
run: chmod +x mvnw | |
- name: Compile the application | |
run: ./mvnw -B clean install -DskipTests=true | |
- name: Start the application | |
run: | | |
./mvnw spring-boot:run & | |
echo $! > spring-boot-app.pid | |
sleep 30 | |
env: | |
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/test_database | |
SPRING_DATASOURCE_USERNAME: root | |
SPRING_DATASOURCE_PASSWORD: root | |
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver | |
- name: Check listening ports | |
run: ss -tuln | |
- name: Run integration tests | |
run: | | |
./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify -Dspring.datasource.url=jdbc:mysql://localhost:3306/test_database -Dspring.datasource.username=root -Dspring.datasource.password=root -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -Dtest="com.uniovi.CucumberRunnerTests" | |
env: | |
SPRING_PROFILES_ACTIVE: test | |
headless: true | |
EXCLUDE_JUNIT: true | |
- name: Run Unit tests | |
run: | | |
./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify -Dspring.datasource.url=jdbc:mysql://localhost:3306/test_database -Dspring.datasource.username=root -Dspring.datasource.password=root -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -Dtest="com.uniovi.Wiq_UnitTests" | |
env: | |
SPRING_PROFILES_ACTIVE: test | |
- name: Shut down the application | |
if: always() | |
run: | | |
kill $(cat spring-boot-app.pid) | |
- name: Collect Jacoco report and send to Sonar | |
run: | | |
./mvnw org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.ref }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test |