Skip to content

Commit

Permalink
ci: update ci configs
Browse files Browse the repository at this point in the history
- add windows runner
- update actions versions
- other minor enhancements
  • Loading branch information
karlicoss committed May 3, 2022
1 parent 80c5be7 commit 637982a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,54 @@ 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

# 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/
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 24 additions & 8 deletions scripts/ci/run
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]


def main():
def main() -> None:
pkg = 'my'
subpackages = find_namespace_packages('.', include=('my.*',))
setup(
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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_*
Expand Down

0 comments on commit 637982a

Please sign in to comment.