<commit_before>name: CMake Self-Hosted

on: [push, pull_request, workflow_dispatch]

env:
  # this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems
  # we set MACOSX_DEPLOYMENT_TARGET later
  MACOS_TARGET: 10.12
  FEATURES: -DUSE_VTK=ON -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "macOS ARM", artifact: "macOS-arm64.dmg",
            os: [self-hosted, macOS],
            cc: "clang", cxx: "clang++",
            build_type: "Release",
            cmake_flags: "-G Ninja -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.2_2/lib/cmake/Qt5",
            cpack_flags: "-G DragNDrop",
          }

    steps:

    - name: Install Dependencies (macOS)
      if: runner.os == 'macOS'
      run: |
        if uname -p | grep -q "arm" ; then
           export PATH=/opt/homebrew/bin:$PATH
        else # not self-hosted runner
          brew install ninja eigen glew
        fi

    - name: Checkout openchemistry
      uses: actions/checkout@v3
      with:
        repository: openchemistry/openchemistry
        submodules: recursive

    - name: Checkout avogadroapp
      uses: actions/checkout@v3
      with:
        repository: openchemistry/avogadroapp
        path: avogadroapp

    - name: Checkout avogadrolibs
      uses: actions/checkout@v3
      with:
        path: avogadrolibs

    - name: Checkout i18n
      uses: actions/checkout@v3
      with:
        repository: openchemistry/avogadro-i18n
        path: avogadro-i18n

    - name: Grab cache files
      uses: actions/cache@v2
      with:
        path: |
          ${{ runner.workspace }}/build/thirdparty
          ${{ runner.workspace }}/build/Downloads
        key: ${{ matrix.config.name }}-thirdparty

    - name: Configure
      run: |
        if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi
        cd "${{ runner.workspace }}/build"
        # won't have any effect except on Mac
        echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV
        CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} ${{matrix.config.cmake_flags}}
      shell: bash

    - name: Build
      run: |
        CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{matrix.config.build_type}} ${{matrix.config.build_flags}}
      shell: bash
      working-directory: ${{ runner.workspace }}/build

    - name: Fix Mac plugins
      if: runner.os == 'macOS'
      working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel 
      run: |
        for plugin in *.so; do
          for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do 
            export lib=`echo $libpath | cut -d '/' -f 9`;
            echo "Fixing $plugin $lib $libpath"
            install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
          done
        done
        cd .. # build/prefix/lib
        for plugin in libinchi.?.?.?.dylib; do
          for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do 
            export lib=`echo $libpath | cut -d '/' -f 9`;
            echo "Fixing $plugin $lib $libpath"
            install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
          done
        done
        otool -L libinchi.?.?.?.dylib
        cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/

    - name: Install the Apple certificate
      # From GitHub docs: https://docs.github.com/en/actions/guides/installing-an-apple-certificate-on-macos-runners-for-xcode-development
      if: runner.os == 'macOS'
      working-directory: ${{ runner.workspace }}/build
      env:
        BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
        P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
        NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }}
        NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
        PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro
      run: |
        # create variables
        if [ -n "${P12_PASSWORD}" ]; then
          CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db

          # import certificate and provisioning profile from secrets
          echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH

          # create temporary keychain if the cert is non-zero
          if [ -s $CERTIFICATE_PATH ]; then
            security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
            security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
            security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

            # import certificate to keychain
            security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
            security list-keychain -d user -s $KEYCHAIN_PATH

            # signing occurs via avogadroapp cpack instructions
          fi # certificate exists
        fi # password exists

    - name: Pack
      if: matrix.config.artifact != 0
      shell: bash
      run: |
        if [ -z "${P12_PASSWORD}" ]; then
          unset CODESIGN_IDENTITY # to prevent cpack failing when trying to sign
        fi
        cpack ${{ matrix.config.cpack_flags }}
      env:
        P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
      working-directory: ${{ runner.workspace }}/build/avogadroapp

    - name: Notarize Mac DMG
      if: runner.os == 'macOS'
      run: |
        pwd
        ls -l
        # check if we have the password and the username
        if [ -n "${NOTARIZE_PASSWORD}" ] && [ -n "${NOTARIZE_USERNAME}" ]; then
          echo "codesign DMG"
          codesign -s "$CODESIGN_IDENTITY" --timestamp "Avogadro2*.dmg"
          echo "notarizing"
          npx notarize-cli --file "Avogadro2*.dmg"
        fi
      env:
        NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }}
        NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
        PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro
      working-directory: ${{ runner.workspace }}/build/avogadroapp

    - name: Upload
      if: matrix.config.artifact != 0
      uses: actions/upload-artifact@v2
      with:
        path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.*
        name: ${{ matrix.config.artifact }}

    - name: Cleanup
      if: ${{ always() }} # To ensure this step runs even when earlier steps fail<commit_msg>More work to debug m1 notarization [skip ci]<commit_after>name: CMake Self-Hosted

on: [push, pull_request, workflow_dispatch]

