A
A
Alex2019-08-06 17:19:47
Node.js
Alex, 2019-08-06 17:19:47

How to write a config for travis ci?

How to correctly write a config for the following behavior:
Any commit or PR triggers tests npm run tests
If something with the tag tag is pushed to the master branch Run tests, build, deploy to production with a command , and deploy to npm run deployGitHub Releases
run twice with one different environment variable. BROWSER
That is, as I see it:
I commit to any branch - two parallel tests run
BROWSER=chrome npm run tests
BROWSER=firefox npm run tests
Someone makes a PR to any branch - two parallel tests run
BROWSER=chrome npm run tests
BROWSER=firefox npm run tests
I commit to the master with a tag - runs two parallel tests
BROWSER=chrome npm run tests
BROWSER=firefox npm run tests
If both tests pass, two commands are launched to deploy
BROWSER=chrome npm run deploy
BROWSER=firefox npm run deploy
AND the third command is to create a release on GitHub
I am not familiar with this tool at all. Wrote this config

language: node_js

node_js: 
  - "10"

env: 
  - BROWSER=chrome
  - BROWSER=firefox


script: npm run build

deploy:
  skip_cleanup: true
  provider: script
  script: npm run deploy
  on:
    branch: master

But it is not clear:
How to add a preliminary stage of testing here?
How to make deploy run only if there is a tag?
How will the task react to PR in the master branch?
How to add another task to deploy to GitHub?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-08-07
@Kozack

Look at https://docs.travis-ci.com/user/build-stages/.
As far as I understand, you should have stages:
- test (with two browsers)
- build
- deploy (only if branch=master)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question