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

Run full suite of tests, every time (most of the time) #246

Merged
merged 11 commits into from Jul 1, 2018
Merged

Run full suite of tests, every time (most of the time) #246

merged 11 commits into from Jul 1, 2018

Conversation

campionfellin
Copy link
Collaborator

@campionfellin campionfellin commented Jun 28, 2018

Fixes longstanding testing issues

See https://travis-ci.org/campionfellin/clasp/jobs/397869625 for example

  • npm run test succeeds.
  • npm run lint succeeds.
  • Appropriate changes to README are included in PR.

Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
@campionfellin
Copy link
Collaborator Author

With this, we probably would have noticed issues with Node 6/7 earlier.

Signed-off-by: campionfellin <campionfellin@gmail.com>
@campionfellin
Copy link
Collaborator Author

Looks like manually rebuilding doesn't run them either.

Related blog post: https://blog.algolia.com/travis-encrypted-variables-external-contributions/

Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

  • Can we add a tests/README.md:
    • Explaining/providing
      • How the tests work
      • What this .clasprc.json.en is
      • How to configure Travis (if necessary)
      • Any links that are useful.
    • Moving the bottom (line 327) comment to the README.

We can move testing instructions from the main README to the tests/ README too.

This will help others

@@ -0,0 +1,2 @@
�t�@�NM����.|9%� �M�mc)eJ�&���,nv�9��N����7=b����C,P8�O��A��T�,SЇ ��f�4wk�gn�<��2�p9p� �ץ�p�Y�d|K�Z(�xn�T(��"��g���={)3�(�y ��O���S��
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this file to tests/ and update the relative path in the .travis.yaml?

  • This file is only used in our tests
  • Let's try to reduce the number of top-level files/folders.

.travis.yml Outdated
cache:
directories:
- "$HOME/.npm"
before_install:
- npm install -g npm@latest
- openssl aes-256-cbc -K $encrypted_0f9bbf7a60f4_key -iv $encrypted_0f9bbf7a60f4_iv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to describe exactly what this command does in the README.
It looks very complicated.

.travis.yml Outdated
- npm run lint
- npm run test
- npm run lint
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then npm run test; fi'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not change this?
This only runs Travis tests for PRs and not commits?

@grant
Copy link
Contributor

grant commented Jun 30, 2018

Assuming this is WIP given the do not merge label.

Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
@coveralls
Copy link

coveralls commented Jul 1, 2018

Coverage Status

Coverage increased (+12.6%) to 37.257% when pulling fa80380 on campionfellin:master into 1b04371 on google:master.

Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
@campionfellin
Copy link
Collaborator Author

Ok, I think this is now working as we want:

First, see https://travis-ci.org/google/clasp/builds/398823862

If you dive into each job, it skips the tests that need authentication and ends with 11 passing and 17 pending.

Now, see https://travis-ci.org/campionfellin/clasp/builds/398823851

If you look closely, it has 27 passing, 1 pending. It also fails builds on Node 6/7 as we expect.

The logic for this is now:

const isPR = process.env.TRAVIS_PULL_REQUEST;
.
.
.
  before(function() {
    if (isPR !== 'false') {
      this.skip();
    }
  });

For some reason, $TRAVIS_PULL_REQUEST is not set to false, but rather "false" when it's not a PR.

Note, this may cause some problems with Coveralls, as the PRs will have much lower coverage, and then it will jump back up on merging with master.

README.md Outdated
sudo npm run build;
npm run test
```
See `/tests/README.md`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a tl;dr for how to run tests.

I'd keep:

sudo npm run build;	
npm run test	

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this in the tests README.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's under the Configuration Locally header.

README.md Outdated
@@ -345,12 +345,7 @@ clasp <command>

#### Run Tests (experimental)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we graduate the tests from experimental?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,63 @@
# Tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a sentence here to describe what the testing situation is for clasp. Something like:

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated
# 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 2 \n's

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated

# Configuration using Travis

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an intro sentence as to what Travis is and how clasp uses it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated

Change test files to use a flag that runs certain tests (what we're currently running) on PRs, and runs all tests on master.

# Configuration Locally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## Local Configuration

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated
Change test files to use a flag that runs certain tests (what we're currently running) on PRs, and runs all tests on master.

# Configuration Locally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a short sentence to what this section describes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated
# Configuration Locally

1. Make sure you are logged in (`clasp login`).
1. In `/tests/test.ts` change `describe.skip(...)` to `describe(...)` for relevant tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see skipped test suites anymore. Can you remove this line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tests/README.md Outdated

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).**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -28,7 +29,12 @@ describe('Test help for each function', () => {
});
});

describe.skip('Test clasp list function', () => {
describe('Test clasp list function', () => {
before(function() {
Copy link
Contributor

@grant grant Jul 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract this to a function?

function skipIfPR() {
  if (!Boolean(isPR)) return this.skip();
}
before(skipIfPR);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure this will work, Typescript is not a fan:

[ts] 'this' implicitly has type 'any' because it does not have a type annotation.

I'm not sure the best way to pass this through that makes it work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, isPR is never a boolean, it's either an int like this PR is 246 or it is "false" (string)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can follow up in a different change.

@grant
Copy link
Contributor

grant commented Jul 1, 2018

Looking good.
I'd just be sure to make the instructions very short and precise, more like an instruction manual and less like a conversation.

Signed-off-by: campionfellin <campionfellin@gmail.com>
@campionfellin
Copy link
Collaborator Author

Ok, I believe I addressed most of the comments and have made the instructions more concise.

@grant grant merged commit b7d9664 into google:master Jul 1, 2018
@campionfellin
Copy link
Collaborator Author

campionfellin commented Jul 1, 2018

@grant This build looks like it's failing, likely because the keys to decrypt are on my Travis account, rather than yours/clasp's. Can you follow these instructions:

https://docs.travis-ci.com/user/encrypting-files/#Automated-Encryption

Essentially:

clasp login
Then cp ~/.clasprc.json ./tests/.clasprc.json
travis encrypt-file ./tests/.clasprc.json --add

@grant grant mentioned this pull request Jul 1, 2018
@grant
Copy link
Contributor

grant commented Jul 2, 2018

I installed travis (after much troubleshooting) and re-encrypted the files.
@campionfellin Can you add those "essentially" steps to the tests/ README?

@campionfellin
Copy link
Collaborator Author

Sorry for all the troubles 😔, I'll go ahead and add those steps

@grant
Copy link
Contributor

grant commented Jul 2, 2018

No worries, https://stackoverflow.com/a/34989655 was the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants