Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Languages plugin no longer works #424

Closed
Nixinova opened this issue Jul 29, 2021 · 10 comments · Fixed by #436
Closed

Languages plugin no longer works #424

Nixinova opened this issue Jul 29, 2021 · 10 comments · Fixed by #436

Comments

@Nixinova
Copy link
Contributor

Today's metrics run deleted all languages data and doesn't add it back even in a following run. No errors are logged in the Action run.

Nixinova/Nixinova@6339db0

The only difference between today and yesterday is Linguist v7.16 came out a few hours ago; maybe this had something to do with it?

@lowlighter
Copy link
Owner

Hello,
Indeed, I have the same problem too 😕

It could come from the linguist release since the docker file is not version fixed, but the @main branch didn't got any docker image rebuild so it should have retained the previous version

I'll investigate later today, thanks for reporting

lowlighter added a commit that referenced this issue Jul 30, 2021
lowlighter added a commit that referenced this issue Jul 30, 2021
@Nixinova
Copy link
Contributor Author

Run

Spammed with the following as the second debug statement:

#424 DEBUG: TypeError: files.map is not a function
    at file:///metrics/source/plugins/languages/analyzers.mjs:148:166
    at Array.flatMap (<anonymous>)
    at analyze (file:///metrics/source/plugins/languages/analyzers.mjs:148:133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async indepth (file:///metrics/source/plugins/languages/analyzers.mjs:33:7)
    at async Object.default [as languages] (file:///metrics/source/plugins/languages/index.mjs:64:32)
    at async file:///metrics/source/plugins/core/index.mjs:50:30
    at async Promise.all (index 4)
    at async metrics (file:///metrics/source/app/metrics/index.mjs:61:22)
First debug is showing that the commit data is being fetched:
// line 2551
// #424 DEBUG: [
// 
[
    {
      sha: '274d05e67e8ca9fbca75ba3c0e02f52bad2a9804',
      filename: 'lib/linguist/languages.yml',
      status: 'modified',
      additions: 1,
      deletions: 0,
      changes: 1,
      blob_url: 'https://github.com/Nixinova/fork_linguist/blob/d49b21cd977093a3359f37b976e039e270d085a4/lib/linguist/languages.yml',
      raw_url: 'https://github.com/Nixinova/fork_linguist/raw/d49b21cd977093a3359f37b976e039e270d085a4/lib/linguist/languages.yml',
      contents_url: 'https://api.github.com/repos/Nixinova/fork_linguist/contents/lib/linguist/languages.yml?ref=d49b21cd977093a3359f37b976e039e270d085a4',
      patch: '@@ -6345,6 +6345,7 @@ Wget Config:\n' +
        '   language_id: 668457123\n' +
        ' Wikitext:\n' +
        '   type: prose\n' +
        '+  color: "#fc5757"\n' +
        '   wrap: true\n' +
        '   aliases:\n' +
        '   - mediawiki'
    }
  ]
// line 13036
//   ... 16 more items
// ]

@Nixinova
Copy link
Contributor Author

Nixinova commented Jul 30, 2021

Ah, I think may have I found the problem

const files = Object.fromEntries(Object.entries(JSON.parse(await imports.run("github-linguist --json", {cwd:path}, {log:false}))).flatMap(([lang, files]) => files.map(file => [file, lang])))

await imports.run("github-linguist --json", {cwd:path}, {log:false}))).flatMap(([lang, files]) => //...

Linguist 7.16 did overhaul the output of --json:

$ github-linguist --json
{"Dockerfile":{"size":1212,"percentage":"0.31"},"Ruby":{"size":264519,"percentage":"66.84"},"C":{"size":97685,"percentage":"24.68"},"Lex":{"size":5098,"percentage":"1.29"},"Shell":{"size":1257,"percentage":"0.32"},"Go":{"size":25999,"percentage":"6.57"}}

@lowlighter
Copy link
Owner

Thanks, greatly appreciate the help for debug 👍

Maybe it would be a good time to try to switch to Nixinova/Linguist and have a full JS implementation of linguist ?
It's always hasazardous to rely on spawn process, it may be more stable in the future

@Nixinova
Copy link
Contributor Author

Yeah, I'll prioritise developing my Linguist further; currently it doesn't check gitignore or heuristics but I'll add those for v1.3.

lowlighter added a commit that referenced this issue Jul 30, 2021
@lowlighter
Copy link
Owner

Yeah, I'll prioritise developing my Linguist further; currently it doesn't check gitignore or heuristics but I'll add those for v1.3.

Ok, I'll try to rollback on previous linguist version in the meantime to try fix this issue as it's pretty big

@Nixinova
Copy link
Contributor Author

Nixinova commented Jul 30, 2021

Rollback to 7.15 worked, you can remove the two debug statements.

@Nixinova
Copy link
Contributor Author

Closing since it's working now. If you want to use github-linguist@latest again you'll have to tweak that line to fit the new output format.

lowlighter added a commit that referenced this issue Jul 31, 2021
@Nixinova
Copy link
Contributor Author

Nixinova commented Aug 1, 2021

Yeah, I'll prioritise developing my Linguist further; currently it doesn't check gitignore or heuristics but I'll add those for v1.3.

Version 1.4.0 is out and supports both of these now. It should be good to use.

@Nixinova
Copy link
Contributor Author

Nixinova commented Aug 1, 2021

+ const linguist = require('linguist-js')
- const files = Object.fromEntries(Object.entries(JSON.parse(await imports.run("github-linguist --json", {cwd:path}, {log:false}))).flatMap(([lang, files]) => files.map(file => [file, lang])))
+ const {results:files} = await linguist(path, {})

https://github.com/Nixinova/fork_metrics/tree/replace-linguist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants