My CI file currently has two installation commands that run sequentially. However, as the former does not require the latter to be able to execute, I would like to run these commands at the same time. How do I run these commands in parallel without parallelizing my entire build pipeline?
install:
- docker pull <image>
- npm install
You can simply use bash syntax;
install: docker pull <image> & npm install
Related
I'm running some playwright tests in a pipeline but I'm having problems trying to fail the build when a test fails.
In my pipeline I call a make file that calls a shell script that installs playwright, does some setup, and then runs the command yarn playwright test the script I call always returns an exit code 0 but Playwright returns an exit code 1 if a test fails.
Is it possible for me to get the exit code of Playwright so I can then pass it back up and handle it in my pipeline?
Update:
The line in my makefile that calls the sh script is:
uiTests: node-install node-audit
$(DOCKER_RUN_NODE) bash /app/scripts/playwright.sh
My Playwright.sh script:
#!/usr/bin/env bash
apt-get update
apt-get install -y gnupg2 gnupg1 wget
docker pull mcr.microsoft.com/playwright/python:v1.27.0-focal
yarn install
yarn playwright install
yarn playwright install-deps
yarn run local & yarn run uiTests
rm -rf node_modules
This pulls the dependencies then starts the local instance of the site and runs the tests
yarn run uiTests runs this command "BASE_URL='http://localhost:3000' yarn playwright test"
When I run npm commands on my Windows 10 machine, new processes seem to spawn in new windows.
On my (Mac-using) colleagues machines, I see that these commands run in the same terminal window from which they were called. This is the behaviour I'd expect and is much more useful - it's really hard, for instance, to see my test results in the split second between them finishing and the terminal window being closed!
As an example, our packages.json has a script to run jest:
scripts": {
"test": "jest"
}
When I run npm run test, the following gets written to the current terminal:
$ npm run test
> #headuplabs/mobile#0.0.1 test C:\Users\TomWright\Documents\Repos\HeadUp.Mobile
> jest
But the actual execution of jest then gets started in a newly created window:
I'm using "git bash" as my default integrated terminal in VS Code, but I'm able to replicate this using cmd.exe and outside VS Code (i.e. by running git bash or cmd standalone).
I presume that my npm installation is improperly configured, but my Google search haven't yielded any answers.
Does anyone know what I'd need to do to make npm processes run in the same terminal window?
As mentioned in "how to set shell for npm run-scripts in windows", you might want configure the shell in npm itself:
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
That would avoid the default setting, which can trigger a new shell window.
In circle CI build I am trying to install nvm as follows:
- run:
name: Install nvm
command: curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
But I am getting this error:
How do fix this issue?
Disclaimer: Developer Advocate at CircleCI
You didn't specify which Docker image (or executor) you are using. Most likely you're using a Docker image that doesn't include Bash. You can do one of three things:
Install Bash first in that Docker image.
Choose a Docker image with Bash already installed.
Use sh for the command instead of Bash.
Option 3 is the easiest option as long as the install script isn't using Bash specific features. You can try it by replacing the end of the command like this:
curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | sh
I have set up CI for Angular2 projects in the past which use npm commands, however I recently started using Angular-CLI which uses 'ng' commands instead.
When I try to set up CI for my project in Visual Studio Online I can't find a way to execute 'ng' commands.
I have tried running NPM command (using npm task from the catalog) to install the CLI; npm install -g angular-cli, after that I run npm install. Now to run 'ng build' I have tried to run in using command line tool (since there doesn't appear to be a tool to allow me to run ng commands), however that fails saying that ng is not a recognised command.
Any suggestions on setting up CI for an Angular-CLI project using VSO?
Thanks
If you want your build definition to run on any build agent (the Hosted one and any on premise agent), you could relying on local installation of angular-cli with npm, without the -g flag:
>npm install angular-cli
By default npm will install 'ng' under .\node_modules\.bin\
Your build definition could use the 'npm install' task to install locally 'ng', then you can invoke it by 'Command Line' task because you know the path to it (e.g. $(Build.SourcesDirectory)\node_modules\.bin).
Example of a build definition creating a new project and building it using 'ng':
install locally the 'ng' cli tool:
create the project 'helloworldproject':
build the project 'helloworldproject':
==Update (programmatically retrieve the actual binary path with 'npm bin')==
To remove the assumption where the binaries are placed and have a more resilient build definition, you could retrieve programmatically the actual binary path used by npm using the command:
>npm bin
The following example (this time a short PowerShell script) shows how to create the 'helloworldproject' and build it thereafter:
Remember:
to disable the option 'Fail on Standard Error' on the PowerShell task, as the ng tools likes to write stuff there even when it succeeds.
of course you still need the 'npm install' task as shown above before using the 'ng' tool.
I am currently going through the same thing so feel you pain.
You will probably have to create your own build server either as a VM on azure or on premise. The reason for this is that angular-cli isn't one of the capabilities of the hosted build server at present.
When you do create your own, you are still going to run into some hurdles. When you install angular-cli globally it still puts it under an AppData folder for the user that you install it with. If you have setup your agent to run as a different user for example NetworkService then for that service account "ng" wont be in the path. It will likely also not have permissions to run it because angular-cli has been installed under a user's folder for which it won't have permission.
Ok, so you run the agent with the same user or you resolve the permission and path issue you may still run into problems. If you use a powershell script task as one of your build tasks to perform "ng build" you will then run into the issue that I have highlighted here:
https://github.com/angular/angular-cli/issues/3979
So looks like we may have to resort to a command line build task instead.
Hope this helps. The last two days I have spent on this may as well help someone else.
Regarding Angular2-CLI command line, it uses ng2 instead of ng. (Angular-CLI uses ng), so your command is incorrect.
Refer to these steps to verify ng2 command (works on Hosted agent):
Add NPM build step (npm command: install; arguments: angular2-cli -g)
Add Command Line step (Tool: ng2; Arguments: --version)
If you are using on premise build agent with network service, using these steps instead:
NPM build step (npm command: install; Arguments: angular2-cli -g)
Command Line step (Tool: C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\ng2.cmd; Argumetns: --version)
For on premise build agent with user account, you can log on that machine and install Angular2-CLI command line (do not need to install it during the build).
I have Docker Toolbox installed under Windows 7. The Docker daemon is running inside a VM (the default behavior of Docker Toolbox).
I am trying to get Phundament running using the default tutorial.
It all works fine until I reach this command:
docker-compose run php composer install
It results in:
I've successfully attached to the running container using docker exec -it <container ID> bash but when I do a ls /app command on any of the two containers I get no files in that directory. In effect, the attempt to run composer install there fails.
I tried attaching to both containers and the result is identical.
I also noticed that behavior just recently, it's sadly a limitation of docker-compose on Windows.
For the command you mentioned you can actually run
docker-compose run -d php composer install
As general workarounds...
use docker exec -it app_php_1 bash
see also https://getcarina.com/docs/troubleshooting/troubleshooting-cannot-enable-tty-mode-on-windows/
if you don't really need an interactive shell, you could just run a command or script, like docker-compose run -d php setup.sh
Note: I need to double-check the above suggestions on a real Windows testing system.
PS: I am the author if Phundament. I've also just created an issue for this.
Please try:
winpty docker-compose run php composer install
it works for example:
winpty docker run --rm -it debian bash