name: Stress Test CI

on:
  push:
    branches:
      - master

jobs:
  jikesrvm-stress-test:
    runs-on: [self-hosted, Linux, freq-scaling-on]
    timeout-minutes: 720
    steps:
      - name: Checkout MMTk Core
        uses: actions/checkout@v2
        with:
          path: mmtk-core
      - name: Checkout JikesRVM Binding
        uses: actions/checkout@v2
        with:
          repository: mmtk/mmtk-jikesrvm
          token: ${{ secrets.CI_ACCESS_TOKEN }}
          path: mmtk-jikesrvm
          submodules: true
      # setup
      - name: Overwrite MMTk core in JikesRVM binding
        run: cp -r mmtk-core mmtk-jikesrvm/repos/
      - name: Setup
        run: |
          sed -i 's/^mmtk[[:space:]]=/#ci:mmtk=/g' mmtk-jikesrvm/mmtk/Cargo.toml
          sed -i 's/^#[[:space:]]mmtk/mmtk/g' mmtk-jikesrvm/mmtk/Cargo.toml
      # SemiSpace
      - name: Build SemiSpace
        run: |
          cd mmtk-jikesrvm/repos/jikesrvm
          RUSTUP_TOOLCHAIN=nightly-2020-07-08 python scripts/testMMTk.py -g RFastAdaptiveSemiSpace -j /usr/lib/jvm/java-1.8.0-openjdk-amd64 --build-only -- --answer-yes --quick --use-third-party-heap=../../ --use-third-party-build-configs=../../jikesrvm/build/configs --use-external-source=../../jikesrvm/rvm/src
      # Set parameters
      - name: Set stress test parameters
        id: stress_test
        run: echo "MMTK_STRESS_FACTOR=1" >> $GITHUB_ENV
      - name: antlr
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar antlr
      - name: bloat
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar bloat
      - name: fop
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar fop
      - name: hsqldb
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms200M -Xmx200M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar hsqldb
      - name: jython
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar jython
      - name: luindex
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar luindex
      - name: pmd
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar pmd
      - name: xalan
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms100M -Xmx100M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar xalan
      - name: lusearch
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms75M -Xmx75M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar lusearch
      - name: eclipse
        if: always()
        timeout-minutes: 180
        run:
          mmtk-jikesrvm/repos/jikesrvm/dist/RFastAdaptiveSemiSpace_x86_64-linux/rvm -Xms150M -Xmx150M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar eclipse

  openjdk-stress-test:
    runs-on: [self-hosted, Linux, freq-scaling-on]
    timeout-minutes: 720
    steps:
      - name: Checkout MMTk Core
        uses: actions/checkout@v2
        with:
          path: mmtk-core
      - name: Checkout OpenJDK Binding
        uses: actions/checkout@v2
        with:
          repository: mmtk/mmtk-openjdk
          token: ${{ secrets.CI_ACCESS_TOKEN }}
          path: mmtk-openjdk
          submodules: true
      # setup
      - name: Overwrite MMTk core in openjdk binding
        run: cp -r mmtk-core mmtk-openjdk/repos/
      - name: Setup
        run: |
          sed -i 's/^mmtk[[:space:]]=/#ci:mmtk=/g' mmtk-openjdk/mmtk/Cargo.toml
          sed -i 's/^#[[:space:]]mmtk/mmtk/g' mmtk-openjdk/mmtk/Cargo.toml
      # SemiSpace
      - name: Build SemiSpace
        run: |
          cd mmtk-openjdk/repos/openjdk
          export DEBUG_LEVEL=release
          export MMTK_PLAN=semispace
          export RUSTUP_TOOLCHAIN=nightly-2020-07-08
          sh configure --disable-warnings-as-errors --with-debug-level=$DEBUG_LEVEL
          make CONF=linux-x86_64-normal-server-$DEBUG_LEVEL THIRD_PARTY_HEAP=$PWD/../../openjdk
      # Set parameters
      - name: Set stress test parameters
        id: stress_test
        run: echo "MMTK_STRESS_FACTOR=1" >> $GITHUB_ENV
      # Run
      - name: antlr
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar antlr
      - name: fop
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar fop
      - name: luindex
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar luindex
      - name: pmd
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar pmd
      - name: hsqldb
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar hsqldb
      - name: eclipse
        if: always()
        timeout-minutes: 180
        run:
          mmtk-openjdk/repos/openjdk/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar /usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar eclipse