Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test on Windows with GitHub Actions #2461

Draft
wants to merge 4 commits into
base: py3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: tests
on: [push]

jobs:
test:

test-linux:
runs-on: ubuntu-16.04
strategy:
max-parallel: 16
Expand Down Expand Up @@ -47,3 +46,48 @@ jobs:
find src -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
find plugins -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/

test-windows:
runs-on: windows-latest
strategy:
max-parallel: 16
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Prepare for installation
run: |
python -m pip install setuptools
python -m pip install --upgrade pip wheel
python -m pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium

- name: Install
run: |
python -m pip install --upgrade -r requirements.txt
python -m pip list

- name: Prepare for tests
run: |
echo "::set-env name=ZERONET_OPENSSL_BIN::$((Get-Command openssl).definition)"
openssl version -a
openssl rand -hex 256

- name: Test
run: |
python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini
$env:ZERONET_LOG_DIR="log/CryptMessage"; python -m pytest -x plugins/CryptMessage/Test
$env:ZERONET_LOG_DIR="log/Bigfile"; python -m pytest -x plugins/Bigfile/Test
$env:ZERONET_LOG_DIR="log/AnnounceLocal"; python -m pytest -x plugins/AnnounceLocal/Test
$env:ZERONET_LOG_DIR="log/OptionalManager"; python -m pytest -x plugins/OptionalManager/Test
$env:ZERONET_LOG_DIR="log/Multiuser"; mv plugins/disabled-Multiuser plugins/Multiuser; python -m pytest -x plugins/Multiuser/Test
$env:ZERONET_LOG_DIR="log/Bootstrapper"; mv plugins/disabled-Bootstrapper plugins/Bootstrapper; python -m pytest -x plugins/Bootstrapper/Test
find src -name "*.json" | xargs -n 1 python -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
find plugins -name "*.json" | xargs -n 1 python -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/
3 changes: 3 additions & 0 deletions src/Crypt/CryptConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def createSslRsaCert(self):
)
back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "")
proc.wait()
print(back)

print(subprocess.run(helper.shellquote(self.openssl_bin) + " rand -hex 65536", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace"))

if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)):
self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back)
Expand Down
2 changes: 2 additions & 0 deletions src/Test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def pytest_collection_modifyitems(config, items):
config.data_dir = TEST_DATA_PATH # Use test data for unittests
if "ZERONET_LOG_DIR" in os.environ:
config.log_dir = os.environ["ZERONET_LOG_DIR"]
if "ZERONET_OPENSSL_BIN" in os.environ:
config.openssl_bin_file = os.environ["ZERONET_OPENSSL_BIN"]
config.initLogging(console_logging=False)

# Set custom formatter with realative time format (via: https://stackoverflow.com/questions/31521859/python-logging-module-time-since-last-log)
Expand Down