SquirrelJME/SquirrelJME

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: CircleCI Build Configuration
# SourceForge: squirreljme@frs.sourceforge.net
# SourceForge Root: /home/frs/project/squirreljme/AutoBuild/
# CircleCI Reference: https://circleci.com/docs/2.0/env-vars/

version: 2.1
executors:
  buildenv:
    docker:
      - image: circleci/openjdk:8-jdk

orbs:
  win: circleci/windows@2.4.0

jobs:
  ################################## WINDOWS #################################
  build_windows:
    executor:
      name: win/default
      shell: cmd.exe
    environment:
      # Use a reduced amount of memory to all of the VMs so that it does not
      # try grabbing all the memory that is available to the system.
      JAVA_OPTS: -Xmx3g
    steps:
      - checkout
      - run:
          shell: cmd.exe
          name: Gradle Build and Test
          # According to documentation, Gradle on Windows has trouble and tries
          # to make way too many workers which causes extreme resource.
          # contention --max-workers=2
          command: gradlew build testHosted -x javadoc -x javadocJar -x testFixturesJavaDoc -x sourcesJar --console plain --continue --parallel
      - run:
          shell: bash.exe
          name: Save test results
          command: |
            mkdir -p /c/users/circleci/test-results/junit-windows
            /usr/bin/find . -type f -regex '.*/vm-test-hosted/junit/.*\.xml' -exec cp {} /c/users/circleci/test-results/junit-windows/ \;
          when: always
      - run:
          shell: bash.exe
          name: Save test results
          command: |
            mkdir -p /c/users/circleci/test-results/csv-windows
            /usr/bin/find . -type f -regex '.*/vm-test-hosted/csv/.*\.csv' -exec cp {} /c/users/circleci/test-results/csv-windows/ \;
          when: always
      - store_test_results:
          path: c:\users\circleci\test-results
      - store_artifacts:
          path: c:\users\circleci\test-results
  ratufacoat_build_windows:
    executor:
      name: win/default
      shell: cmd.exe
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Install required dependencies
          working_directory: ratufacoat
          shell: cmd.exe
          command: choco install cmake.install
      - run:
          name: Setup CMake build
          working_directory: ratufacoat
          shell: bash.exe
          command: |
            "$PROGRAMFILES/CMake/bin/cmake.exe" .
      - run:
          name: Compile CMake build
          working_directory: ratufacoat
          shell: bash.exe
          command: |
            "$PROGRAMFILES/CMake/bin/cmake.exe" --build .
      - store_artifacts:
          path: ratufacoat\src\Debug\SquirrelJME.exe
          destination: SquirrelJME.exe

  ################################# MAC OS X #################################
  build_macosx:
    macos:
      xcode: 11.3.0
    environment:
      # Do not auto-update brew as this takes forever and we really just want
      # a single package
      HOMEBREW_NO_AUTO_UPDATE: 1

      # Do not auto-clean brew, this wastes time and everything will be thrown
      # out when the container finishes anyway
      HOMEBREW_CLEANUP_MAX_AGE_DAYS: 730

      # Do not send analytics
      HOMEBREW_NO_ANALYTICS: 1

      # Do not cleanup after installation
      HOMEBREW_NO_INSTALL_CLEANUP: 1
    steps:
      - checkout
      - run:
          # Only OpenJDK is required, Gradle always uses Gradle wrapper so
          # we do not need that
          name: Install OpenJDK 11
          command: brew install openjdk@11
      - run:
          name: Gradle Build and Test
          command: ./gradlew build testHosted -x javadoc -x javadocJar -x testFixturesJavaDoc -x sourcesJar --console plain --continue --parallel
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit-macosx/
            find . -type f -regex '.*/vm-test-hosted/junit/.*\.xml' -exec cp {} ~/test-results/junit-macosx/ \;
          when: always
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/csv-macosx/
            find . -type f -regex '.*/vm-test-hosted/csv/.*\.csv' -exec cp {} ~/test-results/csv-macosx/ \;
          when: always
      - store_test_results:
          path: ~/test-results
      - store_artifacts:
          path: ~/test-results
  ratufacoat_build_macosx:
    macos:
      xcode: 11.3.0
    environment:
      # Do not auto-update brew as this takes forever and we really just want
      # a single package
      HOMEBREW_NO_AUTO_UPDATE: 1
    steps:
      - checkout
      - run:
          name: Install CMake
          command: brew install cmake
      - attach_workspace:
          at: .
      - run:
          name: Setup CMake build
          working_directory: ratufacoat
          command: cmake .
      - run:
          name: Compile CMake build
          working_directory: ratufacoat
          command: cmake --build .
      - store_artifacts:
          path: ratufacoat/src/SquirrelJME
          destination: SquirrelJME

  ################################### LINUX ##################################
  build_linux:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - run:
          name: Gradle Build and Test
          command: ./gradlew build testHosted --console plain --continue --parallel
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit-linux/
            find . -type f -regex '.*/vm-test-hosted/junit/.*\.xml' -exec cp {} ~/test-results/junit-linux/ \;
          when: always
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/csv-linux/
            find . -type f -regex '.*/vm-test-hosted/csv/.*\.csv' -exec cp {} ~/test-results/csv-linux/ \;
          when: always
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'
      - store_test_results:
          path: ~/test-results
      - store_artifacts:
          path: ~/test-results

  ### OSS SonaType Nexus
  sonatype_publish:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Publish to OSS SonaType
          command: ./gradlew publishMavenPublicationToMavenRepository --console plain --continue --parallel

  ### RatufaCoat
  ratufacoat_build_linux:
    executor: buildenv
    resource_class: small
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - run:
          name: Install required dependencies
          command: |
            sudo apt-get update -y
            sudo apt-get install -y cmake build-essential
      - attach_workspace:
          at: .
      - run:
          name: Setup CMake build
          working_directory: ratufacoat
          command: cmake .
      - run:
          name: Compile CMake build
          working_directory: ratufacoat
          command: cmake --build .
      - store_artifacts:
          path: ratufacoat/src/SquirrelJME
          destination: SquirrelJME

  ### SpringCoat
  test_springcoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: SpringCoat Tests
          command: timeout --foreground 15m ./gradlew testSpringCoat --console plain --continue --parallel
          no_output_timeout: 15m
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit-springcoat/
            find . -type f -regex '.*/vm-test-springcoat/junit/.*\.xml' -exec cp {} ~/test-results/junit-springcoat/ \;
          when: always
      - run:
          name: Save snapshots
          command: |
            mkdir -p ~/test-results/nps-springcoat/
            find . -type f -regex '.*/vm-test-springcoat/nps/.*\.nps' -exec cp {} ~/test-results/nps-springcoat/ \;
          when: always
      - run:
          name: Save snapshots
          command: |
            mkdir -p ~/test-results/csv-springcoat/
            find . -type f -regex '.*/vm-test-springcoat/csv/.*\.csv' -exec cp {} ~/test-results/csv-springcoat/ \;
          when: always
      - store_test_results:
          path: ~/test-results
      - store_artifacts:
          path: ~/test-results
  test_summercoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: SummerCoat Tests
          command: timeout --foreground 15m ./gradlew testSummerCoat --console plain --continue --parallel
          no_output_timeout: 15m
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit-summercoat/
            find . -type f -regex '.*/vm-test-summercoat/junit/.*\.xml' -exec cp {} ~/test-results/junit-summercoat/ \;
          when: always
      - run:
          name: Save snapshots
          command: |
            mkdir -p ~/test-results/nps-summercoat/
            find . -type f -regex '.*/vm-test-summercoat/nps/.*\.nps' -exec cp {} ~/test-results/nps-summercoat/ \;
          when: always
      - run:
          name: Save snapshots
          command: |
            mkdir -p ~/test-results/csv-summercoat/
            find . -type f -regex '.*/vm-test-summercoat/csv/.*\.csv' -exec cp {} ~/test-results/csv-summercoat/ \;
          when: always
      - store_test_results:
          path: ~/test-results
      - store_artifacts:
          path: ~/test-results

  ################################### USERS ##################################
  export_user_guide:
    resource_class: small
    executor: buildenv
    steps:
      - checkout
      - run:
          name: Checkout Wiki
          command: git clone git@github.com:SquirrelJME/SquirrelJME.wiki.git /tmp/wiki
      - run:
          name: Wikify
          command: .circleci/squirreljme-wikify-user-guide.sh "$(pwd)" "/tmp/wiki"
      - run:
          name: Update Git User
          command: |
            cd "/tmp/wiki" && git config user.name "SquirrelJME Automation" && git config user.email "xerthesquirrel+squirreljme@gmail.com"
      - run:
          name: Commit changes
          command: |
            cd "/tmp/wiki" && git commit -m "Synchronize User-Guide" || echo "Ignoring commit."
      - add_ssh_keys:
          fingerprints:
            - "26:b8:ae:4d:53:64:4c:6a:59:3d:a6:60:44:90:9d:6c"
      - run:
          name: Push changes
          command: |
            cd "/tmp/wiki" && git push

  ################################ CONSTRUCTION ###############################
  # Runs the `testJar` task so any operations following this will run faster
  # when they need to use these JARs
  construct_testJars:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Construct Test JARs
          command: ./gradlew testJar --console plain --continue --parallel
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'

  # Constructs the ROM fragment libraries for SummerCoat, since they are used
  # for general ROM construction
  construct_libSummerCoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Construct SummerCoat Libraries
          command: ./gradlew libSummerCoat --console plain --continue --parallel
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'

  # All of the tests so that they can run from within SummerCoat
  construct_libTestSummerCoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Construct Test SummerCoat Libraries
          command: ./gradlew libTestSummerCoat --console plain --continue --parallel
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'

  # Constructs the standard SummerCoat ROM, could be uploaded later
  construct_romSummerCoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Construct SummerCoat ROM
          command: ./gradlew romSummerCoat --console plain --continue --parallel
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'

  # Constructs the test SummerCoat ROM, could be uploaded later, this is so
  # that any RatufaCoats have an actual ROM that can be tested to ensure that
  # it properly works.
  construct_romTestSummerCoat:
    executor: buildenv
    environment:
      # Allow Gradle to be fully cached
      GRADLE_USER_HOME: ${CIRCLE_WORKING_DIRECTORY}/.gradle/home
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Construct Test SummerCoat ROM
          command: ./gradlew romTestSummerCoat --console plain --continue --parallel
      - persist_to_workspace:
          root: .
          paths:
            - '.gradle/*'
            - 'build/*'
            - '*/.gradle/*'
            - '*/build/*'
            - '*/*/build/*'

