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

Try out danger via Github Actions #290

Closed
wants to merge 5 commits into from
Closed
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
27 changes: 27 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Danger

on: [pull_request]

jobs:
build:
name: Danger
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install yarn
run: npm install --global yarn
- name: configlet lint
run: |
bin/fetch-configlet
bin/configlet lint .
- name: make report
run: make report
- name: Danger
uses: danger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

53 changes: 53 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require 'pathname';

# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ }
warn('Please rebase to get rid of the merge commits in this PR, otherwise, if this PR is small, this should be squash-merged so the merge commit is squashed.')
end
can_merge = github.pr_json["mergeable"]
is_merged = github.pr_json["merged"]

if is_merged
warn("This PR was merged before CI was done.", sticky: false)
else
warn("This PR cannot be merged yet.", sticky: false) unless can_merge
end

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"

# Warn when there is a big PR
warn("Big PR") if git.lines_of_code > 500

# Ensure there is a summary
warn("Please provide a summary in the Pull Request description. See more info <a href=\"http\://tinyletter.com/exercism/letters/exercism-pull-requests\">here.</a>") if github.pr_body.length < 5

# LINT Comments in for each Line
jsonpath = "lintreport.json"
contents = File.read jsonpath
require "json"
if contents.to_s == ''
contents = "[]"
end
json = JSON.parse contents

json.each do |object|
# TODO: use env path so it works everwhere
source_file = Pathname.new(object["filePath"])
.relative_path_from(Pathname.new('/home/travis/build/exercism/typescript/')).to_s;

(object["messages"] || []).each do |message|
danger_message = "#{message["message"].to_s} (#{message["ruleId"].to_s})"
source_line = message["line"]

# only warn for files that were edited in this PR.
if git.modified_files.include? source_file
# get away from doing inline comments since they are buggy as of Sep-2016
shortFile.prepend("/") unless source_file[0] == '/'

warn(danger_message, file: source_file, line: source_line)
else
message(danger_message, file: source_file, line: source_line)
end
end
end
7 changes: 4 additions & 3 deletions maintaining/package.track.json → package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@exercism/typescript-track",
"name": "@exercism/typescript",
"version": "1.0.0",
"description": "Exercism TypeScript track top-level runner. Not meant for individual exercises.",
"private": true,
Expand All @@ -8,8 +8,9 @@
"url": "https://github.com/exercism/typescript"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.3.3",
"@typescript-eslint/parser": "^2.3.3",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"danger": "9.2.2",
"eslint": "^6.5.1",
"eslint-plugin-import": "^2.18.2",
"typescript": "^3.6.4"
Expand Down