diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35cddb26..acace3e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,31 +7,37 @@ on: tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi # Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them". pull_request: # needed to trigger on others' PRs + # Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them". workflow_dispatch: # needed to trigger workflows manually # todo cron? -env: - # useful for scripts & sometimes tests to know - CI: true jobs: build: strategy: matrix: - platform: [ubuntu-latest, macos-latest] # TODO windows-latest?? - python-version: [3.7, 3.8, 3.9] + platform: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.7', '3.8', '3.9'] + exclude: [ + # windows runners are pretty scarce, so let's only run one of them.. + {platform: windows-latest, python-version: '3.7'}, + {platform: windows-latest, python-version: '3.9'}, + ] runs-on: ${{ matrix.platform }} + # TODO let's at least start running windows for now, will fix later + continue-on-error: ${{ matrix.platform == 'windows-latest' }} + steps: # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive fetch-depth: 0 # nicer to have all git history when debugging/for tests @@ -39,13 +45,16 @@ jobs: # uncomment for SSH debugging # - uses: mxschmitt/action-tmate@v3 - - run: scripts/ci/run + # explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd... + - run: bash scripts/ci/run - - uses: actions/upload-artifact@v2 + - if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms + uses: actions/upload-artifact@v2 with: name: .coverage.mypy-misc_${{ matrix.platform }}_${{ matrix.python-version }} path: .coverage.mypy-misc/ - - uses: actions/upload-artifact@v2 + - if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms + uses: actions/upload-artifact@v2 with: name: .coverage.mypy-core_${{ matrix.platform }}_${{ matrix.python-version }} path: .coverage.mypy-core/ @@ -58,11 +67,11 @@ jobs: # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 with: - python-version: '3.7' + python-version: '3.8' - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive diff --git a/pytest.ini b/pytest.ini index b6406e2b..aaa3df2a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -9,3 +9,5 @@ addopts = # otherwise it won't discover doctests # eh? importing too much # --doctest-modules + # show all test durations (unless they are too short) + --durations=0 diff --git a/scripts/ci/run b/scripts/ci/run index a7ea3bab..47014ece 100755 --- a/scripts/ci/run +++ b/scripts/ci/run @@ -1,7 +1,8 @@ -#!/bin/bash -eu +#!/bin/bash +set -eu cd "$(dirname "$0")" -cd ../.. +cd .. # git root if ! command -v sudo; then # CI or Docker sometimes doesn't have it, so useful to have a dummy @@ -10,16 +11,31 @@ if ! command -v sudo; then } fi -if ! [ -z "$CI" ]; then +if [ -n "${CI-}" ]; then # install OS specific stuff here - if [[ "$OSTYPE" == "darwin"* ]]; then + case "$OSTYPE" in + darwin*) # macos brew install fd - else + ;; + cygwin* | msys* | win*) + # windows + : + ;; + *) + # must be linux? sudo apt update sudo apt install fd-find - fi + ;; + esac fi -pip3 install --user tox -tox + +PY_BIN="python3" +# some systems might have python pointing to python3 +if ! command -v python3 &> /dev/null; then + PY_BIN="python" +fi + +"$PY_BIN" -m pip install --user tox +"$PY_BIN" -m tox diff --git a/setup.py b/setup.py index 1163008e..31fc3931 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ ] -def main(): +def main() -> None: pkg = 'my' subpackages = find_namespace_packages('.', include=('my.*',)) setup( diff --git a/tox.ini b/tox.ini index 52bfdfb6..8c22eb38 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,8 @@ [tox] minversion = 3.5 +# https://github.com/tox-dev/tox/issues/20#issuecomment-247788333 +# hack to prevent .tox from crapping to the project directory +toxworkdir={env:TOXWORKDIR_BASE:}{toxinidir}/.tox [testenv] passenv = CI CI_*