workflows:
  version: 2
  tests:
    jobs:
      ############################# STANDARD TESTS ############################
      - build_linux
      - test_springcoat:
          requires:
            - construct_testJars
#      - test_summercoat:
#          requires:
#            - construct_libTestSummerCoat

      # Mac OS X runs decently however the jobs for it have a higher cost, so
      # only perform builds and tests for trunk to lower costs.
      # Currently have an overabundance of credits...
      - build_macosx
#          requires:
#            - build_linux
#          filters:
#            branches:
#              only:
#                - trunk

      # Building on Windows is currently expensive and takes longer, so only
      # run these builds on trunk to lower costs.
      # Currently have an overabundance of credits...
      - build_windows
#          requires:
#            - build_linux
#          filters:
#            branches:
#              only:
#                - trunk

      # Publishing to OSS Sonatype Nexus (https://oss.sonatype.org)
      - sonatype_publish:
          requires:
            - build_linux
          filters:
            branches:
              only:
                - trunk
                - wip-centralpublish

      ###################### LIBRARY AND ROM CONSTRUCTION #####################
      - construct_testJars:
          requires:
            - build_linux
#      - construct_libSummerCoat:
#          requires:
#            - build_linux
#      - construct_libTestSummerCoat:
#          requires:
#            - construct_testJars
#      - construct_romSummerCoat:
#          requires:
#            - construct_libSummerCoat
#      - construct_romTestSummerCoat:
#          requires:
#            - construct_libTestSummerCoat

      ############################## RATUFACOAT ##############################
#      - ratufacoat_build_windows:
#          requires:
#            - build_windows
#            - construct_romTestSummerCoat
#      - ratufacoat_build_linux:
#          requires:
#            - build_linux
#            - construct_romTestSummerCoat
#      - ratufacoat_build_macosx:
#          requires:
#            - build_macosx
#            - construct_romTestSummerCoat

  #################### TASKS TO INCREASE USER FRIENDLINESS ####################
  friendliness:
    jobs:
      - export_user_guide:
          filters:
            branches:
              only:
                - trunk
                - wip-userguide