Apollo on android: can't download schema or generate classes - windows

I'm trying Apollo and graphql for the first time and I want to use this api and I'm following the official example here. However
running the schema download task
gradlew :app:downloadApolloSchema --endpoint='https://countries.trevorblades.com/' --schema='app/src/main/graphql/com/trevorblades/countries/schema.json'
results in
Execution failed for task ':app:downloadApolloSchema'.
> Expected URL scheme 'http' or 'https' but no colon was found
with both the repo I want to use and the example's.
If I try to manually download the schema using the button on the repo's page, place it in the correct directory and run
gradlew generateApolloSources
it results in
Failed to parse GraphQL schema introspection query from `[...]app\src\main\graphql\com\trevorblades\countries\schema.json`
again with both my repo and the one from the example.
I've the feeling that I'm missing something really trivial here, but I really can't figure it out.
any help will be appreciated.

Try the JS GraphQL IDEA plugin, which might make life a tad easier. And as it suggested here ...you might not pass a valid endpoint at all. Try --endpoint=https://countries.trevorblades.com/ or in " double-quotes . The error message is definitely concerning the --endpoint and not concerning the --schema. I have the suspicion that Windows might not like these ' single quotes
(obviously the same would also apply to --schema).
gradlew.bat :app:downloadApolloSchema --endpoint=https://countries.trevorblades.com/ --schema=app/src/main/graphql/com/trevorblades/countries/schema.json
or:
gradlew.bat :app:downloadApolloSchema --endpoint="https://countries.trevorblades.com/" --schema="app/src/main/graphql/com/trevorblades/countries/schema.json"

Related

Download Gitlab's graphql schema

I'm trying to get hold of gitlab_schema.graphql, i.e. the schema for Gitlab's graphql API. Can't find it anywhere, does anyone have any pointers?
You can use apollo CLI for this: apollo client:download-schema --endpoint=https://gitlab.yourcompany.com/api/graphql schema.graphql or just omit filename and it will download to JSON
It doesn't look like GitLab shares the schema directly, just this Reference Documentation generated from the schema, and the GraphiQL Explorer / IDE (more info about GraphiQL Explorer here).
I found the schema is an artifact in the Gitlab CI pipe (graphql-schema-dump job), for example here: https://gitlab.com/gitlab-org/gitlab/-/jobs/1602029144.
Not perfect, but works.
Here's alternative, if you are working with Rust lang. For Rust developers, you need to install the crate named graphql_client_cli via cargo. Example: cargo install graphql_client_cli.
Next, you can run the graphql client you just downloaded, to get the schema (either in JSON or GraphQL format). Example: graphql-client --authorization 'Bearer <bearer token>' https://<your gitlab url site>/api/graphql.
See the GraphQL Client CLI for more options.

How to get SonarQube Issues Report via API

