Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitHub Action that uploads coverage to Codecov ☂️

License

NotificationsYou must be signed in to change notification settings

codecov/codecov-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub MarketplaceFOSSA StatusWorkflow for Codecov Action

Easily upload coverage reports to Codecov from GitHub Actions

v5 Release

v5 of the Codecov GitHub Action will use theCodecov Wrapper to encapsulate theCLI. This will help ensure that the Action gets updates quicker.

Migration Guide

Thev5 release also coincides with the opt-out feature for tokens for public repositories. In theGlobal Upload Token section of the settings page of an organization in codecov.io, you can set the ability for Codecov to receive a coverage reports from any source. This will allow contributors or other members of a repository to upload without needing access to the Codecov token. For more details seehow to upload without a token.

[!WARNING] >The following arguments have been changed

  • file (this has been deprecated in favor offiles)
  • plugin (this has been deprecated in favor ofplugins)

The following arguments have been added:

  • binary
  • gcov_args
  • gcov_executable
  • gcov_ignore
  • gcov_include
  • report_type
  • skip_validation
  • swift_project

You can see their usage in theaction.ymlfile.

v4 Release

v4 of the Codecov GitHub Action will use theCodecov CLI to upload coverage reports to Codecov.

Breaking Changes

  • Tokenless uploading is unsupported. However, PRs made from forks to the upstream public repos will support tokenless (e.g. contributors to OSS projects do not need the upstream repo's Codecov token). For details,see our docs
  • Various arguments to the Action have been removed

Dependabot

  • For repositories usingDependabot, users will need to ensure that it has access to the Codecov token for PRs from Dependabot to upload coverage. To do this, please add yourCODECOV_TOKEN as a Dependabot Secret. For more information, see"Configuring access to private registries for Dependabot."

v3 versions and below will not have access to CLI features (e.g. global upload token, ATS).

Usage

Caution

In order for the Action to work seamlessly, you will need to havebash,curl,git, andgpg installed on your runner. You will also need to runactions/checkout before calling the Codecov action. If these are not present, the Action will fail. Github Actions runners will have these installed by default. If you are using a custom runner or running in a container, you will need to ensure that these are installed.

To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (@v5 is recommended) as astep within yourworkflow.yml file.

This Action also requires you toprovide an upload token fromcodecov.io (tip: in order to avoid exposing your token,store it as asecret).

Currently, the Action will identify linux, macos, and windows runners. However, the Action may misidentify other architectures. The OS can be specified as

  • alpine
  • alpine-arm64
  • linux
  • linux-arm64
  • macos
  • windows

Inside your.github/workflows/workflow.yml file:

steps:  -uses:actions/checkout@main  -uses:codecov/codecov-action@v5with:fail_ci_if_error:true# optional (default = false)files:./coverage1.xml,./coverage2.xml# optionalflags:unittests# optionalname:codecov-umbrella# optionaltoken:${{ secrets.CODECOV_TOKEN }}verbose:true# optional (default = false)

The Codecov token can also be passed in via environment variables:

steps:  -uses:actions/checkout@main  -uses:codecov/codecov-action@v5with:fail_ci_if_error:true# optional (default = false)files:./coverage1.xml,./coverage2.xml# optionalflags:unittests# optionalname:codecov-umbrella# optionalverbose:true# optional (default = false)env:CODECOV_TOKEN:${{ secrets.CODECOV_TOKEN }}

Important

This assumes that you've set your Codecov token insideSettings > Secrets asCODECOV_TOKEN. If not, you canget an upload token for your specific repo oncodecov.io. Keep in mind that secrets arenot available to forks of repositories.

Using OIDC

As an alternative to Codecov upload tokens, you can choose to use OIDC as your upload authentication method by setting theuse_oidc argument:

-uses:codecov/codecov-action@v5with:use_oidc:true

Any token supplied will be ignored, as Codecov will default to the OIDC token for verification.

Note that the codecov action must have write permission forid-token for this to work:

permissions:id-token:write

This can be set at either the workflow or job level. See GitHub'sdocs for more details.

Arguments

Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:

InputDescriptionRequired
base_sha'The base SHA to select. This is only used in the "pr-base-picking" run command'Optional
binaryThe file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed.Optional
codecov_yml_pathThe location of the codecov.yml file. This is currently ONLY used for automated test selection (https://docs.codecov.com/docs/getting-started-with-ats). Note that for all other cases, the Codecov yaml will need to be located as described here:https://docs.codecov.com/docs/codecov-yaml#can-i-name-the-file-codecovymlOptional
commit_parentSHA (with 40 chars) of what should be the parent of this commit.Optional
directoryFolder to search for coverage files. Default to the current working directoryOptional
disable_file_fixesDisable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets). Read more herehttps://docs.codecov.com/docs/fixing-reportsOptional
disable_searchDisable search for coverage files. This is helpful when specifying what files you want to upload with the files option.Optional
disable_safe_directoryDisable setting safe directory. Set to true to disable.Optional
disable_telemDisable sending telemetry data to Codecov. Set to true to disable.Optional
dry_runDon't upload files to CodecovOptional
env_varsEnvironment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)Optional
excludeComma-separated list of folders to exclude from search.Optional
fail_ci_if_errorOn error, exit with non-zero codeOptional
filesComma-separated explicit list of files to upload. These will be added to the coverage files found for upload. If you wish to only upload the specified files, please consider using "disable-search" to disable uploading other files.Optional
flagsComma-separated list of flags to upload to group coverage metrics.Optional
forceOnly used for empty-upload run commandOptional
git_serviceOverride the git_service (e.g. github_enterprise)Optional
gcov_argsExtra arguments to pass to gcovOptional
gcov_executablegcov executable to run. Defaults to 'gcov'Optional
gcov_ignorePaths to ignore during gcov gatheringOptional
gcov_includePaths to include during gcov gatheringOptional
handle_no_reports_foundIf no coverage reports are found, do not raise an exception.Optional
job_codeOptional
nameCustom defined name of the upload. Visible in the Codecov UIOptional
network_filterSpecify a filter on the files listed in the network section of the Codecov report. This will only add files whose path begin with the specified filter. Useful for upload-specific path fixing.Optional
network_prefixSpecify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing.Optional
osOverride the assumed OS. Options available at cli.codecov.ioOptional
override_branchSpecify the branch to be displayed with this commit on CodecovOptional
override_buildSpecify the build number manuallyOptional
override_build_urlThe URL of the build where this is runningOptional
override_commitCommit SHA (with 40 chars)Optional
override_prSpecify the pull request number manually. Used to override pre-existing CI environment variables.Optional
pluginsComma-separated list of plugins to run. Specifynoop to turn off all pluginsOptional
recurse_submodulesWhether to enumerate files inside of submodules for path-fixing purposes. Off by default.Optional
report_codeThe code of the report if using local upload. If unsure, leave unset. Read more herehttps://docs.codecov.com/docs/the-codecov-cli#how-to-use-local-uploadOptional
report_typeThe type of file to upload, coverage by default. Possible values are "test_results", "coverage".Optional
root_dirRoot folder from which to consider paths on the network section. Defaults to current working directory.Optional
run_commandChoose which CLI command to run. Options are "upload-coverage", "empty-upload", "pr-base-picking", "send-notifications". "upload-coverage" is run by default.'Optional
skip_validationSkip integrity checking of the CLI. This is NOT recommended.Optional
slug[Required when using the org token] Set to the owner/repo slug used instead of the private repo token. Only applicable to some Enterprise users.Optional
swift_projectSpecify the swift project name. Useful for optimization.Optional
tokenRepository Codecov token. Used to authorize report uploadsOptional
urlSet to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers.Optional
use_legacy_upload_endpointUse the legacy upload endpoint.Optional
use_oidcUse OIDC instead of token. This will ignore any token suppliedOptional
use_pypiUse the pypi version of the CLI instead of from cli.codecov.io. If specified, integrity checking will be bypassed.Optional
verboseEnable verbose loggingOptional
versionWhich version of the Codecov CLI to use (defaults to 'latest')Optional
working-directoryDirectory in which to execute codecov.shOptional

Exampleworkflow.yml with Codecov Action

name:Example workflow for Codecovon:[push]jobs:run:runs-on:${{ matrix.os }}strategy:matrix:os:[ubuntu-latest, macos-latest, windows-latest]env:OS:${{ matrix.os }}PYTHON:"3.10"steps:      -uses:actions/checkout@main      -name:Setup Pythonuses:actions/setup-python@mainwith:python-version:"3.10"      -name:Generate coverage reportrun:|          pip install pytest          pip install pytest-cov          pytest --cov=./ --cov-report=xml      -name:Upload coverage to Codecovuses:codecov/codecov-action@v5with:directory:./coverage/reports/env_vars:OS,PYTHONfail_ci_if_error:truefiles:./coverage1.xml,./coverage2.xml,!./cacheflags:unittestsname:codecov-umbrellatoken:${{ secrets.CODECOV_TOKEN }}verbose:true

Contributing

Contributions are welcome! Check out theContribution Guide.

License

The code in this project is released under theMIT License.

FOSSA Status


[8]ページ先頭

©2009-2025 Movatter.jp