Skip to content

Commit

Permalink
Fix based on notes
Browse files Browse the repository at this point in the history
Signed-off-by: campionfellin <campionfellin@gmail.com>
  • Loading branch information
campionfellin committed Jul 1, 2018
1 parent 8308842 commit fa80380
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
-in ./tests/.clasprc.json.enc -out .clasprc.json -d || true
- npm install -g npm@latest
install:
# npm-ci (https://docs.npmjs.com/cli/ci) is used for the install step instead +- npm ci
# npm-ci (https://docs.npmjs.com/cli/ci) is used for the install step instead
# of npm-install because it ensures that the package-lock.json is up to date
# with the package.json in order for the travis tests to pass.
- npm ci
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,14 @@ clasp <command>

(If you see build errors, run `sudo npm run build-fresh`)

#### Run Tests (experimental)
#### Run Tests

See `/tests/README.md`
```sh
sudo npm run build;
npm run test
```

See `/tests/README.md` for more information.

#### Lint

Expand Down
41 changes: 18 additions & 23 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
# Tests

These tests should ideally be run for every Pull Request, though due to the need to run `clasp login` before some commands, some tests are not run.


# Configuration using Travis
Many of `clasp`'s CLI commands have unit tests that run the `clasp` command and asserts the std output and std error code is as expected.

This is a bit more difficult, and why we include the `.clasprc.json.enc` file. The `.clasprc.json` file is used to authenticate many of the `clasp` commands, and is what is generated after using `clasp login`.
These tests should ideally be run for every Pull Request, though due to the need to run `clasp login` before some commands, some tests are not run.

Here it is encrypted as `.clasprc.json.enc` and decrypted by Travis with the line:
To run tests yourself, follow the __Local Configuration__ instructions.

```openssl aes-256-cbc -K $encrypted_0f9bbf7a60f4_key -iv $encrypted_0f9bbf7a60f4_iv -in .clasprc.json.enc -out .clasprc.json -d || true```
## Local Configuration

The way that Travis works is that encrypted files cannot be decrypted by a Pull Request from a fork (see: https://docs.travis-ci.com/user/encrypting-files/). There are ways around this, that may or may not be what we will do in the future, see (https://blog.algolia.com/travis-encrypted-variables-external-contributions/) for ideas.
1. Make sure you are logged in (`clasp login`).
1. Rebuild: `sudo npm run build`
1. Run `npm run test`

This is why the end of that command ends with ` || true` (so Travis doesn't fail on any PR).
## Configuration using Travis

We need a way to keep track of this, so we don't try to run the tests and fail if we didn't decrypt the credentials. This is where this line comes in:
Travis (https://travis-ci.org/) is used to automatically build and run tests on `clasp`. Every version of `clasp` should pass the Travis build step before release.

`- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then npm run test; fi'`
Since Travis cannot `clasp login`, a `.clasprc.json` file is included that was created locally using `clasp login`.

`$TRAVIS_PULL_REQUEST` is a default variable set by Travis to either the PR number or false. Since we only decrypt the variable on non-PRs, then we only use `npm run test` on those (such as when we merge to master or make a commit directly to master, etc).
It is encrypted as `.clasprc.json.enc` and then decrypted by Travis:

### TODO
```openssl aes-256-cbc -K $encrypted_0f9bbf7a60f4_key -iv $encrypted_0f9bbf7a60f4_iv -in .clasprc.json.enc -out .clasprc.json -d || true```

Change test files to use a flag that runs certain tests (what we're currently running) on PRs, and runs all tests on master.
Travis will not decrypt files on a Pull Request from a fork (see: https://docs.travis-ci.com/user/encrypting-files/).

# Configuration Locally
There are complicated ways around this, see (https://blog.algolia.com/travis-encrypted-variables-external-contributions/) for ideas.

1. Make sure you are logged in (`clasp login`).
1. In `/tests/test.ts` change `describe.skip(...)` to `describe(...)` for relevant tests.
* **Note: (All tests are relevant).**
1. Rebuild: `npm run build`
1. Run `npm run test`
The command ends with ` || true` so Travis doesn't immediately fail on any PR.

# Test these commands and configs.
## Test these commands and configs.

## Commands:
### Commands:
* [ ] clasp;
* [ ] clasp login';
* [ ] clasp login --no-localhost;
Expand All @@ -58,6 +53,6 @@ Change test files to use a flag that runs certain tests (what we're currently ru
* [x] getScriptURL
* [x] getFileType
* [x] getAPIFileType
## Configs
### Configs
* [ ] .js and .gs files
* [ ] Ignored files

0 comments on commit fa80380

Please sign in to comment.