Add tests and CI for the typescript sample
Categories
(Data Platform and Tools Graveyard :: Glean.js, task, P1)
Tracking
(Not tracked)
People
(Reporter: Dexter, Assigned: amritdhaliwalz)
Details
(Keywords: good-first-bug, Whiteboard: [good first bug])
Attachments
(1 file)
We did this for the Javascript sample, but it would be good to do that for the typescript sample too.
Comment 1•4 years ago
|
||
To help Mozilla out with this bug, here's the steps:
- Comment here on the bug that you want to volunteer to help. I (or someone else) will assign it to you.
- Clone the Glean.js repository:
git clone https://github.com/mozilla/glean.js
- Build Glean.js. Inside the
glean/
folder, run:
npm install
npm test
# Make sure all tests passed.
- Start working on this bug. The suggested first step here is take a look at the tests on the Javascript sample. The Typescript test suite, should execute at least the same tests as that suite.
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 2•4 years ago
|
||
Hi Amrit!
Do you need guidance on this? Is there anything I can do to help?
Hi Alessio,
So I thought I was doing ok with trying to replicate the same tests from the javascript example
but, when I try this import "import * as sample from "../../src/generated/sample.js";" I get an error
saying "Cannot find module '../../src/generated/sample.js' or its corresponding type declarations.ts(2307)"
Any hemp would be appreciated.
Thanks,
Amrit
(In reply to Amrit from comment #3)
Hi Alessio,
So I thought I was doing ok with trying to replicate the same tests from the javascript example
but, when I try this import "import * as sample from "../../src/generated/sample.js";" I get an error
saying "Cannot find module '../../src/generated/sample.js' or its corresponding type declarations.ts(2307)"Any help would be appreciated.
Thanks,
Amrit
Reporter | ||
Comment 5•4 years ago
|
||
(In reply to Amrit from comment #3)
... when I try this import "import * as sample from "../../src/generated/sample.js";" I get an error
saying "Cannot find module '../../src/generated/sample.js' or its corresponding type declarations.ts(2307)"
Hey, no problem! Do you have a work in progress PR I can look at to give you better insights?
That code is generated. In order to generate it when running npm run build
we build the glean task.
Is a generated
directory being created? Does it have the files we're looking for?
So it looks like no directory called generated is being created and when I try to run nom run build
I am getting more errors.
Here is a link to a PR you can use to see have some better insight
https://github.com/AmrDhaliwal/glean.js
Reporter | ||
Comment 7•4 years ago
|
||
(In reply to Amrit from comment #6)
So it looks like no directory called generated is being created and when I try to run nom run build
I am getting more errors.
Would you kindly paste the errors here?
Here is a link to a PR you can use to see have some better insight
https://github.com/AmrDhaliwal/glean.js
Looks like you committed the code on the main
branch on your fork: would you kindly commit to a branch and open a pull request?
Reporter | ||
Updated•4 years ago
|
Here are the errors I am receiving in the terminal:
npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
Also, sorry for some reason when you said PR I thought
you meant Public repo, but here's a link to the pull request:
https://github.com/mozilla/glean.js/pull/282
Reporter | ||
Comment 9•4 years ago
|
||
(In reply to Amrit from comment #8)
Here are the errors I am receiving in the terminal:
npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
Ah, I see! Hang on, I think the README is wrong. Are you running the build command from within web-extensions/typescript
?
Assignee | ||
Comment 10•4 years ago
|
||
No, I was running them from inside the glean folder.
Reporter | ||
Comment 11•4 years ago
|
||
(In reply to Amrit from comment #10)
No, I was running them from inside the glean folder.
When you clone the repo, you will see a glean
directory under the root of directory you just cloned. That's the glean
directory that it's talking about. Are you into that directory? Chances are you might be running it from the root instead.
Assignee | ||
Comment 12•4 years ago
|
||
I thought that at first too but, I am defiantly on the glean directory and not the root
one.
Reporter | ||
Comment 13•4 years ago
|
||
(In reply to Amrit from comment #12)
I thought that at first too but, I am defiantly on the glean directory and not the root
one.
Cool. At this point I believe I need the full shell log to better help you diagnose this :-) Would you kindly attach it here? Thanks!
Assignee | ||
Comment 14•4 years ago
|
||
Of course, here is the log thanks for your help.
0 verbose cli [
0 verbose cli 'C:\Program Files\nodejs\node.exe',
0 verbose cli 'C:\Users\Amrit\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
0 verbose cli 'run',
0 verbose cli 'build'
0 verbose cli ]
1 info using npm@7.11.2
2 info using node@v14.16.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\Amrit\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:C:\Users\Amrit\Desktop\Open_Source\glean.js\glean.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\Amrit.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\Amrit\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 5ms
19 timing npm:load:configload Completed in 5ms
20 timing npm:load:setTitle Completed in 1ms
21 timing npm:load:setupLog Completed in 0ms
22 timing npm:load:cleanupLog Completed in 2ms
23 timing npm:load:configScope Completed in 0ms
24 timing npm:load:projectScope Completed in 1ms
25 timing npm:load Completed in 11ms
26 timing config:load:flatten Completed in 2ms
27 timing command:run-script Completed in 3ms
28 verbose stack Error: Missing script: "build"
28 verbose stack
28 verbose stack To see a list of scripts, run:
28 verbose stack npm run
28 verbose stack at RunScript.run (C:\Users\Amrit\AppData\Roaming\npm\node_modules\npm\lib\run-script.js:99:13)
29 verbose cwd C:\Users\Amrit\Desktop\Open_Source\glean.js\glean
30 verbose Windows_NT 10.0.19041
31 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Amrit\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "build"
32 verbose node v14.16.1
33 verbose npm v7.11.2
34 error Missing script: "build"
34 error
34 error To see a list of scripts, run:
34 error npm run
35 verbose exit 1
Assignee | ||
Comment 15•4 years ago
|
||
(In reply to Alessio Placitelli [:Dexter] from comment #13)
(In reply to Amrit from comment #12)
I thought that at first too but, I am defiantly on the glean directory and not the root
one.Cool. At this point I believe I need the full shell log to better help you diagnose this :-) Would you kindly attach it here? Thanks!
Hi Alessio just wanted to follow up and see if you had time to look at the full shell log?
Comment 16•4 years ago
|
||
(In reply to Amrit from comment #15)
(In reply to Alessio Placitelli [:Dexter] from comment #13)
(In reply to Amrit from comment #12)
I thought that at first too but, I am defiantly on the glean directory and not the root
one.Cool. At this point I believe I need the full shell log to better help you diagnose this :-) Would you kindly attach it here? Thanks!
Hi Alessio just wanted to follow up and see if you had time to look at the full shell log?
Hey [:Amrit] I left a few comments on your work-in-progress PR. Also note that, for changes in the sample typescript extension you actually need to run the commands inside the glean.js/samples/web-extension/typescript/
folder.
Assignee | ||
Comment 17•4 years ago
|
||
Hi [:brizental] so after reading the README and running the commands I seem to be running into
an error in my terminal "'glean' is not recognized as an internal or external command,
operable program or batch file."
Any help would be appreciated.
Comment 18•4 years ago
|
||
(In reply to Amrit from comment #17)
Hi [:brizental] so after reading the README and running the commands I seem to be running into
an error in my terminal "'glean' is not recognized as an internal or external command,
operable program or batch file."Any help would be appreciated.
Questions:
- Are you inside the
glean.js/samples/web-extension/typescript/
folder? - Have you succesfully linked the
@mozilla/glean
package before attempting to runnpm run build
? If not, then this is the issue. You can go inside yournode_modules
folder and check that thenode_modules/.bin/glean
andnode_modules/@mozilla/glean
paths exist. - Are you attempting to run the
glean
command directly from the command line? This will only work in case you have the@mozilla/glean
package installed as a global npm package. Otherwise, to run directly from the command line you need to use the full path to the glean executable.
Assignee | ||
Comment 19•4 years ago
|
||
I was running the glean command from the command line and decided to install @mozilla/glean
globally and then the build did run.
But the "node_modules/.bin" path doesn't exist but, the "node_modules/@mozilla/glean" does exist.
Which seems strange.
Comment 20•4 years ago
|
||
(In reply to Amrit from comment #19)
But the "node_modules/.bin" path doesn't exist but, the "node_modules/@mozilla/glean" does exist.
Which seems strange.
Hm, this is indeed very weird. Have you tried deleting the node_modules and reinstalling / relinking the packages?
Assignee | ||
Comment 21•4 years ago
|
||
I deleted the node_modules and reinstalled/linked the packages and the "node_modules/.bin" is now
there but doesn't have "glean" in it.
Also the terminal is returning these errors when I run the build:
ERROR in ./src/index.ts 10:16-44
Module not found: Error: Can't resolve './generated/pings' in 'C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src'
ERROR in ./src/index.ts 11:17-46
Module not found: Error: Can't resolve './generated/sample' in 'C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src'
ERROR in C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src\index.ts
./src/index.ts 8:23-42
[tsl] ERROR in C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src\index.ts(8,24)
TS2307: Cannot find module './generated/pings' or its corresponding type declarations.
ERROR in C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src\index.ts
./src/index.ts 9:43-63
[tsl] ERROR in C:\Users\Amrit\Desktop\Open_Source\glean.js\samples\web-extension\typescript\src\index.ts(9,44)
TS2307: Cannot find module './generated/sample' or its corresponding type declarations.
Comment 22•4 years ago
|
||
(In reply to Amrit from comment #21)
I deleted the node_modules and reinstalled/linked the packages and the "node_modules/.bin" is now
there but doesn't have "glean" in it.
Hum, can you check that you did build glean? This is a web extension sample, so you need to run npm run build:webext
to build for webextensions, but also npm run build:cli
to build the cli part.
Assignee | ||
Comment 23•4 years ago
|
||
That did fix the "node_modules/.bin" and now has glean in the folder.
But the folder generated still hasn't been created the terminal is giving me the
same 4 errors that I posted about yesterday.
Assignee | ||
Comment 24•4 years ago
|
||
I was also, able to run the extension in Firefox by following the instructions on the web-extension
README which caused the Glean logo to appear and was able to click on it which activated
the pop-up.
Reporter | ||
Comment 25•4 years ago
|
||
(In reply to Amrit from comment #24)
I was also, able to run the extension in Firefox by following the instructions on the web-extension
README which caused the Glean logo to appear and was able to click on it which activated
the pop-up.
Does that mean you are no longer having the errors?
Assignee | ||
Comment 26•4 years ago
|
||
No this is the strange part the errors are still occuring.
Reporter | ||
Comment 27•3 years ago
|
||
(In reply to Amrit from comment #26)
No this is the strange part the errors are still occuring.
Hey Amrit,
let's try one last thing: would you kindly provide us with the full, detailed log from your shell, including the commands you write and the paths? This would really help us diagnosing the problem. If you don't feel comfortable (understandably) adding it to the bug, that's fine. Please do send it via email, if you want, to aplacitelli@mozilla.com
Assignee | ||
Comment 28•3 years ago
|
||
Hi Alessio,
I sent a full console log of what I am doing as a text file to your
email
Thanks,
Amrit
Reporter | ||
Comment 29•3 years ago
|
||
Hey Amrit,
would you kindly update your code to the most recent version of Glean.js? You might be stumbling upon a problem with the glean_parser output not being displayed. We solved this recently.
Assignee | ||
Comment 30•3 years ago
|
||
Hi Alessio,
I updated all the code to the most recent version and am still having errors.
Are you able to get it running on your end?
Seeing what you are doing might help.
Comment 31•3 years ago
|
||
Hey Amrit, are you on the Mozilla chat? Would you mind joining so we can chat and I can more help you debug this more easily? https://wiki.mozilla.org/Matrix. My username over there is the same as here, :brizental :)
Assignee | ||
Comment 32•3 years ago
|
||
Hi :brizental I sent you a message on Matrix :)
Comment 33•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Description
•