Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched from CircleCI to Github Actions #68

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 47 additions & 47 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:latest
build:
docker:
- image: circleci/node:latest

working_directory: ~/repo
working_directory: ~/repo

steps:
- checkout
- restore_cache:
keys:
- dependency-cache-{{ checksum "yarn.lock" }}
- dependency-cache-
- run: yarn
- save_cache:
paths:
- node_modules
key: dependency-cache-{{ checksum "yarn.lock" }}
- run: yarn run verify
- persist_to_workspace:
root: "."
paths:
- src
steps:
- checkout
- restore_cache:
keys:
- dependency-cache-{{ checksum "yarn.lock" }}
- dependency-cache-
- run: yarn
- save_cache:
paths:
- node_modules
key: dependency-cache-{{ checksum "yarn.lock" }}
- run: yarn run verify
- persist_to_workspace:
root: "."
paths:
- src

publish:
docker:
- image: circleci/node:latest
publish:
docker:
- image: circleci/node:latest

working_directory: ~/repo
working_directory: ~/repo

steps:
- checkout
- attach_workspace:
at: "."
- run:
name: Add NPM auth token file
command: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
- run:
name: npm publish if new version
command: |
currentVersion=`npm show console-fail-test version`
nextVersion=`node -e "console.log(require('./package.json').version)"`
[ "$currentVersion" != "$nextVersion" ] && npm publish || true;
steps:
- checkout
- attach_workspace:
at: "."
- run:
name: Add NPM auth token file
command: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
- run:
name: npm publish if new version
command: |
currentVersion=`npm show console-fail-test version`
nextVersion=`node -e "console.log(require('./package.json').version)"`
[ "$currentVersion" != "$nextVersion" ] && npm publish || true;

workflows:
version: 2
build_and_end_to_end:
jobs:
version: 2
build_and_end_to_end:
jobs:
- build
- publish:
context: org-global
requires:
- build
- publish:
context: org-global
requires:
- build
filters:
branches:
only: main
filters:
branches:
only: main
34 changes: 17 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module.exports = {
env: {
browser: true,
es6: true,
},
extends: ["plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
env: {
browser: true,
es6: true,
},
extends: ["plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
};
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish to NPM

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: Codecademy/run-on-yarn@v1
with:
command: compile
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}

on:
push:
branches:
- main
16 changes: 16 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Push CI

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: Codecademy/run-on-yarn@v1
with:
command: ${{ matrix.command }}

strategy:
fail-fast: false
matrix:
command: ["compile", "format:verify", "lint"]

on: push
40 changes: 3 additions & 37 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
{
"arrowParens": "always",
"parser": "typescript",
"printWidth": 140,
"tabWidth": 4,
"trailingComma": "all",
"overrides": [
{
"files": ".*.json",
"options": {
"parser": "json"
}
},
{
"files": "*.json",
"options": {
"parser": "json"
}
},
{
"files": ".vscode/*.json",
"options": {
"parser": "json"
}
},
{
"files": "*.md",
"options": {
"parser": "markdown"
}
},
{
"files": "*.yml",
"options": {
"parser": "yaml"
}
}
]
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "all"
}
14 changes: 7 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"files.exclude": {
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.d.ts": {
"when": "$(basename).ts"
}
"files.exclude": {
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.d.ts": {
"when": "$(basename).ts"
}
}
}
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ In general, you can use the Node API to request specific test frameworks and spy

```js
require("console-fail-test").cft({
testFramework: "jest",
spyLibrary: "jasmine",
testFramework: "jest",
spyLibrary: "jasmine",
});
```

Expand All @@ -30,7 +30,7 @@ For others, use the Node API with their API request:

```js
require("console-fail-test").cft({
testFramework: require("ava"),
testFramework: require("ava"),
});
```

Expand Down Expand Up @@ -180,7 +180,7 @@ You can request a specific test library using the Node API with its API request:

```js
require("console-fail-test").cft({
spyLibrary: "sinon",
spyLibrary: "sinon",
});
```

Expand Down Expand Up @@ -261,25 +261,25 @@ By default, `console-fail-test` will error on _any_ called `console` method. If

```js
require("console-fail-test").cft({
console: {
warn: true, // won't error on any instance of console.warn
},
console: {
warn: true, // won't error on any instance of console.warn
},
});
```

