GithubHelp home page GithubHelp logo

codecov / uploader Goto Github PK

View Code? Open in Web Editor NEW
104.0 18.0 74.0 6.56 MB

Codecov's universal binary uploader.

Home Page: https://docs.codecov.com/docs/codecov-uploader

License: Apache License 2.0

Makefile 0.26% JavaScript 0.72% Shell 0.05% TypeScript 98.98%
hacktoberfest

uploader's Introduction

Codecov Uploader

CircleCI codecov FOSSA Status Total alerts

Usage

To see how to use this uploader, please visit our documentation.

!!! The project requires npm v7. You can check which version you have via npm --version. If you need to update it, run npm install --global npm (you should only need to do this once).

  • The project requires Node.js v16
  • If nvm is installed, your node version should change to the development version the repository is set to automatically; nvm is by no means necessary, however
  1. Run npm install once you get in the repository and after every branch change, etc.
  • npm run test to run the tests
  • npm run build to verify the source code can be built

  • npm run build-linux to generate the final binary for use on Linux
  • npm run build-macos to generate the final binary for use on macOS
  • npm run build-windows to generate the final binary for use on Windows

Additionally, you can run the uploader without actually doing a full build via:

  • npm run build which generates the final JavaScript
  • node dist/bin/codecov.js

Steps to develop

  • make clean
  • make install
  • make build

Note: make build does not currently build the Windows binary until I confirm that a Windows binary build under Linux works. It also does not build the Alpine binary, as that needs to be build in an alpine container, using a static build of NodeJS. To build the Windows binary, run npm run build-windows

Binaries for Windows, MacOS, and Linux will be in the out/ directory.

License

FOSSA Status .

uploader's People

Contributors

adrian-codecov avatar debayande avatar drazisil avatar drazisil-codecov avatar eddiemoore avatar eliatcodecov avatar flamefire avatar fossabot avatar gabrielrussoc avatar giovanni-guidini avatar jimmy-lee avatar joseph-sentry avatar kleisauke avatar matt-codecov avatar michael-codecov avatar mitchell-codecov avatar montross50 avatar mrjaeger avatar patil2099 avatar quinnturner avatar ra80533 avatar renovate-bot avatar renovate[bot] avatar samdoran avatar sbeidas avatar snyk-bot avatar thomasrockhu avatar thomasrockhu-codecov avatar vihangm avatar webknjaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uploader's Issues

[CE-2800] Default to cwd with warning when .git is not located

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

When running the uploader in docker, or other places where there is no .git dir, it fails

Describe the solution you'd like
A clear and concise description of what you want to happen.

Default to cwd with warning when .git is not located

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Using the -R flag works

Additional context
Add any other context or screenshots about the feature request here.

[CE-2897] Upload does not add EOF separator with multiple files

Describe the bug
A clear and concise description of what the bug is.

Upload does not add EOF separator with multiple files

To Reproduce
Steps to reproduce the behavior:

  • Attempt use uploader with more than one overage file

Expected behavior
A clear and concise description of what you expected to happen.

  • Expected to work, not fail processing on the server.

The uploader receives bad requests when setting CI env in GitHub actions

Describe the bug
When I run the codecov uploader in the docker container, everything is fine until I set up environment variables using the first technique mentioned in the following article:
https://docs.codecov.com/docs/testing-with-docker

Then the uploader complains about bad requests:

Detected GitHub Actions as the CI provider.
Pinging Codecov: https://codecov.io/upload/v4?package=uploader-0.1.0&token=*******&branch=test/migrate-to-shellspec&build=1039293011&build_url=undefined%2Fdustin71728%2Fyarn-2-completion%2Factions%2Fruns%2F1039293011&commit=24eb740b7574622e2af937f65c74e97292ab9448&job=default&pr=&service=github-actions&slug=dustin71728/yarn-2-completion&name=&tag=&flags=&parent=
https://codecov.io/upload/v4?package=uploader-0.1.0&branch=test/migrate-to-shellspec&build=1039293011&build_url=undefined%2Fdustin71728%2Fyarn-2-completion%2Factions%2Fruns%2F1039293011&commit=24eb740b7574622e2af937f65c74e97292ab9448&job=default&pr=&service=github-actions&slug=dustin71728/yarn-2-completion&name=&tag=&flags=&parent=
        Content-Type: 'text/plain'
        Content-Encoding: 'gzip'
        X-Reduced-Redundancy: 'false'
