mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Resolve #133: Disabled "prompts" automatically for *Continuous Integration* systems
This commit is contained in:
@ -12,6 +12,8 @@ Release History
|
|||||||
* Added
|
* Added
|
||||||
`Project Configuration <http://docs.platformio.org/en/latest/projectconf.html>`__
|
`Project Configuration <http://docs.platformio.org/en/latest/projectconf.html>`__
|
||||||
option named `envs_dir <http://docs.platformio.org/en/latest/projectconf.html#envs-dir>`__
|
option named `envs_dir <http://docs.platformio.org/en/latest/projectconf.html#envs-dir>`__
|
||||||
|
* Disabled "prompts" automatically for *Continuous Integration* systems
|
||||||
|
(`issue #103 <https://github.com/ivankravets/platformio/issues/103>`_)
|
||||||
* Fixed firmware uploading for
|
* Fixed firmware uploading for
|
||||||
`atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__
|
`atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__
|
||||||
boards which work within ``usbtiny`` protocol
|
boards which work within ``usbtiny`` protocol
|
||||||
|
@ -18,6 +18,19 @@ General
|
|||||||
PlatformIO uses *General* environment variables for the common
|
PlatformIO uses *General* environment variables for the common
|
||||||
operations/commands.
|
operations/commands.
|
||||||
|
|
||||||
|
.. _envvar_CI:
|
||||||
|
|
||||||
|
CI
|
||||||
|
~~
|
||||||
|
|
||||||
|
PlatformIO handles ``CI`` variable which is setup by
|
||||||
|
`Continuous Integration <http://en.wikipedia.org/wiki/Continuous_integration>`_
|
||||||
|
(Travis, Circle and etc.) systems.
|
||||||
|
Currently, PlatformIO uses it to disable prompts.
|
||||||
|
|
||||||
|
In other words, ``CI=true`` automatically setup
|
||||||
|
:ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS>`.
|
||||||
|
|
||||||
.. _envvar_PLATFORMIO_HOME_DIR:
|
.. _envvar_PLATFORMIO_HOME_DIR:
|
||||||
|
|
||||||
PLATFORMIO_HOME_DIR
|
PLATFORMIO_HOME_DIR
|
||||||
|
@ -32,11 +32,12 @@ application:
|
|||||||
.. warning::
|
.. warning::
|
||||||
If you are going to run *PlatformIO* from **subprocess**, you **MUST
|
If you are going to run *PlatformIO* from **subprocess**, you **MUST
|
||||||
DISABLE** all prompts. It will allow you to avoid blocking.
|
DISABLE** all prompts. It will allow you to avoid blocking.
|
||||||
There are 2 options:
|
There are a few options:
|
||||||
|
|
||||||
- using environment variable :ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS>`
|
- using environment variable :ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=No <envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS>`
|
||||||
- disable global setting via :ref:`platformio setting enable_prompts false <cmd_settings>`
|
- disable global setting ``enable_prompts`` via :ref:`cmd_settings` command
|
||||||
command.
|
- masking under Continuous Integration system via environment variable
|
||||||
|
:ref:`CI=true <envvar_CI>`.
|
||||||
|
|
||||||
Please *choose one of* the following:
|
Please *choose one of* the following:
|
||||||
|
|
||||||
|
@ -86,7 +86,9 @@ better.
|
|||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
You can override these settings using :ref:`envvars`.
|
* The ``Yes`` value is equl to: ``True``, ``Y``, ``1``.
|
||||||
|
The value is not case sensetive.
|
||||||
|
* You can override these settings using :ref:`envvars`.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
@ -101,6 +101,10 @@ def set_state_item(name, value):
|
|||||||
|
|
||||||
|
|
||||||
def get_setting(name):
|
def get_setting(name):
|
||||||
|
# disable prompts for Continuous Integration systems
|
||||||
|
if name == "enable_prompts" and getenv("CI", "").lower() == "true":
|
||||||
|
return False
|
||||||
|
|
||||||
_env_name = "PLATFORMIO_SETTING_%s" % name.upper()
|
_env_name = "PLATFORMIO_SETTING_%s" % name.upper()
|
||||||
if _env_name in environ:
|
if _env_name in environ:
|
||||||
return sanitize_setting(name, getenv(_env_name))
|
return sanitize_setting(name, getenv(_env_name))
|
||||||
|
@ -1,28 +1,24 @@
|
|||||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
# See LICENSE for details.
|
# See LICENSE for details.
|
||||||
|
|
||||||
|
from os import environ
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from platformio import app
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def platformio_setup(request):
|
def platformio_setup(request):
|
||||||
prev_settings = dict(
|
pioenvvars = ("ENABLE_PROMPTS", "ENABLE_TELEMETRY")
|
||||||
enable_telemetry=None,
|
for v in pioenvvars:
|
||||||
enable_prompts=None
|
environ["PLATFORMIO_SETTING_%s" % v] = "No"
|
||||||
)
|
|
||||||
for key, value in prev_settings.iteritems():
|
|
||||||
prev_settings[key] = app.get_setting(key)
|
|
||||||
# disable temporary
|
|
||||||
if prev_settings[key]:
|
|
||||||
app.set_setting(key, False)
|
|
||||||
|
|
||||||
def platformio_teardown():
|
def platformio_teardown():
|
||||||
# restore settings
|
for v in pioenvvars:
|
||||||
for key, value in prev_settings.iteritems():
|
_name = "PLATFORMIO_SETTING_%s" % v
|
||||||
app.set_setting(key, value)
|
if _name in environ:
|
||||||
|
del environ[_name]
|
||||||
|
|
||||||
request.addfinalizer(platformio_teardown)
|
request.addfinalizer(platformio_teardown)
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -38,6 +38,8 @@ basepython =
|
|||||||
py27: python2.7
|
py27: python2.7
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
deps = pytest
|
deps = pytest
|
||||||
|
setenv =
|
||||||
|
PLATFORMIO_SETTING_ENABLE_PROMPTS = False
|
||||||
commands =
|
commands =
|
||||||
{envpython} --version
|
{envpython} --version
|
||||||
pip install --egg http://sourceforge.net/projects/scons/files/latest/download
|
pip install --egg http://sourceforge.net/projects/scons/files/latest/download
|
||||||
|
Reference in New Issue
Block a user