## Why?

Logging to the console during tests can be a sign of

- 🚫 warnings from third-party libraries such as React for improper usage
- 🤕 temporary code that shouldn't be checked into your project
- 📢 unnecessary spam in your tests window
- 🚫 warnings from third-party libraries such as React for improper usage
- 🤕 temporary code that shouldn't be checked into your project
- 📢 unnecessary spam in your tests window

This little library throws an error after each test if a console method was called during it.
It's got some nifty features:

- 📊 Summary of which methods are called with calling arguments
- 🛫 Failures are thrown _after_ tests finish, so your tests will fail normally if they should
- 📊 Summary of which methods are called with calling arguments
- 🛫 Failures are thrown _after_ tests finish, so your tests will fail normally if they should

Look how fancy the terminal output is with Jest!

Expand All @@ -289,8 +289,8 @@ Look how fancy the terminal output is with Jest!

Requires:

- [Node.js](https://nodejs.org) >10 (LTS)
- [Yarn](https://yarnpkg.com/en)
- [Node.js](https://nodejs.org) >10 (LTS)
- [Yarn](https://yarnpkg.com/en)

After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo):

Expand Down
2 changes: 1 addition & 1 deletion docs/Ava.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Call the Node API in each test file that should be checked for console calls:
// some.test.js

require("console-fail-test").cft({
testFramework: require("ava"),
testFramework: require("ava"),
});
```
8 changes: 4 additions & 4 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ If you use a test framework console-fail-test doesn't yet support:

1. Find or file an issue tagged with [test framework support](https://github.com/RyzacInc/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+framework+support%22) and wait until it's marked as [accepting prs](https://github.com/RyzacInc/console-fail-test/labels/accepting%20prs)
2. Add a new file under [`src/environments`](../src/environments) that exports a function matching `TestEnvironmentGetter`:
- If the environment isn't provided and doesn't seem to exist, return `undefined`
- If the environment is provided or does seem to exist, return an object with hooks to be called by [`cft.ts`](../src/cft.ts)
- If the environment isn't provided and doesn't seem to exist, return `undefined`
- If the environment is provided or does seem to exist, return an object with hooks to be called by [`cft.ts`](../src/cft.ts)
3. Add that getter to `testEnvironmentsByName` and `detectableTestEnvironmentGetters` in [`src/environments/selectTestEnvironment.ts`](../src/environments/selectTestEnvironment.ts)

See [`src/environments/jest.ts`](../src/environments/jest.ts) as an example.
Expand All @@ -50,8 +50,8 @@ If you use a spy library console-fail-test doesn't yet support:

1. Find or file an issue tagged with [spy library support](https://github.com/RyzacInc/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22spy+library+support%22) and wait until it's marked as [accepting prs](https://github.com/RyzacInc/console-fail-test/labels/accepting%20prs)
2. Add a new file under [`src/spies`](../src/spies) that exports a function matching matching `SpyFactoryGetter`:
- If the spy library isn't provided and doesn't seem to exist, return `undefined`
- If the spy library is provided or does seem to exist, return a method that, given a container object and method name, spies on that method on the container
- If the spy library isn't provided and doesn't seem to exist, return `undefined`
- If the spy library is provided or does seem to exist, return a method that, given a container object and method name, spies on that method on the container
3. Add that getter to `spyFactoriesByName` and `detectableSpyFactoryGetters` in [src/spies/selectSpyFactory.ts](../src/spies/selectSpyFactory.ts).

The returned object containing `getCalls` and `restore` returned by `spyOn` will be used by [`cft.ts`](../src/cft.ts) to check whether the method was called.
Expand Down
2 changes: 1 addition & 1 deletion docs/Jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ If you'd like to use Jasmine's spies instead of Jest's, use the Node API with th

```js
require("console-fail-test").cft({
spyLibrary: "jasmine",
spyLibrary: "jasmine",
});
```
2 changes: 1 addition & 1 deletion docs/Lab.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Call the Node API in each test file that should be checked for console calls wit
const { it } = (exports.lab = require("lab").script());

require("console-fail-test").cft({
testFramework: exports.lab,
testFramework: exports.lab,
});
```
Loading