Error!: Error: Error uploading to https://codecov.io: Error: Error uploading to Codecov: Error: Bad Request

I wonder if the root cause is that the build_url query parameter is not a well-formatted URL. It is a literal undefined string in the host part of the URL.

So I try to set up CI_BUILD_URL with the correct value, but it still doesn't work.
The failed log( In Run yarn test step):
https://github.com/dustin71728/yarn-2-completion/runs/3091016225?check_suite_focus=true

The log printed out all the environment variables returned from the command:
"ci_env=bash <(curl -s https://codecov.io/env)"
https://github.com/dustin71728/yarn-2-completion/runs/3090999690?check_suite_focus=true

The successful log without CI environment variables involved:
https://github.com/dustin71728/yarn-2-completion/runs/3081701233?check_suite_focus=true

References
Dockerfile: https://github.com/dustin71728/yarn-2-completion/blob/test/migrate-to-shellspec/docker/bash-5-0.Dockerfile
Github Action YAML file: https://github.com/dustin71728/yarn-2-completion/blob/test/migrate-to-shellspec/.github/workflows/default.yaml

Expected behavior
The uploader should upload the coverage report when the CI is true in the docker container running on Github action.

codecov-linux.SHA256SUM is currently invalid

codecov uploader for linux shasum failing - both on Travis CI - and have also replicated locally

shasum -a 256 -c codecov-linux.SHA256SUM
shasum: codecov: 
codecov: FAILED open or read
shasum: WARNING: 1 listed file could not be read

Originally setup using the instructions from https://docs.codecov.com/docs/codecov-uploader

Example of recent failure on travis:
https://travis-ci.com/github/silverstripe/silverstripe-assets/jobs/519946430#L1024

Travis config used for codecov:
https://github.com/silverstripe/silverstripe-travis-shared/blob/master/config/base.yml#L122

Looks like this has been failing for at least the last 3 hours (around 12:30am 29 June GMT), was working fine 18 hours ago (around 9:30am 28 June GMT)

Example of this working correctly 18 hours ago:
https://travis-ci.com/github/silverstripe/cwp-agencyextensions/jobs/519612481#L1098

The Codecov uploader doesn't work in Docker containers that runs in TeamCity with corporate proxy

Describe the bug

Pinging Codecov: https://codecov.io/upload/v4?package=uploader-0.1.0&token=*******&branch=undefined&build=&build_url=&commit=75607b5fa42ddbaf29f3cc80593de9a1c71a9b6b&job=&pr=&service=teamcity&slug=&name=&tag=&flags=&parent=
Error!: Error: Error uploading to https://codecov.io: Error: Error uploading to Codecov: Error: connect ETIMEDOUT 34.120.215.12:443

To Reproduce
Steps to reproduce the behavior:

  1. Download codecov from curl -Os https://uploader.codecov.io/latest/linux/codecov
  2. Run docker container in TeamCity using codecov env script
# request codecov to detect CI environment to pass through to docker
ci_env=`bash <(curl -s https://codecov.io/env)`
docker run $ci_env -e CI=true ...
 |----- inside docker container
 | # exec tests
 | # Your Codecov Uploader approach here
 | # See more at https://docs.codecov.com/docs/codecov-uploader
 | ./codecov

Expected behavior
Bash uploader works well in the case.

Judging by parameters of the query string and by https://github.com/codecov/uploader/blob/master/src/ci_providers/provider_teamcity.js file, the new uploader does not work with TeamCity variables defined by env script:

elif [ "$TEAMCITY_VERSION" != "" ];
then
  add "TEAMCITY_VERSION"
  add "TEAMCITY_BUILD_BRANCH"
  add "TEAMCITY_BUILD_ID"
  add "TEAMCITY_BUILD_URL"
  add "TEAMCITY_BUILD_COMMIT"
  add "TEAMCITY_BUILD_COMMIT"
  add "BUILD_VCS_NUMBER"
  add "TEAMCITY_BUILD_REPOSITORY"

Version of env script - 1.0.3 (Also note, that line add "TEAMCITY_BUILD_COMMIT" is repeated twice - maybe typo)

Buildkite Support for Binary Uploader

Describe the solution you'd like
Please add Buildkite as a supported CI.

Additional context
It's supported by bash uploader so assume just need simple migration?

feat: add metadata for vcs

Ask: Codecov is lacking data to know how often mercual is being used with Codecov. To that end, I would like to add a vcs= quesrystring param to indicate if git or hg was used.

