Skip to content

Commit

Permalink
Refactor CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Jun 5, 2019
1 parent f198d18 commit 71316ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
16 changes: 10 additions & 6 deletions .travis.yml
Expand Up @@ -12,18 +12,22 @@ env:
- HUSKY_DEBUG=true
script:
- npm test
# Test post-checkout

# Install hooks locally
- npm run devinstall
- cat .git/hooks/post-checkout
- time git checkout
- node scripts/ci-post-checkout-check

# Test HUSKY_SKIP_HOOKS
- cat .git/hooks/post-checkout
- HUSKY_SKIP_HOOKS=1 time git checkout
- node scripts/ci-husky-skip-hooks
- node scripts/ci-husky-skip-hooks-check

# Test post-checkout hook
- time git checkout
- node scripts/ci-post-checkout-check

# Should not fail due to missing script
- node scripts/ci-break-path.js
- cat .git/hooks/post-checkout
- time git checkout

# Test uninstall
- npm run devuninstall
17 changes: 13 additions & 4 deletions appveyor.yml
@@ -1,6 +1,6 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "10"
nodejs_version: "12"

# Install scripts. (runs after repo cloning)
install:
Expand All @@ -18,17 +18,26 @@ test_script:
# Output useful info for debugging.
- node --version
- npm --version

# Run tests
- npm test
# Run post-checkout hook test

# Install hooks locally
- npm run devinstall
- cat .git/hooks/post-checkout

# Test HUSKY_SKIP_HOOKS
- HUSKY_SKIP_HOOKS=1 git checkout
- node scripts/ci-husky-skip-hooks-check

# Test post-checkout hook
- git checkout
- node scripts/ci-post-checkout-check

# Should not fail due to missing script
- node scripts/ci-break-path.js
- cat .git/hooks/post-checkout
- git checkout
- git checkout

# Test uninstall
- npm run devuninstall

Expand Down
Expand Up @@ -5,14 +5,6 @@ const path = require('path')
const filename = path.join(__dirname, '../ci-post-checkout')

if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename, 'utf-8')

if (data.split(' ').length !== 3) {
console.log('Not all params were set in HUSKY_GIT_PARAMS')
console.log('Got', data)
process.exit(1)
}

fs.unlinkSync(filename)
console.log(
'.git/hooks/post-checkout script has run, hooks were not skipped.'
Expand Down

0 comments on commit 71316ff

Please sign in to comment.