Skip to content

Instantly share code, notes, and snippets.

@damian-burke
damian-burke / dangerfile.js
Created September 13, 2020 21:09
Dangerfile to scan ktlint / detekt / Android Lint reports
import {danger, fail, message, warn, schedule} from 'danger'
const reporter = require("danger-plugin-lint-report")
// Scan ktlint reports
schedule(reporter.scan({
fileMask: "**/reports/ktlint/*.xml",
reportSeverity: true,
requireLineModification: true,
}))
name: DangerJS
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
name: DangerJS
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
name: DangerJS
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
@damian-burke
damian-burke / danger.yml
Created September 13, 2020 20:57
DangerJS on GitHub Actions
name: DangerJS
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
@damian-burke
damian-burke / dangerfile.js
Last active September 13, 2020 20:42
DangerJS CHANGELOG modification check
// Add a CHANGELOG entry for app changes
const hasChangelog = danger.git.modified_files.includes("CHANGELOG.yml")
if (!hasChangelog) {
fail("Please add a changelog entry for your changes. :crystall_ball:")
}
interface SampleApi {
@GET("fact")
@Headers(TokenInterceptor.AUTHENTICATION_APP)
fun getAppScopeCatFact(): Call<CatFact>
@GET("fact")
@Headers(TokenInterceptor.AUTHENTICATION_USER)
fun getUserScopeCatFact(): Call<CatFact>
}
class TokenInterceptor: AuthenticationInterceptor(AUTHENTICATION_HEADER) {
// ...
companion object {
const val AUTHENTICATION_HEADER = "Authentication"
const val KEY_USER_TOKEN = "User Token"
const val KEY_APP_TOKEN = "App Token"
const val AUTHENTICATION_USER = "$AUTHENTICATION_HEADER: $KEY_USER_TOKEN"
const val AUTHENTICATION_APP = "$AUTHENTICATION_HEADER: $KEY_APP_TOKEN"
GET /secured/data HTTP/1.1
...
Authentication: Token my_super_secret_user_token
...
GET /secured/data HTTP/1.1
...
Authentication: User Token
...