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

refactor [TeamCity] #2601

Merged
merged 10 commits into from
Jan 2, 2019
Merged

refactor [TeamCity] #2601

merged 10 commits into from
Jan 2, 2019

Conversation

calebcartwright
Copy link
Member

Refactors TeamCity services to new service model and adds tests.

Refs #1358

@calebcartwright calebcartwright added the service-badge New or updated service badge label Dec 28, 2018
@shields-ci
Copy link

shields-ci commented Dec 28, 2018

Messages
📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against feef630

pass: serverSecrets.teamcity_pass,
}
} else {
qs.guest = 1
Copy link
Member Author

Choose a reason for hiding this comment

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

TeamCity requires auth, so if explicit user/pass are not provided then we have to use guest auth

sendBadge(format, badgeData)
}
const buildStatusRegex = /SUCCESS|FAILURE|ERROR/
const buildStatusTextRegex = /^Success|Failure|Error|Tests( failed: \d+( \(\d+ new\))?)?(,)?( passed: \d+)?(,)?( ignored: \d+)?(,)?( muted: \d+)?$/
Copy link
Member Author

Choose a reason for hiding this comment

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

This covers everything that I've seen, but I have this suspicion that there are other potential values. The API spec does not enumerate those potential values so this is based on available info.

}
}

