<commit_before>version: 2
jobs:
  build:
    working_directory: ~/buendia

    docker:
      - image: projectbuendia/debian-stretch:1.0.0

    steps:
      - checkout # check out the code in the project directory

      - restore_cache:
          keys:
              - buendia-v1-{{ .Branch }}-{{ .Revision }}
              - buendia-v1-{{ .Branch }}
              - buendia-v1-

      - run:
          # The package version is set to n.n-b or n.n.n-b if the current Git
          # tag is "vn.n" or "vn.n.n" and the current build number is b; else
          # it is 0.0.0-b
          name: Determine package version number
          command: |
              perl -e 'print(($ENV{"CIRCLE_TAG"} =~ /^v([0-9]+(\.[0-9]+){0,2})$/ ? $1 : "0.0.0"), "-", $ENV{"CIRCLE_BUILD_NUM"})' > /tmp/buendia-version
          
      - run:
          name: Build all Debian packages
          command: make -C packages PACKAGE_VERSION=$(cat /tmp/buendia-version)

      - save_cache:
          key: buendia-v1-{{ .Branch }}-{{ .Revision }}
          paths:
            - ~/.m2
            - /tmp/buendia-fetched

      - run:
          name: Collect and store test results
          command: |
              mkdir -p /tmp/test-results &&
              cp -a openmrs/api/target/surefire-reports /tmp/test-results/api &&
              cp -a openmrs/omod/target/surefire-reports /tmp/test-results/omod

      - store_test_results:
          path: /tmp/test-results
             
      - run: 
          name: Collect and store built packages
          command: mkdir -p /tmp/packages && cp $(find packages -name '*.deb') /tmp/packages

      - store_artifacts:
          path: /tmp/packages<commit_msg>Add CircleCI workflow for tagged builds<commit_after>version: 2
jobs:
  build:
    working_directory: ~/buendia

    docker:
      - image: projectbuendia/debian-stretch:1.0.0

    steps:
      - checkout # check out the code in the project directory

      - restore_cache:
          keys:
              - buendia-v1-{{ .Branch }}-{{ .Revision }}
              - buendia-v1-{{ .Branch }}
              - buendia-v1-

      - run:
          # The package version is set to n.n-b or n.n.n-b if the current Git
          # tag is "vn.n" or "vn.n.n" and the current build number is b; else
          # it is 0.0.0-b
          name: Determine package version number
          command: |
              perl -e 'print(($ENV{"CIRCLE_TAG"} =~ /^v([0-9]+(\.[0-9]+){0,2})$/ ? $1 : "0.0.0"), "-", $ENV{"CIRCLE_BUILD_NUM"})' > /tmp/buendia-version
          
      - run:
          name: Build all Debian packages
          command: make -C packages PACKAGE_VERSION=$(cat /tmp/buendia-version)

      - save_cache:
          key: buendia-v1-{{ .Branch }}-{{ .Revision }}
          paths:
            - ~/.m2
            - /tmp/buendia-fetched

      - run:
          name: Collect and store test results
          command: |
              mkdir -p /tmp/test-results &&
              cp -a openmrs/api/target/surefire-reports /tmp/test-results/api &&
              cp -a openmrs/omod/target/surefire-reports /tmp/test-results/omod

      - store_test_results:
          path: /tmp/test-results
             
      - run: 
          name: Collect and store built packages
          command: mkdir -p /tmp/packages && cp $(find packages -name '*.deb') /tmp/packages

      - store_artifacts:
          path: /tmp/packages

workflows:
  version: 2
  normal-build:
    jobs:
      - build:
          filters:
            tags:
              ignore: /.*/
  release-build:
    # Ensure that tagged releases get their own CircleCI build:
    # https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
    jobs:
      - build:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/
{'fraction_non_alphanumeric': 0.1318134171907757, 'fraction_numerical': 0.012316561844863731, 'mean_word_length': 1.5194719471947196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1636790', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1204, 'n_words': 298}