diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 49040c9f..082503d3 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,81 +1,122 @@ name: Tests on: + # Allow to manually trigger through github API + workflow_dispatch: + # Triggers with push to master push: + branches: + - master + + # Triggers with push to a pr aimed at master pull_request: + branches: + - master + schedule: - # Every Monday at 7AM UTC - - cron: '0 07 * * 5' + # Every day at 7AM UTC + - cron: '0 07 * * *' + +env: + + # Arguments used for pytest + pytest-args: >- + --durations=20 + -v + + # Arguments used for code-cov which is later used to annotate PR's on github + code-cov-args: >- + --cov=ConfigSpace + --cov-report=xml jobs: - ubuntu: - runs-on: ubuntu-18.04 + unit-test: + name: ${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.kind }} + + runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9] - use-conda: [true, false] - use-dist: [false] + os: [windows-latest, ubuntu-latest, macos-latest] + python-version: ["3.7", "3.8", "3.9", "3.10"] + kind: ['conda', 'source', 'dist'] + + exclude: + # Exclude all configurations *-*-dist, include one later + - kind: 'dist' + + # Exclude windows as bash commands wont work in windows runner + - os: windows-latest + + # Exclude macos as there are permission errors using conda as we do + - os: macos-latest + include: - - python-version: 3.8 + # Add the tag code-cov to ubuntu-3.7-source + - os: ubuntu-latest + python-version: 3.7 + kind: 'source' code-cov: true - - python-version: 3.7 - use-conda: false - use-dist: true - fail-fast: false + + # Include one config with dist, ubuntu-3.7-dist + - os: ubuntu-latest + python-version: 3.7 + kind: 'dist' steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + # A note on checkout: When checking out the repository that # triggered a workflow, this defaults to the reference or SHA for that event. # Otherwise, uses the default branch (master) is used. + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Conda Install test dependencies - if: matrix.use-conda == true + + - name: Conda install + if: matrix.kind == 'conda' run: | # Miniconda is available in $CONDA env var $CONDA/bin/conda create -n testenv --yes pip wheel python=${{ matrix.python-version }} $CONDA/envs/testenv/bin/python3 -m pip install --upgrade pip $CONDA/envs/testenv/bin/pip3 install -e .[test] - - name: Install test dependencies - if: matrix.use-conda == false && matrix.use-dist == false + + - name: Source install + if: matrix.kind == 'source' run: | python -m pip install --upgrade pip - if [[ `python -c 'import platform; print(platform.python_version())' | cut -d '.' -f 2` -eq 6 ]]; then - # Numpy 1.20 dropped suppert for Python3.6 - pip install "numpy<=1.19" - fi pip install -e .[test] - sudo apt-get update - - name: Dist Install test dependencies - if: matrix.use-conda == false && matrix.use-dist == true + + - name: Dist install + if: matrix.kind == 'dist' run: | python -m pip install --upgrade pip - sudo apt-get update - # We need to install for the dependencies, like pytest python setup.py sdist last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1) - pip install $last_dist[test] - - name: Store repository status + python -m pip install $last_dist[test] + + - name: Store git status id: status-before run: | echo "::set-output name=BEFORE::$(git status --porcelain -b)" - - name: Conda Run tests - timeout-minutes: 45 - if: matrix.use-conda == true - run: | - export PATH="$CONDA/envs/testenv/bin:$PATH" - if [ ${{ matrix.code-cov }} ]; then codecov='--cov=ConfigSpace --cov-report=xml'; fi - $CONDA/envs/testenv/bin/python3 -m pytest --durations=20 -v $codecov test - - name: Run tests + + - name: Tests timeout-minutes: 45 - if: matrix.use-conda == false run: | - if [ ${{ matrix.code-cov }} ]; then codecov='--cov=ConfigSpace --cov-report=xml'; fi - pytest --durations=20 -v $codecov test + if [[ ${{ matrix.kind }} == 'conda' ]]; then + export PATH="$CONDA/envs/testenv/bin:$PATH" + fi + + if [ ${{ matrix.code-cov }} ]; then + pytest ${{ env.pytest-args }} ${{ env.code-cov-args }} test + else + pytest ${{ env.pytest-args }} test + fi + - name: Check for files left behind by test if: ${{ always() }} run: | @@ -87,6 +128,7 @@ jobs: echo "Not all generated files have been deleted!" exit 1 fi + - name: Upload coverage if: matrix.code-cov && always() uses: codecov/codecov-action@v1