static get examples() {
return [
{
title: 'TeamCity CodeBetter',
previewUrl: 'codebetter/bt428',
title: 'TeamCity Build Status (CodeBetter)',
Copy link
Member Author

Choose a reason for hiding this comment

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

CodeBetter was apparently merged with the main teamcity.jetbrains.com Open Source instance (see http://codebetter.jetbrains.com/) but maintaining the path and some nomenclature for backwards compatibility

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 December 28, 2018 19:13 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 December 28, 2018 19:25 Inactive
@calebcartwright
Copy link
Member Author

Review app deployment is failing, heroku logs here:

2018-12-28T19:51:09.847842+00:00 app[web.1]: npm ERR! Exit status 1
2018-12-28T19:51:09.848158+00:00 app[web.1]: npm ERR! 
2018-12-28T19:51:09.848346+00:00 app[web.1]: npm ERR! Failed at the shields.io@0.0.0 heroku-start script.
2018-12-28T19:51:09.848528+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-12-28T19:51:09.985776+00:00 app[web.1]: 
2018-12-28T19:51:09.985982+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-12-28T19:51:09.986136+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-12-28T19_51_09_863Z-debug.log
2018-12-28T19:51:10.091056+00:00 heroku[web.1]: State changed from starting to crashed
2018-12-28T20:06:00.703320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shields-staging-pr-2601.herokuapp.com request_id=98cb2f35-8983-4ca9-88db-7393984dd24a fwd="65.188.141.183" dyno= connect= service= status=503 bytes= protocol=https
2018-12-28T20:11:06.401835+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shields-staging-pr-2601.herokuapp.com request_id=bef85630-4d7f-4463-ae47-8eec74bf1cc6 fwd="65.188.141.183" dyno= connect= service= status=503 bytes= protocol=https

@paulmelnikow
Copy link
Member

paulmelnikow commented Dec 29, 2018

Hmm, are there more logs further up? (Probably related to #2569.)

@calebcartwright
Copy link
Member Author

Nope, at least not that I could see in the dashboard. Will check with the CLI to see if that offers any more insight

@calebcartwright
Copy link
Member Author

From the CLI

2018-12-29T00:46:31.482312+00:00 app[web.1]: > shields.io@0.0.0 heroku-start /app
2018-12-29T00:46:31.482313+00:00 app[web.1]: > node scripts/export-heroku-secrets-cli.js && node server
2018-12-29T00:46:31.482314+00:00 app[web.1]:
2018-12-29T00:46:31.633522+00:00 app[web.1]: private/secret.json does not exist, creating.
2018-12-29T00:46:31.779687+00:00 app[web.1]: raven@2.6.4 alert: no DSN provided, error reporting disabled
2018-12-29T00:46:32.870527+00:00 app[web.1]: { ValidationError: {
2018-12-29T00:46:32.870539+00:00 app[web.1]: "bind": {
2018-12-29T00:46:32.870540+00:00 app[web.1]: "port": 5007,
2018-12-29T00:46:32.870544+00:00 app[web.1]: "address": "::"
2018-12-29T00:46:32.870545+00:00 app[web.1]: },
2018-12-29T00:46:32.870546+00:00 app[web.1]: "metrics": {
2018-12-29T00:46:32.870548+00:00 app[web.1]: "prometheus": {
2018-12-29T00:46:32.870550+00:00 app[web.1]: "enabled": false
2018-12-29T00:46:32.870552+00:00 app[web.1]: }
2018-12-29T00:46:32.870554+00:00 app[web.1]: },
2018-12-29T00:46:32.870555+00:00 app[web.1]: "ssl": {
2018-12-29T00:46:32.870557+00:00 app[web.1]: "isSecure": false
2018-12-29T00:46:32.870558+00:00 app[web.1]: },
2018-12-29T00:46:32.870560+00:00 app[web.1]: "baseUri": "http://[::]:5007/",
2018-12-29T00:46:32.870562+00:00 app[web.1]: "cors": {
2018-12-29T00:46:32.870564+00:00 app[web.1]: "allowedOrigin" [1]: "http://[::]:5007"
2018-12-29T00:46:32.870565+00:00 app[web.1]: },
2018-12-29T00:46:32.870567+00:00 app[web.1]: "persistence": {
2018-12-29T00:46:32.870569+00:00 app[web.1]: "dir": "./private"
2018-12-29T00:46:32.870570+00:00 app[web.1]: },
2018-12-29T00:46:32.870571+00:00 app[web.1]: "services": {
2018-12-29T00:46:32.870573+00:00 app[web.1]: "github": {
2018-12-29T00:46:32.870575+00:00 app[web.1]: "baseUri": "https://api.github.com",
2018-12-29T00:46:32.870576+00:00 app[web.1]: "debug": {
2018-12-29T00:46:32.870581+00:00 app[web.1]: "enabled": false,
2018-12-29T00:46:32.870582+00:00 app[web.1]: "intervalSeconds": 300
2018-12-29T00:46:32.870584+00:00 app[web.1]: }
2018-12-29T00:46:32.870586+00:00 app[web.1]: },
2018-12-29T00:46:32.870587+00:00 app[web.1]: "trace": false
2018-12-29T00:46:32.870589+00:00 app[web.1]: },
2018-12-29T00:46:32.870590+00:00 app[web.1]: "profiling": {
2018-12-29T00:46:32.870592+00:00 app[web.1]: "makeBadge": false
2018-12-29T00:46:32.870593+00:00 app[web.1]: },
2018-12-29T00:46:32.870595+00:00 app[web.1]: "cacheHeaders": {
2018-12-29T00:46:32.870596+00:00 app[web.1]: "defaultCacheLengthSeconds": 120
2018-12-29T00:46:32.870598+00:00 app[web.1]: },
2018-12-29T00:46:32.870599+00:00 app[web.1]: "rateLimit": true,
2018-12-29T00:46:32.870601+00:00 app[web.1]: "handleInternalErrors": true
2018-12-29T00:46:32.870602+00:00 app[web.1]: }
2018-12-29T00:46:32.870604+00:00 app[web.1]:
2018-12-29T00:46:32.870606+00:00 app[web.1]: [1] "allowedOrigin" must be an array
2018-12-29T00:46:32.870608+00:00 app[web.1]: at Object.exports.process (/app/node_modules/joi/lib/errors.js:203:19)
2018-12-29T00:46:32.870609+00:00 app[web.1]: at internals.Object._validateWithOptions (/app/node_modules/joi/lib/types/any/index.js:764:31)
2018-12-29T00:46:32.870611+00:00 app[web.1]: at module.exports.internals.Any.root.validate (/app/node_modules/joi/lib/index.js:147:23)
2018-12-29T00:46:32.870612+00:00 app[web.1]: at module.exports.internals.Any.root.attempt (/app/node_modules/joi/lib/index.js:177:29)
2018-12-29T00:46:32.870613+00:00 app[web.1]: at module.exports.internals.Any.root.assert (/app/node_modules/joi/lib/index.js:172:14)
2018-12-29T00:46:32.870614+00:00 app[web.1]: at new Server (/app/lib/server.js:85:9)
2018-12-29T00:46:32.870616+00:00 app[web.1]: at /app/server.js:14:11
2018-12-29T00:46:32.870617+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:19:3)
2018-12-29T00:46:32.870618+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:721:30)
2018-12-29T00:46:32.870619+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
2018-12-29T00:46:32.870620+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:620:32)
2018-12-29T00:46:32.870621+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
2018-12-29T00:46:32.870623+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:552:3)
2018-12-29T00:46:32.870624+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
2018-12-29T00:46:32.870625+00:00 app[web.1]: at executeUserCode (internal/bootstrap/node.js:342:17)
2018-12-29T00:46:32.870626+00:00 app[web.1]: at startExecution (internal/bootstrap/node.js:276:5)
2018-12-29T00:46:32.870627+00:00 app[web.1]: at startup (internal/bootstrap/node.js:227:5)
2018-12-29T00:46:32.870628+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
2018-12-29T00:46:32.870629+00:00 app[web.1]: isJoi: true,
2018-12-29T00:46:32.870630+00:00 app[web.1]: name: 'ValidationError',
2018-12-29T00:46:32.870631+00:00 app[web.1]: details:
2018-12-29T00:46:32.870633+00:00 app[web.1]: [ { message: '"allowedOrigin" must be an array',
2018-12-29T00:46:32.870634+00:00 app[web.1]: path: [Array],
2018-12-29T00:46:32.870635+00:00 app[web.1]: type: 'array.base',
2018-12-29T00:46:32.870636+00:00 app[web.1]: context: [Object] } ],
2018-12-29T00:46:32.870637+00:00 app[web.1]: _object:
2018-12-29T00:46:32.870638+00:00 app[web.1]: { bind: { port: 5007, address: '::' },
2018-12-29T00:46:32.870639+00:00 app[web.1]: metrics: { prometheus: [Object] },
2018-12-29T00:46:32.870640+00:00 app[web.1]: ssl: { isSecure: false, key: undefined, cert: undefined },
2018-12-29T00:46:32.870642+00:00 app[web.1]: baseUri: 'http://[::]:5007/',
2018-12-29T00:46:32.870643+00:00 app[web.1]: redirectUri: undefined,
2018-12-29T00:46:32.870644+00:00 app[web.1]: cors: { allowedOrigin: 'http://[::]:5007' },
2018-12-29T00:46:32.870645+00:00 app[web.1]: persistence: { dir: './private', redisUrl: undefined },
2018-12-29T00:46:32.870646+00:00 app[web.1]: services: { github: [Object], trace: false },
2018-12-29T00:46:32.870647+00:00 app[web.1]: profiling: { makeBadge: false },
2018-12-29T00:46:32.870648+00:00 app[web.1]: cacheHeaders: { defaultCacheLengthSeconds: 120 },
2018-12-29T00:46:32.870649+00:00 app[web.1]: rateLimit: true,
2018-12-29T00:46:32.870651+00:00 app[web.1]: handleInternalErrors: true },
2018-12-29T00:46:32.870652+00:00 app[web.1]: annotate: [Function] }
2018-12-29T00:46:32.883059+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-12-29T00:46:32.883398+00:00 app[web.1]: npm ERR! errno 1
2018-12-29T00:46:32.884545+00:00 app[web.1]: npm ERR! shields.io@0.0.0 heroku-start: `node scripts/export-heroku-secrets-cli.js && node server`

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 December 30, 2018 18:09 Inactive
@calebcartwright
Copy link
Member Author

calebcartwright commented Dec 30, 2018

Alright I think I've figured out what's going on here:

In server-config.js where allowedOrigin is set, the call to the envArray function uses a string arg for the defaultValue param. When the envVar param is falsy (which I assume is happening here because at least this staging app doesn't have the ALLOWED_ORIGIN env var set) then the envArray function returns the defaultValue directly https://github.com/badges/shields/blob/master/lib/server-config.js#L11

This results in allowedOrigin being a string in the config resulting in the error (from this line) during Server instantiation.

It looks like there's a couple relatively easy fixes to this, but I'm hesitant to update this just yet as I'm not familiar with the server config/startup process. Any thoughts?

@chris48s
Copy link
Member

I think this is unrelated to this PR. I tried to create a review app for #2598 and I've got the same issue: https://shields-staging-pr-2598.herokuapp.com/

Failing with "allowedOrigin" must be an array

Sounds like you're on the right lines for a fix, but given the issue isn't strictly related to this PR and is affecting other staging deploys, can we pull the fix out into a new PR so we can review it independently of the TeamCity refactor. Then we can merge it into other affected working branches.

@calebcartwright
Copy link
Member Author

calebcartwright commented Dec 30, 2018

Proposed fix in #2607 for review I'll open a PR with a fix here momentarily

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 December 30, 2018 21:29 Inactive
@calebcartwright
Copy link
Member Author

Looks like the fix is working

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 January 2, 2019 02:14 Inactive
Copy link
Member

@paulmelnikow paulmelnikow left a comment

Choose a reason for hiding this comment

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

Nice!

services/teamcity/teamcity-build.service.js Outdated Show resolved Hide resolved
services/teamcity/teamcity-build.service.js Outdated Show resolved Hide resolved
services/teamcity/teamcity-coverage.service.js Outdated Show resolved Hide resolved
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 January 2, 2019 03:10 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 January 2, 2019 04:15 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2601 January 2, 2019 04:17 Inactive
@paulmelnikow paulmelnikow merged commit 3bbe248 into master Jan 2, 2019
@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:

@paulmelnikow paulmelnikow deleted the teamcity-refactor branch January 2, 2019 05:19
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.

4 participants