Skip to content

Commit

Permalink
Merge pull request #9 from pustovitDmytro/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
pustovitDmytro committed May 4, 2021
2 parents 97ba84b + feaafc2 commit b4e7463
Show file tree
Hide file tree
Showing 29 changed files with 6,029 additions and 5,838 deletions.
154 changes: 154 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
defaults: &defaults
resource_class: small
docker:
- image: circleci/node:14
cache-defaults: &cache-defaults
keys:
- -{{ checksum "package-lock.json" }}

parameters:
env-tests:
type: boolean
default: false

aliases:
- &set-github-read-token
name: Set Danger Token
command: |
echo 'export DANGER_GITHUB_API_TOKEN=$(echo Z2hwXzFldFVxODNZTUhCa0ZQUjk0WVV1blFXZTFCVmkzajRSOEpxRQo= | base64 --decode)' >> $BASH_ENV
source $BASH_ENV
- &danger-pr
name: Run danger
command: npx danger ci -d .dangerfile.js
- &coveralls
name: Upload to coveralls
command: npm run coveralls
- &coverage
name: Test Coverage
command: npm run test:coverage -- --reporter mocha-junit-reporter --reporter-options mochaFile=reports/test-results/mocha/test-results.xml
- &lint
name: JavaScript Linter
command: npm run test:lint -- --format junit --output-file ./reports/test-results/eslint/eslint.xml
- &debt
name: Technical Debt
command: npm run test:debt
- &test-package
name: Test packed app
command: npm run test:package
- &security
name: Validate dependencies
command: npm run test:security
- &install
name: Installing Dependencies
command: npm ci
- &cache-modules
key: -{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- node_modules
- lib

version: 2.1
debug: true
jobs:
danger-pr:
<<: *defaults
steps:
- checkout
- run: *install
- run: *set-github-read-token
- run: *danger-pr

install:
<<: *defaults
steps:
- checkout
- run: *install
- run: *security
- run: *danger-pr
- save_cache: *cache-modules
test-coverage:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache-defaults
- run: *coverage
- store_test_results:
path: reports/test-results
- store_artifacts:
path: reports
- run: *coveralls
test-lint:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache-defaults
- run: *lint
- store_test_results:
path: reports/test-results
test-debt:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache-defaults
- run: *debt
- store_artifacts:
path: reports
test-package:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache-defaults
- run: *test-package
- store_artifacts:
path: tmp
deploy:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache-defaults
- run:
name: Create Release
command: "[ -z ${CIRCLE_SKIP_DEPLOY+x} ] && npm run semantic-release || echo 'job skipped'"

workflows:
version: 2
main:
jobs:
- install:
context: pr
- test-package:
requires:
- install
- test-lint:
requires:
- install
- test-debt:
requires:
- install
- test-coverage:
requires:
- install
- deploy:
context: npm-packages
requires:
- test-coverage
- test-package
filters:
branches:
only: master
pr:
jobs:
- danger-pr:
filters:
branches:
only: /pull\/[0-9]+/
env-tests:
when: << pipeline.parameters.env-tests >>
jobs:
- install
48 changes: 48 additions & 0 deletions .dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { message, danger, warn, fail } from 'danger';
import lint from '@commitlint/lint';
import commitLintConfig from './.commitlintrc';

const src = danger.git.fileMatch('src/*');
const tests = danger.git.fileMatch('tests/*');
const system = danger.git.fileMatch('.*', '.*/**', 'LICENSE.md', 'package-lock.json', 'package.json');
const isOwner = danger.github.pr.user.login === danger.github.thisPR.owner;
const renovateBot = 29139614;
const TrustedBots = [ renovateBot ];
// const isBot = danger.github.pr.user.type === 'Bot';
const isTrustedBot = TrustedBots.includes(danger.github.pr.user.id);
const modifiedList = danger.git.modified_files.join('\n\n- ');

export default async function () {
message(`Changed Files in this PR:\n\n- ${modifiedList}`);

const { data: contributors } = await danger.github.api.repos.listContributors(danger.github.thisPR);
const contributor = contributors.find(c => c.login === danger.github.pr.user.login);

if (contributor) {
message(`${contributor} login already contributed ${contributor.contributions} times`);
}

if (system.modified && !isOwner) {
const files = system.getKeyedPaths().modified;
const level = (contributor || isTrustedBot) ? warn : fail;

level(`Only owner can change system files [${files.join(', ')}], please provide issue instead`, files[0]);
}

if (src.modified && !tests.modified) {
warn('Source files were changed without tests');
}

const promises = danger.github.commits.map(async commit => {
const msg = commit.commit.message;
const comitLintReport = await lint(msg, commitLintConfig.rules);

if (!comitLintReport.valid) {
const errors = comitLintReport.errors.map(e => e.message);

fail(`Commit [${commit.sha}]:\n${msg} not mathing convention:\n${errors.join('\n')}`);
}
});

await Promise.all(promises);
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.dangerfile.js
14 changes: 3 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"extends": "webbylab",
"env": {
"browser": true
},
"rules": {
"import/no-commonjs": 0,
"func-names": 0,
"func-style": 0,
"prefer-arrow-callback": 0,
"linebreak-style": 0
}
"extends": [
"incredible"
]
}
52 changes: 52 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug: Issue brief description [version]'
labels: bug
assignees: pustovitDmytro

---

**Issue Description**
A clear and concise description of what the bug is. Paste here brief summary of your issue.

**Please follow the general troubleshooting steps first:**
- [ ] I've searched on the [issue tracker](../) before creating one.
- [ ] I'm running latest package version.
- [ ] I'm ready to provide help with fix, if needed.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. See error

### What do you expect to happen?

<!-- Explain what behavior you wanted/expected. You may include an output. -->

_I wanted Foo!_

```
Output here
```

### What is actually happening?

<!-- Show what happened -->

_The output was Bar!_

```
Output here
```

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment:**
- Version X.X.X
- Node.js version: XXX
- Operating System: XXX

**Additional context**
Add any other context about the problem here.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'Feature: Issue brief description'
labels: enhancement
assignees: pustovitDmytro

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
Ex. I'm always frustrated when [...]

**Please follow the general troubleshooting steps first:**
- [ ] I've searched on the [issue tracker](../) before creating one.
- [ ] I'm running latest package version.
- [ ] I'm ready to provide help with enhancement, if needed.
- [ ] Feature will break current functionality

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
47 changes: 47 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
**IMPORTANT: Please do not create a Pull Request without creating an issue first.**

Please, go through these steps before you submit a PR:
1. Make sure that your PR is not a duplicate.
2. If not, then make sure that:

a. You have done your changes in a separate branch. Branches MUST have descriptive names that start with either the `fix/` or `feature/` prefixes. Good examples are: `fix/signin-issue` or `feature/issue-templates`.

b. You have a descriptive commit message with a short title (first line).

c. You have only one commit (if not, squash them into one commit).

d. `npm test` doesn't throw any error. If it does, fix them first and amend your commit (`git commit --amend`).

3. **After** these steps, you're ready to open a pull request.

a. Give a descriptive title to your PR.

b. Describe your changes.

c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes.


*Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.*


**IMPORTANT**: Please review the [CONTRIBUTING](../#contribute) section for detailed contributing guidelines.

**PLEASE REMOVE THIS NOTES BEFORE SUBMITTING**





**Fixes** #XX

Please provide enough information so that others can review your pull request:

<!-- You can skip this if you're fixing a typo -->


Explain the **details** for making this change. What existing problem does the pull request solve?

<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->

A picture tells a thousand words:
<!-- Provide a screenshot of npm test command here-->
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ node_modules
etc/*.js
etc/*.json
lib/*
coverage/*
tmp/*
logs/*
*.log
*.log
*.tgz
reports/*
.coveralls.yml
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
npx commitlint --edit $1
9 changes: 9 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"threshold": 5,
"reporters": ["html", "console"],
"ignore": [],
"output": "./reports/jscpd",
"minLines": 3,
"minTokens": 30,
"ignoreCase": true
}
13 changes: 13 additions & 0 deletions .mocharc.bundle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"diff": true,
"extension": ["js"],
"reporter": "spec",
"slow": 100,
"timeout": 30000,
"ui": "qunit",
"exit": true,
"color": true,
"full-trace": true,
"recursive": true,
"require": ["./tests/test.env.js"]
}
Loading

0 comments on commit b4e7463

Please sign in to comment.