#182 (comment)

Prettier and lint-staged compete against each other

  1. Save a file targeted by Prettier
    It will be modified to conform with the configured Prettier presets.
  2. Save the modifications made by Prettier
    Prettier will run again but make no changes.
  3. Stage and commit the change(s) made by Prettier
    lint-staged will modify the staged commits to conform with its own presets.

Use local provider when matching CI one is not found

Describe the bug
Use local provider when matching CI one is not found

To Reproduce
Steps to reproduce the behavior:

  1. Try running on a CI provider we don't support yet

Expected behavior
Do not fail on undetected CI provider.

Use environment detection to source arguments as a fallback if values for `args` aren't given

There's a lot of duplicated logic occurring within the plugin system modeling cloud providers. Specifically, there's some fallback behavior occurring in each one which could be moved up towards the area which calls the providers in order to simplify the logic in the providers and centralize the fallback behavior in general.

Before (2bfb124)

/// @file main.js
// Requires at least one test
function getParams(inputs) {
  return {
    something: provider.getSomething(inputs)
  };
}

/// @file provider-a.js
// Requires at least two tests
function getSomething(inputs) {
  return inputs.args.something || inputs.envs["PROVIDER_A_VALUE"];
}

/// @file provider-b.js
// Requires at least two tests
function getSomething(inputs) {
  return inputs.args.something || inputs.envs["PROVIDER_B_VALUE"];
}

/// @file provider-c.js
// Requires at least two tests
function getSomething(inputs) {
  return inputs.args.something || inputs.envs["PROVIDER_C_VALUE"];
}

After

/// @file main.js
// Requires at least two tests
function getParams(inputs) {
  return {
    something: inputs.args.something || provider.getSomething(inputs)
  };
}

/// @file provider-a.js
// Requires at least one test
function getSomething(inputs) {
  return inputs.envs["PROVIDER_A_VALUE"];
}

/// @file provider-b.js
// Requires at least one test
function getSomething(inputs) {
  return inputs.envs["PROVIDER_B_VALUE"];
}

/// @file provider-c.js
// Requires at least one test
function getSomething(inputs) {
  return inputs.envs["PROVIDER_C_VALUE"];
}

Errors not being displayed in output files

Describe the bug
The exit errors are not be saved in the output log.

To Reproduce
Steps to reproduce the behavior:

  1. run uploader in a condition that would exit with an error
  2. redirect the output to a file > output.txt
  3. Observe that exit message was not saved

Expected behavior
All console output should end up in the output file.

Desktop (please complete the following information):

  • OS: Windows

tests should not rely on environmental state

Describe the bug
A clear and concise description of what the bug is.

Unit tests need to be isolated. The branch detection tests will fail if git is not installed.

To Reproduce
Steps to reproduce the behavior:

  1. Run npm test on a machine that does not have git installed.

Expected behavior
A clear and concise description of what you expected to happen.

Test should use passed envs and not be affected by outside state.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Find a faster way to build and test alpine

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Currently, due to needing to build node on every run for the alpine binary, the build cycles take a long time (~35 minutes). This hampers rapid progress, in addition to likely annoying our CI provider. (we are likely to run out of free credits)

Describe the solution you'd like
A clear and concise description of what you want to happen.

Faster build cycles

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Moving the binaries to the deploy only stage. Not a good plan, as the binary build process could break and we may have many changes in before we discover this.

Additional context
Add any other context or screenshots about the feature request here.

Suggestions wanted.

Do not upload binary files

Describe the bug
A clear and concise description of what the bug is.

In windows, the codecov.exe binary is detected as a coverage report and uploaded, causing the Codecov server to fail to process the "report"

To Reproduce
Steps to reproduce the behavior:

https://2910-223286392-gh.circle-artifacts.com/0/output_win.txt

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Flags not working when they contain a period

Describe the bug
A clear and concise description of what the bug is.

The -F command line flag is not working correctly. Flag used was 12.x.v2

To Reproduce
Steps to reproduce the behavior:

  • Attempt to upload using the -F flags option

Expected behavior
A clear and concise description of what you expected to happen.

Flags are shown in the UI and the PR comment

https://codecov.io/gh/drazisil/sigdb/commit/ddfcff46193dd3c19ef15d3673d4c27840beb18a/build

image

drazisil/sigdb@ddfcff4

Confirm all flags are added

  • -h Display this help and exit

