Appveyor build failure - build

I am creating a build with Appveyor on Github use devtool https://github.com/atom/atom-keymap. Although Travis builds success, Appveyor builds still appear error!

I do not know real root cause, but I think I can help with a way to troubleshoot this. Basically you can connect to AppVeyor VM via RDP and debug it. Here are the steps:
Insert - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) before - npm run ci in your appveyor.yml file.
In RDP run the following:
cd c:\projects\atom-keymap
npm run compile
npm run lint
This will bring you to the state to get a repro and debug (because npm run ci is npm run compile && npm run lint && npm run test).
To get a repro npm run test.
To debug the problem, do something like this:
devtool --console node_modules/mocha/bin/_mocha --colors spec/helpers/setup.js spec/* --break
(this will let you debug step-by-step)
or
devtool --console node_modules/mocha/bin/_mocha --colors spec/helpers/setup.js spec/* --watch
(this will let you see a lot of error details)
This is the same what npm run test does, but without switch to quit on error and with debug options.
I went this route myself till this point but my limited knowledge of this npm module did not let me to dig till the root cause.

Related

HardhatError: HH1: You are not inside a Hardhat project

Adding Hardhat version 2.12.2 to an existing project either manually to the package.json or by executing one of the commands:
npm i hardhat
npm i --save-dev hardhat
yarn add hardhat
yarn add --dev hardhat
Gave the following error:
HardhatError: HH1: You are not inside a Hardhat project.
The error was resolved by adding a file named hardhat.config.js to the project root directory.
This file can also be added by executing npx hardhat and then selecting Create an empty hardhat.config.js.
I think that the error is misleading and it should be something like this:
"HardhatError: HH1: Could not find the file hardhat.config.js. Are you not inside a Hardhat project?"
Or something like:
"HardhatError: HH1: You may not be inside a Hardhat project. Ensure running npx hardhat at this directory?"
(You can find more on the discussion at: https://github.com/NomicFoundation/hardhat/issues/1400. But it is limited to collaborators now.)

Conditional Maven build command on Travis CI using Regex

In my Travis CI script on Github, I have the following condition, where the default profile is run if commits are pushed to a remote branch. And test profile if it is a pull request.
script:
- 'if [ "$TRAVIS_EVENT_TYPE" == "push" ]; then
mvn clean install;
else
mvn clean install -P test;
fi'
Now the problem I am facing is that if condition also runs when there is a merge from feature to develop branch which I do not want. I want the if condition to run only when there is a push from local feature or bugfix branch to remote. To handle this I have added regular expression to match the branches like below.
script:
- 'if [ "$TRAVIS_EVENT_TYPE" == "push" && "$TRAVIS_BRANCH" =~ ^(feature|bugfix)]; then
mvn clean install;
else
mvn clean install -P test;
fi'
But it gives the following error:
The command "if [ "$TRAVIS_EVENT_TYPE" == "push" && "$TRAVIS_BRANCH" =~ ^(feature|bugfix)]; then mvn clean install; else mvn clean install -P test; fi" exited with 1.
Edit: I think matching the branch condition won't help in achieving what I am trying to do here. Since the merge will be from feature-* or bugfix-* to develop branch. So I think this additional branch check is redundant here.
So the build rules I am trying to implement are:
If it is a commit push from local branches to remote branches, then run the default profile with mvn clean install.
If it is a new pull request or pull request merge, then run the test profile with mvn clean install -P test
What will be the right checks to achieve this in Travis CI script?

'jss' is not recognized as an internal or external command

I am new in Sitecore JSS.
While running the following command using CMD:
npm install -g #sitecore-jss/sitecore-jss-cli
I got the following result:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4
(node_modules#sitecore-jss\sitecore-jss-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"})
#sitecore-jss/sitecore-jss-cli#9.0.6 updated 1 package in 21.068s
After that I wanted to check that JSS has been installed successfully, so I ran the following CMD command:
jss --help
but the result was:
'jss' is not recognized as an internal or external command, operable
program or batch file.
What am I missing?
Check your environment path variable.
Default the npm location on Windows is
C:\Users{user}\AppData\Roaming\npm
There you found a jss.cmd and the node_modules\#sitecore-jss folder.
To fix the "'jss' is not recognized as an internal or external command, operable program or batch file." error add the npm location to your path or shortly %AppData%\npm
To add somethings to the path go to control panel -> System and Security -> System -> Advanced System Settings then environment variables.
if you cant found the npm location try
npm config get prefix
It is an issues with NPM and this specific version of #sitecore-jss/sitecore-jss-cli#9.0.6.
It is recommanded to use yarn to fix for now. Until the next jss-cli release.
Make sure you remove (#sitecore-jss, jss and jss.cmd) from
C:\Users\{your_username}\AppData\Roaming\NPM\
Install Yarn globally : https://yarnpkg.com/lang/en/docs/install/#windows-stable
Re-install #sitecore-jss/jss-cli using Yarn
yarn global add #sitecore-jss/sitecore-jss-cli
Make jss is using it, using this command
where jss
Expected result:
C:\Users\{your_username}\AppData\Local\Yarn\bin\jss
C:\Users\{your_username}\AppData\Local\Yarn\bin\jss.cmd
if not, try to refresh you environment variables using
refreshenv
(or restart your Command Prompt)

Google Cloud Container Build trigger crashes during gradle build

I was trying to setup a build trigger for an kotlin app that is build using gradle. For that I put together the following Dockerfile:
FROM gradle:jdk8 as builder
WORKDIR /home/gradle/project
COPY . .
WORKDIR ./Kuroji-Eventrouter-Server
RUN gradle shadowJar
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=builder /home/gradle/project/Kuroji-Eventrouter-Server/build/libs/kuroji-eventrouter-server-*-all.jar kuroji-eventrouter-server.jar
ENTRYPOINT ["java", "-jar", "kuroji-eventrouter-server.jar"]
And that file works on my machine with docker build and it starts normally on google container registry however during the RUN gradle shadowJar task it crashes with some gradle error:
Step 5/9 : RUN gradle shadowJar
---> Running in ddd190fc2323
Starting a Gradle Daemon (subsequent builds will be faster)
[91m
[0m[91mFAILURE: [0m[91mBuild failed with an exception.[0m[91m
[0m[91m
[0m[91m* What went wrong:
[0m[91mCould not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
[0m[91m> [0m[91mCould not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
[0m[91m
[0m[91m* Try:
[0m[91mRun with [0m[91m--stacktrace[0m[91m option to get the stack trace. Run with --info[0m[91m or --debug[0m[91m option to get more log output. Run with [0m[91m--scan[0m[91m to get full insights.[0m[91m
[0m[91m
[0m[91m* Get more help at https://help.gradle.org
[0m[91m
[0m[91mBUILD FAILED in 3s
The command '/bin/sh -c gradle shadowJar' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
[0m
I tried building the Image on docker HUB and the same thing happend: https://hub.docker.com/r/usbpc/kuroji-eventrouter-server/builds/bnknnpqowwabdy82ydxiypc/
This is very confusing to me as I thought containers should be able to run anywhere and not depend on the enviroment. What can I do to make google build my container?
The problem was a file permission problem. Using the --stacktrace option I found that the gradle process didn't have permissions to create a folder inside the sources.
The solution I would like to do is use the --chown=gradle:gradle option on the COPY instruction, unfortunatly this it not supported in the google cloud yet.
So the solution is to add USER root before executing the gradle build.

Cannot view code coverage on angular-cli new project

I'm trying to figure out how to get code coverage working with #angular/cli but so far i'm not having much luck.
I started a new project using angular CLI. Basically all i did was ng new test-coverage and once everything was installed in my new project folder, I did a ng test --code-coverage. The tests were run successfully but nothing resembling code coverage was displayed in the browser.
Am I missing some dependencies or something else? Any help will be appreciated.
EDIT:
R. Richards and Rachid Oussanaa were right, the file does get generated and I can access it by opening the index.html.
Now i'm wondering, is there a way I could integrate that into a node command so that the file opens right after the tests are run?
here's what you can do:
install opn-cli which is a cli for the popular opn package which is a cross-platform tool used to open files in their default apps.
npm install -D opn-cli -D to install as dev dependency.
in package.json add a script under scripts as follows
"scripts": {
...
"test-coverage": "ng test --code-coverage --single-run && opn ./coverage/index.html"
}
now run npm run test-coverage
this will run the script we defined. here is an explanation of that script:
ng test --code-coverage --single-run will run tests, with coverage, only ONCE, hence --single-run
&& basically executes the second command if the first succeeds
opn ./coverage/index.html will open the file regardless of platform.