# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Mutation tests

on:
  schedule:
    - cron: '0 13 * * 5'

jobs:
  applications:
    name: Mutation Test ${{ matrix.java-version }}
    if: github.repository == 'eclipse/eclipse-collections'
    strategy:
      matrix:
        os: [ubuntu-latest]
        java-version: [11]

    runs-on: ${{ matrix.os }}

    env:
      JAVA_VERSION: ${{ matrix.java-version }}

    steps:
      - name: Git Checkout
        uses: actions/checkout@v
      - name: Set JDK ${{ matrix.java-version }}
        uses: actions/setup-java@v3
        with:
          distribution: 'zulu'
          java-version: ${{ matrix.java-version }}
      - name: Enable Maven Cache
        uses: actions/cache@v3.0.2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Maven Install
        run: mvn clean install -DskipTests=true
        env:
          MAVEN_OPTS: "-Xmx1g"
      - name: Mutation Test
        run: mvn eu.stamp-project:pitmp-maven-plugin:run -DwithHistory -DtimeoutConstant=8000
        env:
          MAVEN_OPTS: "-Xmx1g"
      - name: Archive pitest reports
        uses: actions/upload-artifact@v3
        with:
          name: pit-reports
          path: unit-tests/target/pit-reports