The globbing on this is strange Need to test the ! masks work

  • -f FILE Target file(s) to upload
    -f "path/to/file" only upload this file
    skips searching unless provided patterns below
    -f '!*.bar' ignore all files at pattern .bar
    -f '
    .foo' include all files at pattern .foo
    Must use single quotes.
    This is non-exclusive, use -s "
    .foo" to match specific paths.

  • -s DIR Directory to search for coverage reports.
    Already searches project root and current working directory #89

  • -t TOKEN Set the private repository token
    (option) set environment variable CODECOV_TOKEN=:uuid
    -t @/path/to/token_file
    -t uuid

  • -n NAME Custom defined name of the upload. Visible in Codecov UI #75

  • -X feature Toggle functionalities

  • -e ENV Specify environment variables to be included with this build
    Also accepting environment variables: CODECOV_ENV=VAR,VAR2
    -e VAR,VAR2 #75

  • -X search Disable searching for reports

  • -X network Disable uploading the file network

  • -N The commit SHA of the parent for which you are uploading coverage. If not present,
    the parent will be determined using the API of your repository provider.
    When using the repository provider's API, the parent is determined via finding
    the closest ancestor to the commit. #87

  • -R root dir Used when not in git/hg project to identify project root directory


  • -F flag Flag the upload to group coverage metrics
    -F unittests This upload is only unittests
    -F integration This upload is only integration tests
    -F ui,chrome This upload is Chrome - UI tests
  • -c Move discovered coverage reports to the trash
  • -Z Exit with 1 if not successful. Default will Exit with 0
  • -v Verbose mode
    -- Override CI Environment Variables --
    These variables are automatically detected by popular CI providers
  • -B branch Specify the branch name
  • -C sha Specify the commit sha
  • -P pr Specify the pull request number
  • -b build Specify the build number
  • -T tag Specify the git tag
    -- Enterprise --
  • -u URL Set the target url for Enterprise customers
    Not required when retrieving the bash uploader from your CCE
    (option) Set environment variable CODECOV_URL=https://my-hosted-codecov.com
  • -r SLUG owner/repo slug used instead of the private repo token in Enterprise
    (option) set environment variable CODECOV_SLUG=:owner/:repo
    (option) set in your codecov.yml "codecov.slug"
  • -S PATH File path to your cacert.pem file used to verify ssl with Codecov Enterprise (optional)
    (option) Set environment variable: CODECOV_CA_BUNDLE="/path/to/ca.pem"
    -- Debugging --
  • -d Don't upload, but dump upload file to stdout

We don't use curl, so probably unneeded

  • -U curlargs Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy"
  • -A curlargs Extra curl arguments to communicate with AWS.

=== All flags below apply to functionality I would prefer to not carry over as it either modifies customer reports prior to upload, or otherwise runs magic that is not clear and prone to confusion ===

  • -X gcovout Disable gcov output
  • -X gcov Disable gcov
  • -X coveragepy Disable python coverage
  • -X fix Disable report fixing
  • -X xcode Disable xcode processing

I'd like to remove xcode functionally and make this a pure uploader

-- xcode --
  • -D Custom Derived Data Path for Coverage.profdata and gcov processing
    Default '~/Library/Developer/Xcode/DerivedData'
  • -J Specify packages to build coverage.
    This can significantly reduces time to build coverage reports.
    -J 'MyAppName' Will match "MyAppName" and "MyAppNameTests"
    -J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests"

I'd like to remove gcov functionally and make this a pure uploader

-- gcov --
  • -g GLOB Paths to ignore during gcov gathering
  • -G GLOB Paths to include during gcov gathering
  • -p dir Project root directory
    Also used when preparing gcov
  • -k prefix Prefix filepaths to help resolve path fixing
  • -x gcovexe gcov executable to run. Defaults to 'gcov'
  • -a gcovargs extra arguments to pass to gcov


This can probably be removed as I'm not using color

  • -K Remove color from the output

[CODE-874] New uploader is unable to find and upload coverage reports from Xcode

Describe the bug
The new uploader fails to find coverage reports from Xcode.

To Reproduce

  1. git clone https://github.com/chris-araman/CombineCloudKit.git
  2. cd CombineCloudKit
  3. swift package generate-xcodeproj
  4. xcodebuild test -enableCodeCoverage YES -scheme CombineCloudKit-Package
  5. bin/codecov -n -Q github-action-2.0.1 -Z

