<commit_before>name: Build and test GYB

on:
  push:
  pull_request:
  schedule:
    - cron: '37 22 * * *'

defaults:
  run:
    shell: bash

env:
  OPENSSL_CONFIG_OPTS: no-asm no-fips
  OPENSSL_INSTALL_PATH: ${{ github.workspace }}/ssl
  OPENSSL_SOURCE_PATH: ${{ github.workspace }}/openssl
  PYTHON_INSTALL_PATH: ${{ github.workspace }}/python
  PYTHON_SOURCE_PATH: ${{ github.workspace }}/cpython

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-20.04
            jid: 1
            goal: build
            arch: x86_64
          - os: macos-10.15
            jid: 2
            goal: build
            arch: x86_64
          - os: windows-2022
            jid: 3
            goal: build
            arch: Win64
          - os: windows-2022
            jid: 4
            goal: build
            arch: Win32
          - os: [self-hosted, linux, arm64]
            jid: 5
            goal: build
            arch: aarch64
          - os: [self-hosted, linux, arm]
            jid: 6
            goal: build
            arch: aarch64
          - os: ubuntu-20.04
            goal: test
            python: 3.7
            jid: 7
          - os: ubuntu-20.04
            goal: test
            python: 3.8
            jid: 8
          - os: ubuntu-20.04
            goal: test
            python: 3.9
            jid: 9

    steps:

      - uses: actions/checkout@master
        with:
          persist-credentials: false
          fetch-depth: 0

      - name: Cache
        id: cache
        uses: actions/cache@v2
        if: matrix.goal == 'build'
        with:
          path: |
            ~/ssl
            ~/python
          key: ${{ matrix.jid }}-20220121

      - name: Use pre-compiled Python
        if: matrix.python != ''
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}

      - name: Set env variables for test
        if: matrix.goal == 'test'
        env:
          JID: ${{ matrix.jid }}
          ACTIONS_CACHE: ${{ steps.cache.outputs.cache-hit }}
          ACTIONS_GOAL: ${{ matrix.goal }}
        run: |
             export PYTHON=$(which python3)
             export PIP=$(which pip3)
             export gyb="${PYTHON} -m gyb"
             export gybpath="$(readlink -e .)"
             echo -e "PYTHON: ${PYTHON}\nPIP: ${PIP}\ngyb: ${gyb}\ngybpath: ${gybpath}"
             echo "PYTHON=${PYTHON}" >> $GITHUB_ENV
             echo "PIP=${PIP}" >> $GITHUB_ENV
             echo "gyb=${gyb}" >> $GITHUB_ENV
             echo "gybpath=${gybpath}" >> $GITHUB_ENV
             echo "JID=${JID}" >> $GITHUB_ENV
             echo "ACTIONS_CACHE=${ACTIONS_CACHE}" >> $GITHUB_ENV
             echo "ACTIONS_GOAL=${ACTIONS_GOAL}" >> $GITHUB_ENV

      - name: Set Env Variables for build
        if: matrix.goal == 'build'
        env:
          arch: ${{ matrix.arch }}
          jid: ${{ matrix.jid }}
        run: |
          echo "We are running on ${RUNNER_OS}"
          if [[ "${RUNNER_OS}" == "macOS" ]]; then
            MAKE=make
            MAKEOPT="-j$(sysctl -n hw.logicalcpu)"
            PERL=perl
            # We only care about non-deprecated OSes
            MACOSX_DEPLOYMENT_TARGET="10.15"
            echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
            echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
          elif [[ "${RUNNER_OS}" == "Linux" ]]; then
            MAKE=make
            MAKEOPT="-j$(nproc)"
            PERL=perl
            echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
          elif [[ "${RUNNER_OS}" == "Windows" ]]; then
            MAKE=nmake
            MAKEOPT=""
            PERL="c:\strawberry\perl\bin\perl.exe"
            echo "PYTHON=${PYTHON_INSTALL_PATH}\python.exe" >> $GITHUB_ENV
          fi
          if [[ "${arch}" == "Win64" ]]; then
            PYEXTERNALS_PATH="amd64"
            PYBUILDRELEASE_ARCH="x64"
            OPENSSL_CONFIG_TARGET="VC-WIN64A"
          elif [[ "${arch}" == "Win32" ]]; then
            PYEXTERNALS_PATH="win32"
            PYBUILDRELEASE_ARCH="Win32"
            OPENSSL_CONFIG_TARGET="VC-WIN32"
          fi
          echo "We'll run make with: ${MAKEOPT}"
          echo "jid=${jid}" >> $GITHUB_ENV
          echo "arch=${arch}" >> $GITHUB_ENV
          echo "MAKE=${MAKE}" >> $GITHUB_ENV
          echo "MAKEOPT=${MAKEOPT}" >> $GITHUB_ENV
          echo "PERL=${PERL}" >> $GITHUB_ENV
          echo "PYEXTERNALS_PATH=${PYEXTERNALS_PATH}" >> $GITHUB_ENV
          echo "PYBUILDRELEASE_ARCH=${PYBUILDRELEASE_ARCH}" >> $GITHUB_ENV
          echo "OPENSSL_CONFIG_TARGET=${OPENSSL_CONFIG_TARGET}" >> $GITHUB_ENV
          echo "LD_LIBRARY_PATH=${OPENSSL_INSTALL_PATH}/lib:${PYTHON_INSTALL_PATH}/lib" >> $GITHUB_ENV

      - name: Get latest stable OpenSSL source
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          git clone https://github.com/openssl/openssl.git
          cd "${OPENSSL_SOURCE_PATH}"
          export LATEST_STABLE_TAG=$(git tag --list openssl-* | grep -v alpha | grep -v beta | sort -Vr | head -n1)
          echo "Checking out version ${LATEST_STABLE_TAG}"
          git checkout "${LATEST_STABLE_TAG}"
          export COMPILED_OPENSSL_VERSION=${LATEST_STABLE_TAG:8} # Trim the openssl- prefix
          echo "COMPILED_OPENSSL_VERSION=${COMPILED_OPENSSL_VERSION}" >> $GITHUB_ENV
      - name: Windows Configure VCode
        uses: ilammy/msvc-dev-cmd@v1
        if: matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'
        with:
          arch: ${{ matrix.arch }}

      - name: Windows NASM Install
        uses: ilammy/setup-nasm@v1
        if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'

      - name: Config OpenSSL
        if: steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          # --libdir=lib is needed so Python can find OpenSSL libraries
          "${PERL}" ./Configure "${OPENSSL_CONFIG_TARGET}" --libdir=lib --prefix="${OPENSSL_INSTALL_PATH}" $OPENSSL_CONFIG_OPTS

      - name: Rename GNU link on Windows
        if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'
        shell: bash
        run: mv /usr/bin/link /usr/bin/gnulink

      - name: Make OpenSSL
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          $MAKE "${MAKEOPT}"

      - name: Install OpenSSL
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          # install_sw saves us ages processing man pages :-)
          $MAKE install_sw<commit_msg>Update build.yml<commit_after>name: Build and test GYB

on:
  push:
  pull_request:
  schedule:
    - cron: '37 22 * * *'

defaults:
  run:
    shell: bash

env:
  OPENSSL_CONFIG_OPTS: no-asm no-fips
  OPENSSL_INSTALL_PATH: ${{ github.workspace }}/ssl
  OPENSSL_SOURCE_PATH: ${{ github.workspace }}/openssl
  PYTHON_INSTALL_PATH: ${{ github.workspace }}/python
  PYTHON_SOURCE_PATH: ${{ github.workspace }}/cpython

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-20.04
            jid: 1
            goal: build
            arch: x86_64
          - os: macos-10.15
            jid: 2
            goal: build
            arch: x86_64
          - os: windows-2022
            jid: 3
            goal: build
            arch: Win64
          - os: windows-2022
            jid: 4
            goal: build
            arch: Win32
          - os: [self-hosted, linux, arm64]
            jid: 5
            goal: build
            arch: aarch64
          - os: [self-hosted, linux, arm]
            jid: 6
            goal: build
            arch: aarch64
          - os: ubuntu-20.04
            goal: test
            python: 3.7
            jid: 7
          - os: ubuntu-20.04
            goal: test
            python: 3.8
            jid: 8
          - os: ubuntu-20.04
            goal: test
            python: 3.9
            jid: 9

    steps:

      - uses: actions/checkout@master
        with:
          persist-credentials: false
          fetch-depth: 0

      - name: Cache
        id: cache
        uses: actions/cache@v2
        if: matrix.goal == 'build'
        with:
          path: |
            ~/ssl
            ~/python
          key: ${{ matrix.jid }}-20220121

      - name: Use pre-compiled Python
        if: matrix.python != ''
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}

      - name: Set env variables for test
        if: matrix.goal == 'test'
        env:
          JID: ${{ matrix.jid }}
          ACTIONS_CACHE: ${{ steps.cache.outputs.cache-hit }}
          ACTIONS_GOAL: ${{ matrix.goal }}
        run: |
             export PYTHON=$(which python3)
             export PIP=$(which pip3)
             export gyb="${PYTHON} -m gyb"
             export gybpath="$(readlink -e .)"
             echo -e "PYTHON: ${PYTHON}\nPIP: ${PIP}\ngyb: ${gyb}\ngybpath: ${gybpath}"
             echo "PYTHON=${PYTHON}" >> $GITHUB_ENV
             echo "PIP=${PIP}" >> $GITHUB_ENV
             echo "gyb=${gyb}" >> $GITHUB_ENV
             echo "gybpath=${gybpath}" >> $GITHUB_ENV
             echo "JID=${JID}" >> $GITHUB_ENV
             echo "ACTIONS_CACHE=${ACTIONS_CACHE}" >> $GITHUB_ENV
             echo "ACTIONS_GOAL=${ACTIONS_GOAL}" >> $GITHUB_ENV

      - name: Set Env Variables for build
        if: matrix.goal == 'build'
        env:
          arch: ${{ matrix.arch }}
          jid: ${{ matrix.jid }}
        run: |
          echo "We are running on ${RUNNER_OS}"
          if [[ "${RUNNER_OS}" == "macOS" ]]; then
            MAKE=make
            MAKEOPT="-j$(sysctl -n hw.logicalcpu)"
            PERL=perl
            # We only care about non-deprecated OSes
            MACOSX_DEPLOYMENT_TARGET="10.15"
            echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
            echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
          elif [[ "${RUNNER_OS}" == "Linux" ]]; then
            MAKE=make
            MAKEOPT="-j$(nproc)"
            PERL=perl
            echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
          elif [[ "${RUNNER_OS}" == "Windows" ]]; then
            MAKE=nmake
            MAKEOPT=""
            PERL="c:\strawberry\perl\bin\perl.exe"
            echo "PYTHON=${PYTHON_INSTALL_PATH}\python.exe" >> $GITHUB_ENV
          fi
          if [[ "${arch}" == "Win64" ]]; then
            PYEXTERNALS_PATH="amd64"
            PYBUILDRELEASE_ARCH="x64"
            OPENSSL_CONFIG_TARGET="VC-WIN64A"
          elif [[ "${arch}" == "Win32" ]]; then
            PYEXTERNALS_PATH="win32"
            PYBUILDRELEASE_ARCH="Win32"
            OPENSSL_CONFIG_TARGET="VC-WIN32"
          fi
          echo "We'll run make with: ${MAKEOPT}"
          echo "jid=${jid}" >> $GITHUB_ENV
          echo "arch=${arch}" >> $GITHUB_ENV
          echo "MAKE=${MAKE}" >> $GITHUB_ENV
          echo "MAKEOPT=${MAKEOPT}" >> $GITHUB_ENV
          echo "PERL=${PERL}" >> $GITHUB_ENV
          echo "PYEXTERNALS_PATH=${PYEXTERNALS_PATH}" >> $GITHUB_ENV
          echo "PYBUILDRELEASE_ARCH=${PYBUILDRELEASE_ARCH}" >> $GITHUB_ENV
          echo "OPENSSL_CONFIG_TARGET=${OPENSSL_CONFIG_TARGET}" >> $GITHUB_ENV
          echo "LD_LIBRARY_PATH=${OPENSSL_INSTALL_PATH}/lib:${PYTHON_INSTALL_PATH}/lib" >> $GITHUB_ENV

      - name: Get latest stable OpenSSL source
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          git clone https://github.com/openssl/openssl.git
          cd "${OPENSSL_SOURCE_PATH}"
          export LATEST_STABLE_TAG=$(git tag --list openssl-* | grep -v alpha | grep -v beta | sort -Vr | head -n1)
          echo "Checking out version ${LATEST_STABLE_TAG}"
          git checkout "${LATEST_STABLE_TAG}"
          export COMPILED_OPENSSL_VERSION=${LATEST_STABLE_TAG:8} # Trim the openssl- prefix
          echo "COMPILED_OPENSSL_VERSION=${COMPILED_OPENSSL_VERSION}" >> $GITHUB_ENV
      - name: Windows Configure VCode
        uses: ilammy/msvc-dev-cmd@v1
        if: matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'
        with:
          arch: ${{ matrix.arch }}

      - name: Windows NASM Install
        uses: ilammy/setup-nasm@v1
        if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'

      - name: Config OpenSSL
        if: matrix.goal == 'build && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          # --libdir=lib is needed so Python can find OpenSSL libraries
          "${PERL}" ./Configure "${OPENSSL_CONFIG_TARGET}" --libdir=lib --prefix="${OPENSSL_INSTALL_PATH}" $OPENSSL_CONFIG_OPTS

      - name: Rename GNU link on Windows
        if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python.outputs.cache-hit != 'true'
        shell: bash
        run: mv /usr/bin/link /usr/bin/gnulink

      - name: Make OpenSSL
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          $MAKE "${MAKEOPT}"

      - name: Install OpenSSL
        if: matrix.goal == 'build' && steps.cache-python.outputs.cache-hit != 'true'
        run: |
          cd "${OPENSSL_SOURCE_PATH}"
          # install_sw saves us ages processing man pages :-)
          $MAKE install_sw
{'fraction_non_alphanumeric': 0.1336669567740064, 'fraction_numerical': 0.0168262257035103, 'mean_word_length': 1.8083503054989816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 87, 'https://': 2, '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': '744524', 'n_tokens_mistral': 4711, 'n_tokens_neox': 4380, 'n_words': 946}