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

new badge: f-droid #1965

Merged
merged 37 commits into from
Aug 30, 2018
Merged

new badge: f-droid #1965

merged 37 commits into from
Aug 30, 2018

Conversation

niccokunzmann
Copy link
Contributor

@niccokunzmann niccokunzmann commented Aug 23, 2018

I document the progress here as an imperfect PR and ask for review once I am confident it works.

  • edit server.js
  • first untested version
    • get the website
    • regex query as string
    • get version info

fixes #1963

@shields-ci
Copy link

shields-ci commented Aug 23, 2018

Messages
📖

✨ Thanks for your contribution to Shields, @niccokunzmann!

Generated by 🚫 dangerJS

.get('/f-droid/version/org.pacien.tincapp.json')
.intercept(nock =>
nock('https://f-droid.org')
.get('/en/packages/org.pacien.tincapp/')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are red although and I do not know why.

$ npm run test:services -- --grep F-Droid

> gh-badges@1.3.0 test:services /home/user/shields
> HANDLE_INTERNAL_ERRORS=false mocha --delay lib/service-test-runner/cli.js "--grep" "F-Droid"

Running all service tests.


No secret data found at /home/user/shields/private/secret.json (see lib/server-secrets.js)
raven@2.4.2 alert: no DSN provided, error reporting disabled
0823224940 FsTokenPersistence configured with /home/user/shields/private/github-user-tokens.json
0823224940 Server is starting up: http://lib/service-test-runner/cli.js:80/
No fallback font set.
Unable to load fallback font. Using Helvetica-Bold instead.
  F-Droid
    Package is found
GET /f-droid/version/org.pacien.tincapp.json has FAILED with the following response:
      1) 
	[ GET /f-droid/version/org.pacien.tincapp.json ]
    Package is not found
GET /f-droid/version/org.pacien.tincapp.json has FAILED with the following response:
      2) 
	[ GET /f-droid/version/org.pacien.tincapp.json ]


  0 passing (827ms)
  2 failing

  1) F-Droid
       Package is found
         
	[ GET /f-droid/version/org.pacien.tincapp.json ]:

      AssertionError: expected { Object (name, value) } to deeply equal { Object (name, value) }
      + expected - actual

       {
      -  "name": "404"
      -  "value": "badge not found"
      +  "name": "F-Droid"
      +  "value": "v1.8asdsadsa"
       }
      
      at Object.pathMatch.matchJSON (node_modules/icedfrisby/lib/pathMatch.js:138:38)
      at _expect (node_modules/icedfrisby/lib/icedfrisby.js:583:10)
      at IcedFrisbyNock._invokeExpects (node_modules/icedfrisby/lib/icedfrisby.js:1261:26)
      at start (node_modules/icedfrisby/lib/icedfrisby.js:1244:12)
      at Request.runCallback [as _callback] (node_modules/icedfrisby/lib/icedfrisby.js:1131:16)
      at Request.self.callback (node_modules/request/request.js:185:22)
      at Request.<anonymous> (node_modules/request/request.js:1161:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
      at endReadableNT (_stream_readable.js:1056:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)

  2) F-Droid
       Package is not found
         
	[ GET /f-droid/version/org.pacien.tincapp.json ]:

      AssertionError: expected { Object (name, value) } to deeply equal { Object (name, value) }
      + expected - actual

       {
      -  "name": "404"
      -  "value": "badge not found"
      +  "name": "F-Droid"
      +  "value": "app not found"
       }
      
      at Object.pathMatch.matchJSON (node_modules/icedfrisby/lib/pathMatch.js:138:38)
      at _expect (node_modules/icedfrisby/lib/icedfrisby.js:583:10)
      at IcedFrisbyNock._invokeExpects (node_modules/icedfrisby/lib/icedfrisby.js:1261:26)
      at start (node_modules/icedfrisby/lib/icedfrisby.js:1244:12)
      at Request.runCallback [as _callback] (node_modules/icedfrisby/lib/icedfrisby.js:1131:16)
      at Request.self.callback (node_modules/request/request.js:185:22)
      at Request.<anonymous> (node_modules/request/request.js:1161:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
      at endReadableNT (_stream_readable.js:1056:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)

See https://f-droid.org/en/packages/org.pacien.tincapp/
and https://github.com/badges/shields/pull/1965/files#diff-63441b8c1c2f41111e85c4e116ac3804R10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: The path is /version and not /f-droid/version

@niccokunzmann
Copy link
Contributor Author

niccokunzmann commented Aug 23, 2018

Now, I have the problem, that the nock data is not delivered as website. The HTTP get always returns an empty website.

See yourself: search for website and see 23a97a0

$ npm run test:services -- --grep F-Droid

> gh-badges@1.3.0 test:services /home/user/shields
> HANDLE_INTERNAL_ERRORS=false mocha --delay lib/service-test-runner/cli.js "--grep" "F-Droid"

Running all service tests.


No secret data found at /home/user/shields/private/secret.json (see lib/server-secrets.js)
raven@2.4.2 alert: no DSN provided, error reporting disabled
0823231217 FsTokenPersistence configured with /home/user/shields/private/github-user-tokens.json
0823231217 Server is starting up: http://lib/service-test-runner/cli.js:80/
No fallback font set.
Unable to load fallback font. Using Helvetica-Bold instead.
  F-Droid
    Package is found
website

GET /version/org.pacien.tincapp.json has FAILED with the following response:
      1) 
	[ GET /version/org.pacien.tincapp.json ]
    Package is not found
