#
# THIS FILE IS GENERATED. SEE https://github.com/Chinilla/chinilla-blockchain/tree/main/tests#readme
#
name: MacOS TEST_NAME Test

on:
  push:
    branches:
      - 'long_lived/**'
      - main
      - 'release/**'
    tags:
        - '**'
  pull_request:
    branches:
      - '**'

concurrency:
  # SHA is added to the end if on `main` to let all main workflows run
  group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
  cancel-in-progress: true

jobs:
  build:
    name: MacOS TEST_NAME Tests
    runs-on: ${{ matrix.os }}
    timeout-minutes: JOB_TIMEOUT
    strategy:
      fail-fast: false
      max-parallel: 4
      matrix:
        python-version: ['3.9', '3.10']
        os: [macOS-latest]
    env:
      CHINILLA_ROOT: ${{ github.workspace }}/.chinilla/vanillanet
      JOB_FILE_NAME: tests_${{ matrix.os }}_python-${{ matrix.python-version }}_TEST_NAME

    steps:
    - name: Checkout Code
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: Setup Python environment
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}

    - name: Create keychain for CI use
      run: |
        security create-keychain -p foo chinillachain
        security default-keychain -s chinillachain
        security unlock-keychain -p foo chinillachain
        security set-keychain-settings -t 7200 -u chinillachain

    - name: Get pip cache dir
      id: pip-cache
      run: |
        echo "::set-output name=dir::$(pip cache dir)"

    - name: Cache pip
      uses: actions/cache@v3
      with:
        # Note that new runners may break this https://github.com/actions/cache/issues/292
        path: ${{ steps.pip-cache.outputs.dir }}
        key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
        restore-keys: |
          ${{ runner.os }}-pip-

CHECKOUT_TEST_BLOCKS_AND_PLOTS

    - name: Run install script
      env:
        INSTALL_PYTHON_VERSION: ${{ matrix.python-version }}
      run: |
        brew install boost
        sh install.sh -d

INSTALL_TIMELORD

    - name: Test TEST_NAME code with pytest
      run: |
        . ./activate
        venv/bin/coverage run --rcfile=.coveragerc --module pytest --durations=10 PYTEST_PARALLEL_ARGS -m "not benchmark" TEST_FILES

    - name: Process coverage data
      run: |
        venv/bin/coverage combine --rcfile=.coveragerc .coverage.*
        venv/bin/coverage xml --rcfile=.coveragerc -o coverage.xml
        mkdir coverage_reports
        cp .coverage "coverage_reports/.coverage.${{ env.JOB_FILE_NAME }}"
        cp coverage.xml "coverage_reports/coverage.${{ env.JOB_FILE_NAME }}.xml"
        venv/bin/coverage report --rcfile=.coveragerc --show-missing

    - name: Publish coverage
      uses: actions/upload-artifact@v3
      with:
        name: coverage
        path: coverage_reports/*
        if-no-files-found: error
#
# THIS FILE IS GENERATED. SEE https://github.com/Chinilla/chinilla-blockchain/tree/main/tests#readme
#
