-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from turekj/feature/github_actions_support
Initial support for GitHub actions
- Loading branch information
Showing
11 changed files
with
123 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Danger | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run Danger | ||
uses: ./ | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: python | ||
python: | ||
- "3.7" | ||
cache: | ||
yarn: true | ||
pip: true | ||
directories: | ||
- node_modules | ||
install: | ||
- pip install poetry | ||
- poetry install | ||
script: | ||
- poetry run pytest | ||
after_script: | ||
- nvm install 10.16.0 | ||
- nvm use 10.16.0 | ||
- yarn global add danger | ||
- poetry run danger-python ci -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Master | ||
|
||
* No changes. | ||
|
||
### 0.1.0 | ||
|
||
* Initial release of the plugin. - [@turekj] | ||
|
||
[@turekj]: https://github.com/turekj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM python:3.7 | ||
|
||
LABEL maintainer="Jakub Turek <[email protected]>" | ||
LABEL "com.github.actions.name"="danger-python" | ||
LABEL "com.github.actions.description"="Runs Python Dangerfiles" | ||
LABEL "com.github.actions.icon"="zap" | ||
LABEL "com.github.actions.color"="blue" | ||
|
||
# Install dependencies | ||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - | ||
RUN apt-get install -y nodejs | ||
|
||
RUN python -m pip install --upgrade pip | ||
RUN pip install poetry | ||
|
||
RUN mkdir -p /usr/src/danger-python | ||
COPY . /usr/src/danger-python | ||
RUN cd /usr/src/danger-python && \ | ||
poetry config virtualenvs.create false && \ | ||
poetry install --no-dev | ||
|
||
ENTRYPOINT ["npx", "--package", "danger", "danger-python", "ci"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
title = danger.github.pr.title | ||
markdown(title) | ||
touched_files = danger.git.modified_files + danger.git.created_files | ||
has_source_changes = any(map(lambda f: f.startswith("danger_python"), touched_files)) | ||
has_changelog_entry = "CHANGELOG.md" in touched_files | ||
is_trivial = "#trivial" in danger.github.pr.title | ||
|
||
if has_source_changes and not has_changelog_entry and not is_trivial: | ||
warn("Please, add a CHANGELOG.md entry for non-trivial changes") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Optional | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from danger_python.models import DangerDSLJSONType, GitHubReviewState | ||
|
||
|
||
def test_github_dsl_handles_correct_review_states(): | ||
""" | ||
Test that GitHub DSL handles correct review states. | ||
""" | ||
dsl_json = { | ||
"github": { | ||
"reviews": [ | ||
{"state": "APPROVED"}, | ||
{"state": "CHANGES_REQUESTED"}, | ||
{"state": "COMMENTED"}, | ||
{"state": "PENDING"}, | ||
{"state": "DISMISSED"}, | ||
] | ||
} | ||
} | ||
|
||
dsl = DangerDSLJSONType(**dsl_json) | ||
|
||
assert len(dsl.github.reviews) == 5 | ||
assert dsl.github.reviews[0].state == GitHubReviewState.APPROVED | ||
assert dsl.github.reviews[1].state == GitHubReviewState.CHANGES_REQUESTED | ||
assert dsl.github.reviews[2].state == GitHubReviewState.COMMENTED | ||
assert dsl.github.reviews[3].state == GitHubReviewState.PENDING | ||
assert dsl.github.reviews[4].state == GitHubReviewState.DISMISSED |