Giter VIP home page Giter VIP logo

python's Introduction

PyPI Python versions Build Status

python

Write your Dangerfiles in Python.

Requirements

⚠️ danger-python is currently work in progress. Breaking changes may occur.

Running danger-python requires:

  • Python 3.7 (tested under Python 3.7.5)
  • danger-js 9.2 (tested under danger-js 9.2.10)

Installation

In order to test the script please run the following commands:

# install danger-js
npm install -g danger
# install danger-python
pip install danger-python
# run danger-python
danger-python pr https://github.com/microsoft/TypeScript/pull/34806

dangerfile.py

You can choose between shorter untyped version of dangerfile.py:

title = danger.github.pr.title
markdown(title)

Or more verbose typed version:

from danger_python import Danger, markdown

danger = Danger()
title = danger.github.pr.title
markdown(title)

Using as GitHub Action

  1. Create a dangerfile.py in the root directory of your repository.
  2. Add a following workflow:
name: Danger
on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: danger/python@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Using as a CI step (Travis)

  1. Create a dangerfile.py in the root directory of your repository.
  2. Set up the CI to execute the danger-python script after the test suite.

Example .travis.yml configuration:

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
    - pip install danger-python
    - danger-python ci -v

Development

To develop the danger-python, clone the repository and run the following commands:

# install danger
npm install -g danger
# install poetry
pip install poetry
# install project dependencies
poetry install
# activate virtual environment
poetry shell
# run tests
pytest

To regenerate the input JSONSchema, put the latest version in scripts/input_schema.json and run the following commands:

cd scripts
python generate_scheme.py

This should update the danger_python/models.py file.

⚠️ Please, be careful with the generation script since the master branch contains the hand edits to the schema. They are all covered by the test suite, though.

Building plugins

To build a plugin, add a danger-python as a dependency and subclass the DangerPlugin class:

from danger_python.plugins import DangerPlugin

class ExamplePlugin(DangerPlugin):
    def hello_world(self):
        count = len(self.danger.git.modified_files)
        self.message(f"ExamplePlugin says hello to {count} modified files")

Importing the package in a dangerfile.py will import all the instance methods to the module-level globals:

import example_plugin 

# calls hello_world method from the plugin class
example_plugin.hello_world()

python's People

Contributors

kempniu avatar orta avatar turekj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python's Issues

I get an error with no error message

Using danger-python-0.1.0 and [email protected] in CLI I get the following error:

(env) [jay@jay-arch DiscordBot]$ danger-python pr TrainerDex/DiscordBot#25
Starting Danger PR on TrainerDex/DiscordBot#25
You don't have a DANGER_GITHUB_API_TOKEN set up, this is optional, but TBH, you want to do this
Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile
Usage: danger-python run [OPTIONS]
Try 'danger-python run --help' for help.

Error: no such option: -p

Danger: ⅹ Failing the build, there is 1 fail.

Failures

danger-python failed.

Markdowns

Log

I get the same issue in the GitHub action

Status of project

The website says it is a work in progress but there hasn't been an update to this repo in three years. Can you please clarify the status of this project?

Is this project abandoned?

It seems like the last commit was over 3 years ago. Just wanted to see if this is still something being pursued.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.