Skip to content

Setting Up a New Punchcard Repository

Scott Nath edited this page Sep 9, 2016 · 5 revisions

Create github repository

  1. Create a new repository in the Punchcard CMS Org
  2. Locally clone the new repo from the Punchcard Org and not your fork - you want the Punchcard CMS fork to be the canonical origin for now

.gitignore

Locally create a node module

  • Set up an awesome new Node module using npm init
    • Make sure punchcard-cms is a keyword
    • Make sure license is Apache-2.0
    • Make sure an https URL is used for the repository field
    • Make sure that main is set to index.js

github repo files

Editor config

  • Add an EditorConfig file in the root of the repository
    • Set root = true
    • For all files ([*]), set the following:
      • Set end_of_line = LF
      • Set indent_style = space
      • Set indent_size = 2
      • Set charset = utf-8
      • Set trim_trailing_whitespace = true
      • Set insert_final_newline = true

Node Version Manager

  • Add an .nvmrc file in the root of the repository
    • Set it to version v5.11

Git Hooks

  • Add Git Hooks to follow our commit conventions
    • Run npm i ghooks punchcard-commit-msg --save-dev
    • Add config.ghooks.commit-msg to package.json and set it to punchcard-commit-msg
    • This should now be in your package.json file:
    "config": {
      "ghooks": {
        "commit-msg": "punchcard-commit-msg"
      }
    }
    

Semantic Release

  • Set up Semantic Release
    • Follow general Semantic Release instructions
      • Using Travis CI
      • Do not create a .travis.yml file (that'll happen later)
        • On the last question "What kind of .travis.yml do you want?", you should select "Create no .travis.yml".
    • Run npm i punchcard-semantic-release --save-dev to install Punchcard's Semantic Release configuration
      • Add release.analyzeCommits to package.json and set it to punchcard-semantic-release/analyze`
      • Add release. generateNotes to package.json and set it to punchcard-semantic-release/notes `
      • This should now be in your package.json file:
      "release": {
        "analyzeCommits": "punchcard-semantic-release/analyze",
        "generateNotes": "punchcard-semantic-release/notes"
      }
      

Unit Testing and Code Coverage

Modules to install

  • Run npm i ava tap-diff nyc coveralls eslint eslint-config-punchcard --save-dev

ESLint

package.json additions

NPM Scripts

  • Add scripts.lint to package.json and set it to eslint index.js lib && eslint -c ./.eslintrc-ava.yml tests
  • Add scripts.ava to package.json and set it to ava | tap-diff
  • Add scripts.nyc to package.json and set it to nyc --all npm run ava
  • Add scripts.pretest to package.json and set it to npm run lint
  • Add scripts.test to package.json and set it to npm run nyc
  • Add scripts.coverage to package.json and set it to nyc report --reporter=text-lcov | coveralls

Testing Configuration

  • Add nyc.exclude to package.json and set it to [ "tests/**/*" ]
  • Add ava.files to package.json and set it to [ "tests/**/*.js" ]
  • Add ava.failFast to package.json and set it to true
  • Add ava.tap to package.json and set it to true

Travis config file

  • Add .travis.yml file
    • Set sudo to false
    • Set language to node_js
    • Set node_js to - '5.11'
    • Set cache.directories to - node_modules
    • Set before_script to - npm prune
    • Set after_success to - npm run coverage and - npm run semantic-release
    • Set branches.except to /^v\d+\.\d+\.\d+$/
    • Set notifications.email to false

Set up Greenkeeper

  • Run greenkeeper enable to set up Greenkeeper
    • *You must have git remote origin set to the canonical repository

Set up Travis for CI/CD

  • Go to Travis and make sure Travis is enabled for the repository
  • Configure the Travis Slack integration using the "Encrypting your credentials" setup instructions
  • Add relevant badges to README.md

Coveralls

  • Set up Coveralls for Code Coverage
    • Go to Coveralls and enable Coveralls for the repository
      • You may need to sync your repos - check page for "JUST CREATED OR GOT ACCESS TO A NEW GIT REPO?" section
    • Go to /settings for the repository in Coveralls
      • Disable Leave Comments?
      • Enable Use Status API
      • Ensure Coverage Threshold for Failure is blank
      • Set Coverage Decrease Threshold for Failure to 3
      • Configure the Incoming WebHooks integration to add Slack for Coveralls (/notifications/slack_webhook from project homepage on Coveralls)
    • Add relevant badges to README.md

Node Security

  • Set up Node Security for continuous security monitoring
    • Go to Node Security and enable Node Security for the repository
    • Add relevant badges to README.md

Github Protected Branches

  • Set up GitHub Protected Branches
    • Travis and Coveralls will need to have run at least once before this step can be followed
    • Go to /settings/branches for the repository
    • Enable Protected branches for the master branch
      • Enable Protect this branch
      • Enable `Required status checks to pass before merging
      • Enable Include administrators
      • Enable Require branches to be up to date before merging
      • Enable continuous-integration/travis-ci and coverage/coveralls for required checks

Change git remotes

  • Remote origin should be changed to your fork
  • Remote upstream should be the punchcard-cms fork