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

GitLab-CI sensor integration addition. #16561

Merged
merged 22 commits into from Sep 25, 2018

Conversation

Projects
None yet
7 participants
@DanielWinks
Contributor

DanielWinks commented Sep 11, 2018

Description:

GitLab_CI sensor. This sensor allows integration of the CI pipeline job status into Home Assistant, enabling similar functionality to the Travis-CI sensor. It can track 1 GitLab repository, and provide the status of the most-recent pipeline job. Unlike Travis-CI, this sensor doesn't allow the choosing of a particular branch to track, because of differences in the GitLab API, however this integration does report which branch the latest CI pipeline job was ran against.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6255

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: gitlab_ci
    gitlab_id: '1234567'
    token: 'aaaaaaaaaaAAAAAAAAAA'

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
@homeassistant

This comment has been minimized.

homeassistant commented Sep 11, 2018

Hi @DanielWinks,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

ATTR_BUILD_STATUS: self._status,
ATTR_BUILD_STARTED: self._started_at,
ATTR_BUILD_FINISHED: self._finished_at,
ATTR_BUILD_DURATION: self._duration,

This comment has been minimized.

@balloob

balloob Sep 14, 2018

Member

We should not include duration. You're not allowed to store those in the state machine.

This comment has been minimized.

@DanielWinks

DanielWinks Sep 14, 2018

Contributor

This is the duration that GitLab-CI took to build the CI job. It's just a string value, so the end user can see how long it took GitLab-CI to build. This should be fine, correct? This is not a duration of this sensor or generated by this sensor, it's the string 'duration' returned from the GitLab API.

This comment has been minimized.

@balloob

balloob Sep 21, 2018

Member

Is it being updated while a build is running? If so, it should not be included.

This comment has been minimized.

@DanielWinks

DanielWinks Sep 21, 2018

Contributor

No, it's the duration the build took, as reported by the GitLab API. Basically, the API returns data of "This is the build SHA, this is the branch, your CI/CD was successful or failed, and it took X seconds to run". It isn't updated while it's running, it's just a data point returned by the API when the build has completed. It's exactly the same "duration" as the "last_build_duration" reported in the current Travis CI sensor.

Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/gitlab_ci.py Outdated

DanielWinks added some commits Sep 21, 2018

Changed PLATFORM_SCHEMA and renamed add_devices.
Changed PLATFORM_SCHEMA to use SCAN_INTERVAL and add_devices to add_entities
@MartinHjelmare

Looks good!

@@ -0,0 +1,174 @@
"""Module for retrieving latest GitLab CI job information."""

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Sep 21, 2018

Member

Update the docstring to match other platforms.

@Danielhiversen Danielhiversen merged commit 4a4c07a into home-assistant:dev Sep 25, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.003%) to 93.54%
Details

@wafflebot wafflebot bot removed the in progress label Sep 25, 2018

@balloob balloob referenced this pull request Oct 12, 2018

Merged

0.80.0 #17361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment