grunt.event.on 'watch' unable to run task - coffeescript

I have a watch for *.css files and on the event watch I would like call the cssmin task using code.
Here is the watch
'stylesheet-css':
files: ['public/stylesheets/*.css']
and on the code for event watch
grunt.event.on 'watch', (action,filepath)->
return if filepath.has '.min'
grunt.task.run 'cssmin:stylesheet-css' ## this doesn't seem to do anything.
Thanks

Related

Is there a way to pipe the smoke test output outside the agent?

I have a release pipeline with a QA/Smoke Test stage, that generates XML files containing test results.
If I run this manually on my machine, obviously I have access to the XML files and I can see the details but on the agent I cannot since we don't have access to those Microsoft hosted agents to view the files.
Is there a way to pipe the files "out" in the task for viewing? maybe there's a third marketplace task that can achieve that?
Here's the deployment result:
2021-06-06T23:34:19.1260519Z Results File: D:\a\r1\a\qa-automation\TestResults\CurrentReport\Logs\junit.xml
2021-06-06T23:34:19.2448029Z Results File: D:\a\r1\a\qa-automation\TestResults\.\CurrentReport\Logs\detailedLogs.xml
2021-06-06T23:34:19.2533810Z
2021-06-06T23:34:19.2596243Z Failed! - Failed: 22, Passed: 2, Skipped: 0, Total: 24, Duration: 52 m 11 s - EED.dll (netcoreapp3.1)
Here's the stage YAML:
steps:
- script: |
git clone https://.../qa-automation.git -b master
cd qa-automation
testrun.bat --cat "EDSmoke" --env dev
displayName: 'Clone qa-automation repo'
Is there a way to pipe the files "out" in the task for viewing? maybe there's a 3rd marketplace task that can achieve that?
You can try with following task:
Write-host "##vso[task.uploadfile]<PathOfTheFiles>\<filename>"
Like:
Write-host "##vso[task.uploadfile]$(System.DefaultWorkingDirectory)\qa-automation\TestResults\CurrentReport\Logs\junit.xml"
View and download attachments associated with releases
Would you like to upload additional logs or diagnostics or images when
running tasks in a release? This feature enables users to upload
additional files during deployments. To upload a new file, use the
following agent command in your script:
Write-host "##vso[task.uploadfile]"
The file is then available as part of the release logs. When you
download all the logs associated with the release, you will be able to
retrieve this file as well.
You can also add a powershell script task in your release definition to read the smoke test output and output it to the console. Then you will be see the content of the log files from "Logs" tab powershell script step. And you can also click "Download all logs as zip" to download the smoke test result files.

How can I hide skipped tasks output in Ansible

I have Ansible role, for example
---
- name: Deploy app1
include: deploy-app1.yml
when: 'deploy_project == "{{app1}}"'
- name: Deploy app2
include: deploy-app2.yml
when: 'deploy_project == "{{app2}}"'
But I deploy only one app in one role call. When I deploy several apps, I call role several times. But every time there is a lot of skipped tasks output (from tasks which do not pass condition), which I do not want to see. How can I avoid it?
I'm assuming you don't want to see the skipped tasks in the output while running Ansible.
Set this to false in the ansible.cfg file.
display_skipped_hosts = false
Note. It will still output the name of the task although it will not display "skipped" anymore.
UPDATE: by the way you need to make sure ansible.cfg is in the current working directory.
Taken from the ansible.cfg file.
ansible will read ANSIBLE_CONFIG,
ansible.cfg in the current working directory, .ansible.cfg in
the home directory or /etc/ansible/ansible.cfg, whichever it
finds first.
So ensure you are setting display_skipped_hosts = false in the right ansible.cfg file.
Let me know how you go
Since ansible 2.4, a callback plugin name full_skip was added to suppress the skipping of task names and skipping keyword in the ansible output. You can try the below ansible configuration:
[defaults]
stdout_callback = full_skip
Ansible allows you to control its output by using custom callbacks.
In this case you can simply use the skippy callback which will not output anything on a skipped task.
That said, skippy is now deprecated and will be removed in ansible v2.11.
If you don't mind losing colours you can elide the skipped tasks by piping the output through sed:
ansible-playbook whatever.yml | sed -nr '/^TASK/{h;n;/^skipping:/{n;b};H;x};p'
If you are using roles, you can use when to cancel the include in main.yml
# roles/myrole/tasks/main.yml
- include: somefile.yml
when: somevar is defined
# roles/myrole/tasks/somefile.yml
- name: this task will only run (and be seen in the output) if somevar is defined
debug:
msg: "Hello World"

Continuously complinig and running my coffeescript tests with karma

