Stop multiline GitHub action on first fail - github-actions

We have a GitHub action for building our app
We're using the multiline syntax.
run: |
npm install
npm run test
npm run e2e
npm run deploy
If one on the commands fail, the action continue to the next command and will deploy the app.
Is there a way to abort the action on first fail?

You should try the "and" operator (&&):
run: |
npm install &&
npm run test &&
npm run e2e &&
npm run deploy

Related

Snyk test returns Failed to test pip project error

I'm running security scan with Snyk CLI for python project. Unfortunately snyk test command returns Failed to test pip project error. What am I missing, snyk test works just fine while scanning npm project ?
$ snyk test --file=requirements.txt
Failed to test pip project
I found the cause basically you need to do two things:
Make sure that packages that your project uses are installed.
Make sure that you are using correct python.
Solution
$ pip3 install -r requirements.txt
$ snyk test --file=requirements.txt --command=python3
Info
You can bypass missing python packages by passing the --allow-missing pip parameter through snyk by using the additional -- argument.
$ snyk test --file=requirements.txt --command=python3 -- --allow-missing
Docs
-- [COMPILER_OPTIONS]
Pass extra arguments directly to Gradle or Maven. E.g. snyk test
-- --build-cache
Python options
--command=COMMAND
Indicate which specific Python commands to use based on Python
version. The default is python which executes your systems de-
fault python version. Run 'python -V' to find out what version
is it. If you are using multiple Python versions, use this pa-
rameter to specify the correct Python command for execution.
Default: python Example: --command=python3
snyk monitor command will also return undefined if it is not ran with
pip3 install -r requirements.txt
snyk test --file=requirements.txt --command=python3
snyk monitor --file=requirements.txt --command=python3
If you are using Snyk and VScode, and you open a repo that has a Python VirtualEnv, you can get this error in your VScode terminal window.
[Error] Open Source Security test failed for "/home/{user}/path/to/repo". Failed to test pip project
Fix for VScode:
Close that VScode window.
From a terminal, navigate to the top folder of that repo.
Run the command to activate the virtual env
Example: . .venv/bin/activate
Open VScode for that folder
Example: run code .
The Snyk Open Source Security test should run without that error now.
If you are using virtual environments, then make sure you have activated the venv with
. venv/Scripts/activate
Then try running Snyk Test again.
Snyk monitor and other cli commands should work from that! :)

Starting existing strapi project locally

How can I start existing strapi project locally?
I want to be able to run strapi dashboard locally.
I tried with npm install, npm run develop but I'm getting - npm ERR! missing script: develop.
Any help would be nice!
Tnx
Ok. So incase somebody else is still wondering how to solve this.
$ cd to your project
$ run the npm install or yarn to install the node_modules, and run the npm run develop or yarn develop.

can an npm script be run from the UI

Don't know if this is possible, but I'd like to add a button to an angular 6 page that runs the e2e scripts (i.e. "npm run e2e"). The idea is to have an easy way for the PO's to run the e2e tests. The e2e tests are written in testCafe. Is this possible?
I found these but it's not quite what I'm looking for
how to run protractor test from UI or web interface - just select scenario from github and run
How to run a protractor test from a UI against an angular app
A browser cannot execute any npm script.
The simplest solution would be to install a batch file on the PO's computer that will do in sequence:
git clone < e2e-repo >
cd < e2e-repo >
npm install
npm run e2e

What is the (ERR! code ENOLOCAL npm ERR!) Could not install because of an error?

I am going to update npm latest version, but it's showing this error message:
G:\>npm i -g npm ERR! code ENOLOCAL npm ERR!
Could not install from "" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hemanth\AppData\Roaming\npm-cache\_logs\2018-01-08T03_34_29_774Z-debug.log
G:\>
This is an issue in node which is caused by white space in your windows username (possibly between the first-name and last-name in windows).
run the following command after replacing firstname with your windows user firstname in command prompt with administrator access
npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
This worked for me:
npm cache verify
Then I re-ran:
npm install -g create-react-app
And it installed like as expected: Issue resolved
I got same issue because I was using an updated "package-lock.json" file from another system, and there was no "node_modules" folder on system where I got the problem.
You can try to following:
Move "package-lock.json" to some other folder, outside current directory.
npm install
If you are facing with this issue, first you should update npm using the below code:
npm -g install npm
then try to create the React file. It is working 100% for me.
Run CMD in administrator mode and fire below commands in order
Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\AppData\Roaming\npm
npm install -g create-react-app
Go to the link for more npm - EPERM: operation not permitted on Windows
Thanks.
npm cache verify
npm install -g create-react-app
I got error npm ERR! code ENOLOCAL while running npx create-react-app my-app
uninstall and install is worked for me…
npm uninstall -g create-react-app
npm install -g create-react-app
this will upgrade your npx, then run
npx create-react-app my-app
this works fine
This worked for me:
npm install -g degit
is like an upgrade
Please verify, whether your npm has installed create-react-app in
**%AppData%Roaming\npm\node_modules**
if not then install it by using the command
npm install -g create-react-app
I got the same problem while trying to use sevelte with
the command
npx degit sveltejs/template youproject
The following was useful:
install -g degit
In the latest Windows, the firewall will block the node.exe to create package.json.
So turn off the firewall settings and try once. It worked for me.
Run npm ci.
Its works for me.

can I run the hello.js example for spookyjs on nitrous.io?

Here are the exact steps I took to try to run the hello.js example for spooky js on nitrous.
1. I installed phantomjs, nodejs(already installed), and casperjs.
$ npm install -g casperjs
Casper warns me that While CasperJS is installable via npm, it’s not a NodeJS package, neither it’s capable to require native NodeJS modules.
Because of this I wanted to use spookyjs which is a nodejs package.
Then, I installed phantom js: $ npm install phantomjs
Finally, I installed spookyjs: $ npm install spooky
2. I tried running the hello.js example using
$ node node_modules/spooky/examples/hello.js
3. I end up getting this error:
{ [Error: Child terminated with non-zero exit code 1] details: { code: 1, signal: null }}
Am I doing something wrong or can casperjs not be installed?
this is where I found spookyjs
Have you installed the phantomjs and casperjs runtime? The npm packages for phantomjs and casperjs call out to these runtimes. The error you see is when it can not find the casperjs runtime.
I'm not very familiar with nitrous.io and how much freedom you have to install other runtimes. Here's what I used for installing them on Linux: https://www.dvdheiden.nl/2013/07/30/installing-phantomjs-and-casperjs-on-linux/