Expected behavior
The coverage report is found and uploaded successfully.

Additional context
codecov-action@v2 uses the new uploader. codecov-action@v1 used the old bash uploader. The new uploader fails to find coverage reports from Xcode when the bash uploader found them successfully. I encountered this issue when attempting to migrate from codecov-action@v1 to @v2.

It seems this functionality was implemented in the bash uploader here:
https://github.com/codecov/codecov-bash/blob/ae76691c8554334bc1ddc355f6667fd36d6890f5/codecov#L1148

There are notes in #15 about wanting to keep this project a "pure uploader". I think separating the concerns of the uploader from the concerns of something processing reports is admirable. However, I think this sort of boilerplate logic is useful to users of the uploader. Perhaps it can be ported to a more coverage-friendly environment (Node.js, Typescript) alongside the uploader functionality, even if it's in a separate module?

This issue is preventing me from migrating to the new uploader via codecov-action@v2.

Does not scan for files on OSX or Windows

Describe the bug
A clear and concise description of what the bug is.

While the uploader can correctly locate files without a .git directory, it appears unable to on Windows and OSX

To Reproduce
Steps to reproduce the behavior:

  1. Run the uploader in a directory that is not a git repo, or a child of one.

Expected behavior
A clear and concise description of what you expected to happen.

Should be able to locate report files, similar to on Linux https://app.circleci.com/pipelines/github/codecov/uploader/445/workflows/27d617a9-1375-4fdb-b077-39922becdf57/jobs/2686

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Purpose of the patches folder

It appears that the project is going through all the steps that pkg does—downloading the Node.js source, applying a set of patches to allow "sourceless" compilation, building the patched version of Node.js from source, etc.

Was there a particular design decision that gave weight to doing all the heavy work even though pkg is also used? Is this simply a relic of early development that will be moved away from in the future?

-f flag can not handle an absolute path

Describe the bug
-f flag can not handle an absolute path. Since it appends ./ to the path, the path becomes invalid

To Reproduce
Steps to reproduce the behavior:

  1. Pass the -f flag a file path that starts with /
  2. See error

Expected behavior
If the passed path starts with a / the app should not prefix with ./

Screenshots
image

-R is currently being used as both `s and `R

From #15

-s DIR Directory to search for coverage reports.
Already searches project root and current working directory

We are currently using the -R flag for both the -s and -R` uses.

@codecov/open-source can we clearly define the use cases for each flag so we can determine how best to seperate them?

Flags with dashes not supported

Describe the bug
A clear and concise description of what the bug is.

When passed a flag with dashes in the name, the uploader passes an empty flag to the server

To Reproduce
Steps to reproduce the behavior:
Call uploader with -F linux-without-git

Expected behavior
A clear and concise description of what you expected to happen.

Flag is passed to the server

Screenshots
If applicable, add screenshots to help explain your problem.

https://app.circleci.com/pipelines/github/codecov/uploader/445/workflows/27d617a9-1375-4fdb-b077-39922becdf57/jobs/2686#tests/containers/0

Additional context
Add any other context about the problem here.

`validateFileNamePath` is too restrictive

Solution

Allow the underlying process attempting to read the file to perform validation. Invalid files at that level will report back via a thrown error which can then be displayed to the user.

Benefits

  • Less code
  • Improve correctness

Scan paths and suggest path fixes

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
If paths in the report and the repo do not match, would love a suggested path fix

Describe alternatives you've considered
Manually creating path fixes

Additional context
N/A

Error: Method Not Allowed

We started getting this error message today.

  Codecov report uploader 0.1.0
=> Project root located at: /opt/atlassian/pipelines/agent/build
Processing reports/XXXXXXXXXXX.xml...
Detected Bitbucket as the CI provider.
Pinging Codecov: https://codecov.io/upload/v4?package=uploader-0.1.0&token=*******&branch=XXXXXXXXXXXXX&build=140&build_url=&commit=cc70d0cf1e1ca2a00f7979c96ffed1a30b1b3076&job=140&pr=&service=bitbucket&slug=XXXXXXXXXXX&name=&tag=&flags=&parent=
Error!: Error: Error uploading to https://codecov.io: Error: Error uploading to Codecov: Error: Method Not Allowed

Investigate testing each providor separately

While I would like to be able to auto-test new CI providors, I think that, given the differences in how things like slugs and SHAs are computed from args and envs, it makes more sense to test each separately.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.