env:
  # this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems
  # we set MACOSX_DEPLOYMENT_TARGET later
  MACOS_TARGET: 10.12
  FEATURES: -DUSE_VTK=ON -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "macOS ARM", artifact: "macOS-arm64.dmg",
            os: [self-hosted, macOS],
            cc: "clang", cxx: "clang++",
            build_type: "Release",
            cmake_flags: "-G Ninja -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.2_2/lib/cmake/Qt5",
            cpack_flags: "-G DragNDrop",
          }

    steps:

    - name: Install Dependencies (macOS)
      if: runner.os == 'macOS'
      run: |
        if uname -p | grep -q "arm" ; then
           export PATH=/opt/homebrew/bin:$PATH
        else # not self-hosted runner
          brew install ninja eigen glew
        fi

    - name: Checkout openchemistry
      uses: actions/checkout@v3
      with:
        repository: openchemistry/openchemistry
        submodules: recursive

    - name: Checkout avogadroapp
      uses: actions/checkout@v3
      with:
        repository: openchemistry/avogadroapp
        path: avogadroapp

    - name: Checkout avogadrolibs
      uses: actions/checkout@v3
      with:
        path: avogadrolibs

    - name: Checkout i18n
      uses: actions/checkout@v3
      with:
        repository: openchemistry/avogadro-i18n
        path: avogadro-i18n

    - name: Grab cache files
      uses: actions/cache@v2
      with:
        path: |
          ${{ runner.workspace }}/build/thirdparty
          ${{ runner.workspace }}/build/Downloads
        key: ${{ matrix.config.name }}-thirdparty

    - name: Configure
      run: |
        if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi
        cd "${{ runner.workspace }}/build"
        # won't have any effect except on Mac
        echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV
        CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} ${{matrix.config.cmake_flags}}
      shell: bash

    - name: Build
      run: |
        CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{matrix.config.build_type}} ${{matrix.config.build_flags}}
      shell: bash
      working-directory: ${{ runner.workspace }}/build

    - name: Fix Mac plugins
      if: runner.os == 'macOS'
      working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel 
      run: |
        for plugin in *.so; do
          for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do 
            export lib=`echo $libpath | cut -d '/' -f 9`;
            echo "Fixing $plugin $lib $libpath"
            install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
          done
        done
        cd .. # build/prefix/lib
        for plugin in libinchi.?.?.?.dylib; do
          for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do 
            export lib=`echo $libpath | cut -d '/' -f 9`;
            echo "Fixing $plugin $lib $libpath"
            install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
          done
        done
        otool -L libinchi.?.?.?.dylib
        cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/

    - name: Install the Apple certificate
      # From GitHub docs: https://docs.github.com/en/actions/guides/installing-an-apple-certificate-on-macos-runners-for-xcode-development
      if: runner.os == 'macOS'
      working-directory: ${{ runner.workspace }}/build
      env:
        BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
        P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
        NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }}
        NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
        PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro
      run: |
        # create variables
        if [ -n "${P12_PASSWORD}" ]; then
          CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db

          # import certificate and provisioning profile from secrets
          echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH

          # create temporary keychain if the cert is non-zero
          if [ -s $CERTIFICATE_PATH ]; then
            security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
            security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
            security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

            # import certificate to keychain
            security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
            security list-keychain -d user -s $KEYCHAIN_PATH

            # signing occurs via avogadroapp cpack instructions
          fi # certificate exists
        fi # password exists

    - name: Pack
      if: matrix.config.artifact != 0
      shell: bash
      run: |
        if [ -z "${P12_PASSWORD}" ]; then
          unset CODESIGN_IDENTITY # to prevent cpack failing when trying to sign
        fi
        cpack ${{ matrix.config.cpack_flags }}
      env:
        P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
      working-directory: ${{ runner.workspace }}/build/avogadroapp

    - name: Notarize Mac DMG
      if: runner.os == 'macOS'
      run: |
        pwd
        ls -l
        # check if we have the password and the username
        if [ -n "${NOTARIZE_PASSWORD}" ] && [ -n "${NOTARIZE_USERNAME}" ]; then
          echo "codesign DMG"
          codesign -s "$CODESIGN_IDENTITY" --timestamp Avogadro2*.dmg
          echo "notarizing"
          npx notarize-cli --file Avogadro2*.dmg
        fi
      env:
        NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }}
        NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }}
        CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }}
        PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro
      working-directory: ${{ runner.workspace }}/build/avogadroapp

    - name: Upload
      if: matrix.config.artifact != 0
      uses: actions/upload-artifact@v2
      with:
        path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.*
        name: ${{ matrix.config.artifact }}

    - name: Cleanup
      if: ${{ always() }} # To ensure this step runs even when earlier steps fail
{'fraction_non_alphanumeric': 0.1195422406880968, 'fraction_numerical': 0.009694584153363947, 'mean_word_length': 2.2697807435653004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2949868', 'n_tokens_mistral': 4618, 'n_tokens_neox': 4389, 'n_words': 1024}