Skip to content

Instantly share code, notes, and snippets.

View ardydedase's full-sized avatar
🏠
Working from home

Ardy Gallego Dedase ardydedase

🏠
Working from home
View GitHub Profile
steps:
- name: node:16
env:
- 'DANGER_MANUAL_CI=CloudBuild'
- 'DANGER_MANUAL_GH_REPO=ardydedase/danger-example'
args:
- '-c'
- |
echo "Running Danger build..."
npm install
import {danger, warn, fail} from 'danger';
const reviewLargePR = () => {
const bigPRThreshold = 300;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(`:exclamation: Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR for faster, easier review.`);
}
}
const ensurePRHasAssignee = () => {
// Always ensure we assign someone, so that our Slackbot can do its work correctly
if (danger.github.pr.assignee === null) {
const reviewLargePR = () => {
const bigPRThreshold = 300;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(`:exclamation: Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR for faster, easier review.`);
}
}
# Meant to be used locally for testing.
steps:
- name: node:16
env:
- 'DANGER_MANUAL_CI=CloudBuild'
- 'DANGER_MANUAL_GH_REPO=ardydedase/danger-example'
# TODO: Replace with your own GitHub token
# - 'DANGER_GITHUB_API_TOKEN=<REPLACE_WITH_YOUR_GH_TOKEN>'
args:
- '-c'
@ardydedase
ardydedase / app.component.spec.ts
Created March 12, 2022 16:51
Spectator test for sample app
import { AppComponent } from './app.component';
import { Spectator, createComponentFactory } from '@ngneat/spectator';
import { GithubService } from './github.service';
import { of } from 'rxjs';
describe('AppComponentSpectator', () => {
let spectator: Spectator<AppComponent>;
// Create componnent providers
const createComponent = createComponentFactory({
component: AppComponent,
@ardydedase
ardydedase / initSearchUsers.ts
Created February 6, 2022 16:13
Sample app initSearchUsers method
initSearchUsers(): void {
this.searchUsersFormControl.valueChanges
.pipe(takeUntil(this.destroyed$))
.subscribe((searchString) => {
if (searchString) {
this.searchType = SearchType.USERS;
this.searchSubject$.next(searchString);
}
});
}
@ardydedase
ardydedase / app.component.spec.ts
Last active February 6, 2022 04:55
Setup spectator tests
import { AppComponent } from './app.component';
import { Spectator, createComponentFactory } from '@ngneat/spectator';
import { GithubService } from './github.service';
describe('AppComponentSpectator', () => {
let spectator: Spectator<AppComponent>;
const createComponent = createComponentFactory({
component: AppComponent,
providers: [
{ provide: GithubService, useValue: {} }
@ardydedase
ardydedase / takeUntiNgOnInit.ts
Last active September 30, 2021 04:39
takeUntiNgOnInit.ts
ngOnInit() {
this.results$ = this.searchSubject$.pipe(
debounceTime(200),
distinctUntilChanged(),
switchMap((searchString) => {
if ((searchString as any).replace(/\s/g, '')) {
switch (this.searchType) {
case SearchType.REPOS:
return this.githubService.searchRepos(searchString);
case SearchType.USERS:
this.searchReposFormControl.valueChanges
.subscribe((searchString) => {
if (searchString) {
this.searchType = SearchType.REPOS;
this.searchSubject$.next(searchString);
}
});
this.searchUsersFormControl.valueChanges
.subscribe((searchString) => {
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable()
export class GithubService {
constructor(private http: HttpClient) {}
public searchRepos(searchString) {
return this.http