Is there a way to get an issues report by querying the SonarQube web API?
With previous versions of SonarQube, I was able to generate an HTML report after each build but this feature looks like it's been deprecated in newer installments.
At the moment, I'm trying this bit of code
curl -u foo:bar https://sonar.example.com/api/issues/search?pageSize=100&componentKeys=my-app&metricKeys=violations,ncloc,line
But it errors with {"errors":[{"msg":"The 'component' parameter is missing"}]
Ideally, what I'm after is to just get the lines of code, the number of bugs, vulnerabilities, and Code smells in each run/scan.
Something like this
But through querying the API after each analysis.
Is this possible, please?
Had the same issue. The problem is that there is something wrong with the CURL command and you need to specify the full url as string using quotes.
Your case would be:
curl -u foo:bar "https://sonar.example.com/api/measures/search?pageSize=100&componentKeys=my-app&metricKeys=ncloc,violations,complexity"
This is an example with measures. Be sure to check the required parameters.

Passing code from CodePipeline to PythonFunction

I'm trying to create a CDK app that will deploy a pipeline-stack and a lambda-stack. Similar to the tutorial here. I'm trying to implement a basic CI/CD application that is triggered with every push to a Github Enterprise Repo.
I chose to use PythonFunction from (#aws-cdk/aws-lambda-python) instead of function from #aws-cdk/aws-lambda because PythonFunction builds the dependencies from requirements.txt. I have various lambdas that use different packages (like awswrangler, pandas, requests, etc.).
But, PythonFunction does not support CfnParametersCode (Where the code is passed through CDK instead of being read from an asset).
What other option do I have to pass my code from GithubEnterprise to
the PythonFunction?
If function from #aws-cdk/aws-lambda is the only option I have, how
can I include the packages from requirements.txt
This does seem like an option for #aws-cdl/aws-lambda, but how would I pass my code from Github? This example relates to building from asset code.
I apologize if I'm missing something obvious, I just started working with AWS CDK last week.
First of all I would recommend to take a look at pipelines.CdkPipeline which is able to deal with Assets. That means you can directly use lambda.Code.from_asset instead of overriding CfnParametersCode in the Pipeline.
Regarding your other question, you can deal with the requirements by installing them into your lambda folder during the build step with: pip install -r requirements.txt -t .
CfnParametersCode gives you the ability to upload your code from an S3 file.
You can do the same via lambda.Code.fromBucket.
Taking your link from the third point (https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda#bundling-asset-code) You just need to use lambda.Code.fromBucket instead of code: lambda.Code.fromAsset. Docs can be found here: https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda

How can I produce github annotations by creating report files on disk?

I am trying to find a portable way to produce code annotations for GitHub in a way that would avoid a vendor-lockin.
Mainly I want to dump annotations inside a file (yaml, json,...) during build process and have a task at the end that does transform this file into github annotations.
The main goal here is to avoid hardcoding support for github-annotation into the tools that produce them, so other CI/CD systems could also consume the annotation-reports and display them in their UI.
linters -> annotations.report -> github-upload
Tools like flake8 are able to produce output in parsable format file:line:column: message, but I need to know if there is any attempt to standardize annotations so we can collect and combine them from multiple tools and feed them to the CI/CD engine.
Today I googled up what the heck those "Github Action Annotations" are all, and this was among the hits:
https://github.com/marketplace/actions/annotations-action
GitHub action for creating annotations from JSON file
As of now that page also contains:
This repository uses npm packages from #attest scope on github; we are working hard to open source these packages.
Annotations Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.
I didn't try it, again, just a random google hit.
I am currently using https://github.com/yuzutech/annotations-action
Sample action code:
- name: Annotate
uses: yuzutech/annotations-action#v0.3.0
with:
repo-token: ${{secrets.GITHUB_TOKEN}}
input: ./annotations.json
title: 'Findings'
ignore-missing-file: true
It does its job well but with one minor defect. If you have a findings on a commit/PR you get to see the finding with a beautiful annotation right where you need it. If you re-push changes, even if the finding persists, the annotation is not displayed on later commits. I have opened an issue but I have not yet received an answer.
The annotations-action mentioned above has not been updated and it does not work with me at all (deprecated calls).
I haven't found anything else that worked exactly as I wanted it to.
Update: I found that you can use reviewdog to annotate based on findings. I also created a GitHub action that can be used for Static Code Analysis here https://github.com/tsigouris007/action-semgrep-reviewdog. You can visit the entrypoint.sh file and check how I piped the custom output to reviewdog utilizing jq.

Teamcity REST URL for getting tags

I'd like to get the url to access the tags on a build
we're running TeamCity 6.0.2
so far I can get to the build xml with
http://teamcity/httpAuth/app/rest/buildTypes/id:bt12/builds/number:1.0.0.990
but adding /tags to the end won't give me just the tags xml
I've gone thru the REST documentation but haven't found a combination that worked
The end goal is to PUT tags onto a specific build
UPDATE:
you have to specify the buildType in the bit of the url. here's the one that works
http://teamcity/httpAuth/app/rest/builds/buildType:bt12,number:1.0.0.990/tags
I think you misread the spec. The /tags is only allowed for one specific build and therefor I guess the /tags cannot be used on /buildTypes
Can you try this, assuming the id:bt12 gives you a specific build...
http://teamcity/httpAuth/app/rest/builds/id:bt12/tags/

Resources