website

GET /version/org.pacien.tincapp.json has FAILED with the following response:
      2) 
	[ GET /version/org.pacien.tincapp.json ]


  0 passing (810ms)
  2 failing

  1) F-Droid
       Package is found
         
	[ GET /version/org.pacien.tincapp.json ]:

      AssertionError: expected { Object (name, value) } to deeply equal { name: 'F-Droid', value: 'v0.19' }
      + expected - actual

       {
         "name": "F-Droid"
      -  "value": "fix this badge"
      +  "value": "v0.19"
       }
      
      at Object.pathMatch.matchJSON (node_modules/icedfrisby/lib/pathMatch.js:138:38)
      at _expect (node_modules/icedfrisby/lib/icedfrisby.js:583:10)
      at IcedFrisbyNock._invokeExpects (node_modules/icedfrisby/lib/icedfrisby.js:1261:26)
      at start (node_modules/icedfrisby/lib/icedfrisby.js:1244:12)
      at Request.runCallback [as _callback] (node_modules/icedfrisby/lib/icedfrisby.js:1131:16)
      at Request.self.callback (node_modules/request/request.js:185:22)
      at Request.<anonymous> (node_modules/request/request.js:1161:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
      at endReadableNT (_stream_readable.js:1056:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)

  2) F-Droid
       Package is not found
         
	[ GET /version/org.pacien.tincapp.json ]:

      AssertionError: expected { Object (name, value) } to deeply equal { Object (name, value) }
      + expected - actual

       {
         "name": "F-Droid"
      -  "value": "fix this badge"
      +  "value": "app not found"
       }
      
      at Object.pathMatch.matchJSON (node_modules/icedfrisby/lib/pathMatch.js:138:38)
      at _expect (node_modules/icedfrisby/lib/icedfrisby.js:583:10)
      at IcedFrisbyNock._invokeExpects (node_modules/icedfrisby/lib/icedfrisby.js:1261:26)
      at start (node_modules/icedfrisby/lib/icedfrisby.js:1244:12)
      at Request.runCallback [as _callback] (node_modules/icedfrisby/lib/icedfrisby.js:1131:16)
      at Request.self.callback (node_modules/request/request.js:185:22)
      at Request.<anonymous> (node_modules/request/request.js:1161:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
      at endReadableNT (_stream_readable.js:1056:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)


@niccokunzmann
Copy link
Contributor Author

niccokunzmann commented Aug 23, 2018

Status:

@paulmelnikow
Copy link
Member

In terms of the mock, I'm not sure what is up with those APM tests passing an array to .reply(), though the nock API doc is here: https://github.com/nock/nock#specifying-replies

I got your tests to pass by changing:

.reply([200, manyVersions])

to:

.reply(200, manyVersions)

niccokunzmann added a commit to niccokunzmann/shields that referenced this pull request Aug 24, 2018
@niccokunzmann
Copy link
Contributor Author

@paulmelnikow Thanks for the reply. I was assuming something else because of
https://github.com/badges/shields/blob/master/services/apm/apm.tester.js#L41 Maybe, this means it returns JSON.

niccokunzmann added a commit to niccokunzmann/shields that referenced this pull request Aug 24, 2018
@niccokunzmann
Copy link
Contributor Author

@PyvesB @chris48s @paulmelnikow Thanks for your replies and the help. Please review as I think, this is ready to merge.

@RedSparr0w
Copy link
Member

Looks like you need to run prettier for the test to pass.
(On mobile sorry for the short reply)

@niccokunzmann
Copy link
Contributor Author

niccokunzmann commented Aug 24, 2018

I forgot: The examples do not work. The tests pass but I can not use the front page.
bc418ab

http://[::]:8080/examples/build shows

I have nothing to offer for this request
… but blood, toil, tears and sweat.
Fortunately, the main page can offer rainbows instead!
(You probably landed on this page because a link was broken, because someone mistyped its URL, or because of an irrelevant mistake. Don't worry, though: there is all of the rest of the Web to explore!)

And I see this in the main page console:

Loading failed for the <script> with source “http://[::]:8080/_next/102fbd59-c519-4278-ba64-757fb07c3e37/page/index.js”. [::]:8080:16
Loading failed for the <script> with source “http://[::]:8080/_next/102fbd59-c519-4278-ba64-757fb07c3e37/page/_error.js”. [::]:8080:16
Loading failed for the <script> with source “http://[::]:8080/_next/373e62b9ccd276ee0427a69f4f991d68/app.js”. [::]:8080:16 
shields/build$ tree
.
├── index.html
├── _next
│   ├── 085d9632aa638b42a1aef20e59bfcbef
│   │   └── app.js
│   └── 120c30d5-2ce6-4314-8234-bd0e2594cb8a
│       └── page
│           ├── _error.js
│           ├── _error.js.map
│           ├── index.js
│           └── index.js.map
└── static
    ├── logo.svg
    └── main.css

5 directories, 8 files

I cannot find this string anywhere:

shields$ grep -r 102fbd59-c519-4278-ba64-757fb07c3e37

It looks like the next build is is not updated.

@niccokunzmann
Copy link
Contributor Author

The service works on http://localhost:3000/#/ but not on http://[::]:8080/

@niccokunzmann
Copy link
Contributor Author

niccokunzmann commented Aug 24, 2018

Problem now: I do not see the example badge.

@niccokunzmann
Copy link
Contributor Author

Problem ideintified:

<img class="badge-img clickable" src="http://[::]:8080/badge/F-Droid-v1.0-blue.svg" alt="">

is a 404 badge not found

@niccokunzmann
Copy link
Contributor Author

Solution:

http://[::]:8080/badge/F--Droid-test-blue.svg

The - needs to be escaped when in title.

niccokunzmann added a commit to niccokunzmann/shields that referenced this pull request Aug 24, 2018
Problem: When a - was in the title, this lead to an invalid preview badge
  badges#1965 (comment)
Solution: Escape the title of the badge.
@niccokunzmann niccokunzmann changed the title [WIP] new badge: f-droid new badge: f-droid Aug 24, 2018
this is the first untested version
- get the website
- parse as xml
- get version info
Some services only require HTTP requests and not JSON requests.
This splits up the two services.
This introduces a new error because the nock results in an empty website.
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 12:37 Inactive
@niccokunzmann
Copy link
Contributor Author

niccokunzmann commented Aug 30, 2018

F-Droid allows downloading a 1.360.393 bytes big jar file with meta data of all the different apps. https://f-droid.org/repo/index-v1.jar This is a jar file which contains JSON.

Right now, there is a single index file that is updated a few times a week. So the easiest way to implement this would be to have something on shields.io poll for the index-v1.jar, and then when it updates, it would generate all of the badges.

If there were many people using the f-droid badges, caching this big file would reduce communication to external servers. It also depends on how often this file is updated. I do not think I will use this as a base for the badge.

- improved performance
- addresses badges#1965 (comment)
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 13:49 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 13:53 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 14:23 Inactive
@niccokunzmann
Copy link
Contributor Author

I think, I addressed the changes marked in the roadmap #1965 (comment).

@paulmelnikow
Copy link
Member

Thank you for addressing these! I will leave this to @PyvesB to wrap up.

If there were many people using the f-droid badges, caching this big file would reduce communication to external servers. It also depends on how often this file is updated. I do not think I will use this as a base for the badge.

I agree with you. It will be lighter to just snag the text files we need. Down the line, we could revisit this if we find many people are using these badges.

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 20:53 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-1965 August 30, 2018 21:37 Inactive
Copy link
Member

@PyvesB PyvesB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the current state of things. Let's get this merged! Thanks for all your work @niccokunzmann, we've all definitely learned at lot here and hopefully things will be smoother next time. 😉

Here's a summary of the follow up tasks to this PR:

@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

@niccokunzmann
Copy link
Contributor Author

@PyvesB @paulmelnikow @RedSparr0w and of cause @shields-ci Thanks for the help during the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add F-Droid version badge
5 participants