I'm using grunt, karma (singleRun: false). My tests are written in coffeescript. Each time my coffee file changes I want my tests to run. The problem is that I don't know how to make both happens.
So far I discovered the watch task, I tried to add my coffee thing there and add the watcher to my test task like that:
//karma.conf.js
singleRun: true,
and in Gruntfile:
//Gruntfile.js
watch: {
coffee: {
files: ['test/spec/{,*/}*.coffee'],
tasks: 'coffee'
}
}
grunt.registerTask('test', [
'clean:server',
'coffee',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma',
'watch:coffee'
]);
This way the karma watcher is watching javascript files, but my own coffee watcher is not triggered at all.
Right now I just removed watch:coffee from test task and I'm running grunt test and grunt watch:coffee in parallel terminals, which looks a bit pathetic. Is there a better way?
Much better approach is to use the karma-coffee-preprocessor. It's simple to set up and I can use singleRun: true.

Can grunt-regard be configured to run a subset of watch tasks instead of all tasks?

I am using gruntjs to build my js application. My grunt file is setup to run two separate builds where 80% of the code is the same for both and depending on the build we include additional files and exclude some files.
I have grunt setup to run the two different builds correctly except I cant tell grunt-regard to run multiple times.
regarde:
coffeeScripts:
files: ['app/scripts/kiosk/*.coffee', 'app/scripts/*.coffee'],
tasks: ['coffee:compileKiosk', 'livereload']
stylusScripts:
files: ['app/css/kiosk/*.styl', 'app/css/*.styl'],
tasks: ['stylus:compileKiosk', 'livereload']
coffeeScriptsWeb:
files: ['app/scripts/web/*.coffee', app/scripts/*.coffee],
tasks: ['coffee:compileWeb', 'livereload']
stylusScriptsWeb:
files: ['app/css/web/*.styl', 'app/css/*.styl],
tasks: ['stylus:compileWeb', 'livereload']
I want to be able to do something similar to the tasks below, but only the first regarde task runs and the second is ignored.
grunt.registerTask 'watchKiosk', ['livereload-start', 'regarde:coffeeScripts', 'regarde:stylusScripts']
grunt.registerTask 'watchWeb', ['livereload-start', 'regarde:coffeeScriptsWeb', 'regarde:stylusScriptsWeb']
My folder structure looks like
app (application root)
scripts (contains common script files)
kiosk (contains script files only for kiosk build)
web (contains script files only for web build)
css (contains common css files)
kiosk (contains css files only for kiosk build)
web (contains css files only for web build)
Ideally when working with the web build I do not want to recompile all the kiosk files and web files when a file changes.
Is there any way to setup grunt to have multiple regarde tasks defined and run the specific task I want for the build I am working on?
If I run these grunt tasks the watch works but will rebuild files that are not part of the specific build I am working with
grunt.registerTask 'watchKiosk', ['livereload-start', 'regarde']
grunt.registerTask 'watchWeb', ['livereload-start', 'regarde']
Thanks to asgoth for his link, from the linked answer I was able to figure out a way to do this. This might not be the best way but it works.
I added two different configurations for my regarde task (one for the kiosk build and one for the web build) to the grunt file:
regardeKiosk:
coffeeScripts:
files: ['app/scripts/kiosk/*.coffee', 'app/scripts/*.coffee'],
tasks: ['coffee:compileKiosk', 'livereload']
stylusScripts:
files: ['app/css/kiosk/*.styl', 'app/css/*.styl'],
tasks: ['stylus:compileKiosk', 'livereload']
and
regardeWeb:
coffeeScriptsWeb:
files: ['app/scripts/web/*.coffee', app/scripts/*.coffee],
tasks: ['coffee:compileWeb', 'livereload']
stylusScriptsWeb:
files: ['app/css/web/*.styl', 'app/css/*.styl],
tasks: ['stylus:compileWeb', 'livereload']
Then I created a multi task that picks the correct configuration and updates the regarde config before starting the regard task.
#startWatch config
startWatch:
web: 'Web'
kiosk: 'Kiosk'
grunt.registerMultiTask 'startWatch', 'refreshing the changed file(s)', () ->
#read regarde config and regarde template config. #data comes from startWatch config
regardeConfig = grunt.config('regarde')
correctConfig = grunt.config('regarde' + #data)
#replace regarde config with the correct config
grunt.config('regarde', correctConfig)
#run regarde task
grunt.task.run('regarde')
Then I am able to define my two grunt tasks and pick which regard task to run based on the build
grunt.registerTask 'watchKiosk', ['livereload-start', 'startWatch:kiosk']
grunt.registerTask 'watchWeb', ['livereload-start', 'startWatch:web']

Why isn't Pyinotify able to watch a dir?

I would like Pyinotify to watch a templates directory, which has subfolders, but I'm getting this error:
DIRECTORY /home/project/templates
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates WD=-1
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates/dir1 WD=-1
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates/dir2 WD=-1
Waiting for stuff to happen...
I've found answers such as using a unicode directory name or using other programs which use inotify, but each is too specific.
What generally causes this error?
Increase the maximum number or watches:
sudo sysctl -n -w fs.inotify.max_user_watches=16384
Reference: http://github.com/seb-m/pyinotify/wiki/Frequently-Asked-Questions
ASIDE
If you're looking for notification tools, also try http://github.com/peterbe/python-gorun.