Files
codecov-action/action.yml
T

286 lines
12 KiB
YAML
Raw Normal View History

2024-11-11 10:54:09 -05:00
---
# yamllint disable rule:line-length
2019-08-06 18:02:35 -07:00
name: 'Codecov'
2019-08-07 17:04:13 -07:00
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
2024-11-11 10:54:09 -05:00
author: 'Thomas Hu <@thomasrockhu-codecov> | Codecov'
2020-04-04 14:00:57 +01:00
inputs:
2024-11-11 10:54:09 -05:00
binary:
description: 'The file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed.'
2020-07-09 23:05:11 -04:00
required: false
2024-11-13 13:18:24 -05:00
codecov_yml_path:
description: 'The location of the codecov.yml file. This is crrently 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-codecovyml'
required: false
2024-01-31 10:05:05 -08:00
commit_parent:
2024-11-11 10:54:09 -05:00
description: 'SHA (with 40 chars) of what should be the parent of this commit.'
2024-01-31 10:05:05 -08:00
required: false
2020-07-07 22:29:12 -04:00
directory:
2024-11-11 10:54:09 -05:00
description: 'Folder to search for coverage files. Default to the current working directory'
2020-07-07 22:29:12 -04:00
required: false
2024-02-26 11:31:39 -08:00
disable_file_fixes:
2024-11-11 10:54:09 -05:00
description: 'Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets). Read more here https://docs.codecov.com/docs/fixing-reports'
2024-02-26 11:31:39 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2024-02-01 09:05:17 -08:00
disable_search:
2024-11-11 10:54:09 -05:00
description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the files option.'
2024-02-01 09:05:17 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2024-02-26 11:31:39 -08:00
disable_safe_directory:
description: 'Disable setting safe directory. Set to true to disable.'
2024-02-01 09:05:17 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2021-06-24 10:50:37 -04:00
dry_run:
description: "Don't upload files to Codecov"
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2020-03-20 16:05:53 +00:00
env_vars:
2020-04-04 14:00:57 +01:00
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
2020-03-20 16:05:53 +00:00
required: false
2024-01-31 10:05:05 -08:00
exclude:
2024-11-11 10:54:09 -05:00
description: 'Comma-separated list of folders to exclude from search.'
2024-01-31 10:05:05 -08:00
required: false
2019-12-05 00:57:51 -08:00
fail_ci_if_error:
2024-11-11 10:54:09 -05:00
description: 'On error, exit with non-zero code'
2024-02-01 09:05:17 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2024-02-01 09:05:17 -08:00
files:
2024-11-11 10:54:09 -05:00
description: 'Comma-separated list of explicit 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.'
2024-02-01 09:05:17 -08:00
required: false
2024-01-31 10:05:05 -08:00
flags:
2024-11-11 10:54:09 -05:00
description: 'Comma-separated list of flags to upload to group coverage metrics.'
2022-04-04 16:14:50 -04:00
required: false
2024-02-26 11:31:39 -08:00
git_service:
description: 'Override the git_service (e.g. github_enterprise)'
required: false
2024-11-11 10:54:09 -05:00
default: 'github'
gcov_args:
description: 'Extra arguments to pass to gcov'
required: false
gcov_executable:
description: "gcov executable to run. Defaults to 'gcov'"
required: false
default: 'gcov'
gcov_ignore:
description: 'Paths to ignore during gcov gathering'
required: false
gcov_include:
description: "Paths to include during gcov gathering"
required: false
2024-02-01 09:05:17 -08:00
handle_no_reports_found:
2024-11-11 10:54:09 -05:00
description: 'If no coverage reports are found, do not raise an exception.'
2024-02-01 09:05:17 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2024-02-01 09:05:17 -08:00
job_code:
2024-11-11 10:54:09 -05:00
description: ''
2024-02-01 09:05:17 -08:00
required: false
2021-01-05 17:31:02 -05:00
name:
2024-11-11 10:54:09 -05:00
description: 'Custom defined name of the upload. Visible in the Codecov UI'
2021-01-05 17:31:02 -05:00
required: false
2024-04-09 10:53:53 -07:00
network_filter:
2024-11-11 10:54:09 -05:00
description: 'Specify 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.'
2024-04-09 10:53:53 -07:00
required: false
network_prefix:
2024-11-11 10:54:09 -05:00
description: 'Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing.'
2024-04-09 10:53:53 -07:00
required: false
2023-04-11 13:08:35 -07:00
os:
2024-11-11 10:54:09 -05:00
description: 'Override the assumed OS. Options available at cli.codecov.io'
2023-04-11 13:08:35 -07:00
required: false
2021-01-05 17:31:02 -05:00
override_branch:
2024-11-11 10:54:09 -05:00
description: 'Specify the branch to be displayed with this commit on Codecov'
2021-01-05 17:31:02 -05:00
required: false
override_build:
2024-11-11 10:54:09 -05:00
description: 'Specify the build number manually'
2021-01-05 17:31:02 -05:00
required: false
2024-02-01 09:05:17 -08:00
override_build_url:
description: 'The URL of the build where this is running'
required: false
2021-01-05 17:31:02 -05:00
override_commit:
2024-11-11 10:54:09 -05:00
description: 'Commit SHA (with 40 chars)'
2021-01-05 17:31:02 -05:00
required: false
override_pr:
2024-11-11 10:54:09 -05:00
description: 'Specify the pull request number manually. Used to override pre-existing CI environment variables.'
2024-01-31 10:05:05 -08:00
required: false
2023-09-22 17:29:50 -05:00
plugins:
2024-11-11 10:54:09 -05:00
description: 'Comma-separated list of plugins to run. Specify `noop` to turn off all plugins'
2023-09-22 17:29:50 -05:00
required: false
2024-02-01 09:05:17 -08:00
report_code:
2024-11-11 10:54:09 -05:00
description: 'The code of the report if using local upload. If unsure, leave default. Read more here https://docs.codecov.com/docs/the-codecov-cli#how-to-use-local-upload'
required: false
report_type:
description: 'The type of file to upload, coverage by default. Possible values are "testing", "coverage".'
2024-02-01 09:05:17 -08:00
required: false
2024-11-13 13:18:24 -05:00
root_dir:
2024-11-11 10:54:09 -05:00
description: 'Root folder from which to consider paths on the network section. Defaults to current working directory.'
2021-01-05 17:31:02 -05:00
required: false
2024-11-11 10:54:09 -05:00
skip_validation:
description: 'Skip integrity checking of the CLI. This is NOT recommended.'
required: false
default: 'false'
2021-06-24 10:50:37 -04:00
slug:
2024-11-11 10:54:09 -05:00
description: '[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.'
required: false
swift_project:
description: 'Specify the swift project name. Useful for optimization.'
required: false
token:
description: 'Repository Codecov token. Used to authorize report uploads'
2021-06-24 10:50:37 -04:00
required: false
2024-01-31 10:05:05 -08:00
url:
2024-11-11 10:54:09 -05:00
description: 'Set to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers.'
2024-01-31 10:05:05 -08:00
required: false
2024-02-01 09:05:17 -08:00
use_legacy_upload_endpoint:
2024-11-11 10:54:09 -05:00
description: 'Use the legacy upload endpoint.'
2024-02-01 09:05:17 -08:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
use_oidc:
description: 'Use OIDC instead of token. This will ignore any token supplied'
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
2020-10-16 18:27:17 -04:00
verbose:
2024-11-11 10:54:09 -05:00
description: 'Enable verbose logging'
2020-10-16 18:27:17 -04:00
required: false
2024-11-11 10:54:09 -05:00
default: 'false'
version:
2024-11-11 10:54:09 -05:00
description: "Which version of the Codecov CLI to use (defaults to 'latest')"
required: false
2024-11-11 10:54:09 -05:00
default: 'latest'
2023-05-03 12:12:56 -04:00
working-directory:
description: 'Directory in which to execute codecov.sh'
required: false
2024-11-11 10:54:09 -05:00
2019-08-03 07:11:50 -07:00
branding:
2020-04-04 14:00:57 +01:00
color: 'red'
2019-08-03 07:11:50 -07:00
icon: 'umbrella'
2024-11-13 14:16:55 -05:00
2019-08-05 21:19:25 -07:00
runs:
2024-11-11 10:54:09 -05:00
using: "composite"
steps:
2024-11-19 17:40:08 -05:00
- name: Action version
shell: bash
run: |
CC_ACTION_VERSION=$(cat ${GITHUB_ACTION_PATH}/src/version)
2024-11-19 17:40:08 -05:00
echo -e "\033[0;32m==>\033[0m Running Action version $CC_ACTION_VERSION"
2024-11-11 10:54:09 -05:00
- name: Set safe directory
if: ${{ inputs.disable_safe_directory != 'true' }}
2024-11-11 10:54:09 -05:00
shell: bash
run: |
git config --global --add safe.directory ${{ github.workspace }}
- name: Set fork
shell: bash
run: |
2024-12-18 15:33:42 -03:00
CC_FORK="false"
if [ -n "$GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME" ] && [ "$GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME" != "$GITHUB_REPOSITORY" ];
then
echo -e "\033[0;32m==>\033[0m Fork detected"
CC_FORK="true"
fi
2024-12-18 15:33:42 -03:00
echo "CC_FORK=$CC_FORK" >> "$GITHUB_ENV"
env:
GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
2024-11-11 10:54:09 -05:00
- name: Get and set token
shell: bash
run: |
2024-12-18 15:33:42 -03:00
if [ "${{ inputs.use_oidc }}" == 'true' ] && [ "$CC_FORK" != 'true' ];
2024-11-11 10:54:09 -05:00
then
# {"count":1984,"value":"***"}
2024-12-18 15:33:42 -03:00
echo -e "\033[0;32m==>\033[0m Requesting OIDC token from '$ACTIONS_ID_TOKEN_REQUEST_URL'"
2024-11-19 15:20:22 -05:00
CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://codecov.io" | cut -d\" -f6)
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
elif [ -n "${{ env.CODECOV_TOKEN }}" ];
then
2024-12-18 14:57:16 -03:00
echo -e "\033[0;32m==>\033[0m Token set from env"
echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV"
2024-11-11 10:54:09 -05:00
else
if [ -n "${{ inputs.token }}" ];
2024-11-11 10:54:09 -05:00
then
echo -e "\033[0;32m==>\033[0m Token set from input"
CC_TOKEN=$(echo "${{ inputs.token }}" | tr -d '\n')
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
2024-11-11 10:54:09 -05:00
fi
fi
2024-11-15 07:50:22 -05:00
- name: Override branch for forks
shell: bash
run: |
if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "$CC_FORK" == 'true' ]
2024-11-15 07:50:22 -05:00
then
2024-12-18 15:44:32 -03:00
echo -e "\033[0;32m==>\033[0m Fork detected, setting branch to $GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
2024-11-15 07:50:22 -05:00
TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
echo "TOKENLESS=$TOKENLESS" >> "$GITHUB_ENV"
2024-11-15 07:50:22 -05:00
fi
echo "CC_BRANCH=$CC_BRANCH" >> "$GITHUB_ENV"
2024-11-15 07:50:22 -05:00
env:
CC_BRANCH: ${{ inputs.override_branch }}
GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
2024-11-20 18:55:06 -05:00
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
2024-11-15 07:50:22 -05:00
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Override commits and pr for pull requests
shell: bash
run: |
if [ -z "$CC_SHA" ];
then
CC_SHA="$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA"
fi
if [ -z "$CC_PR" ] && [ "${GITHUB_EVENT_NAME}" == "pull_request_target" ];
then
CC_PR="$GITHUB_EVENT_NUMBER"
fi
echo "CC_SHA=$CC_SHA" >> "$GITHUB_ENV"
echo "CC_PR=$CC_PR" >> "$GITHUB_ENV"
env:
CC_PR: ${{ inputs.override_pr }}
CC_SHA: ${{ inputs.override_commit }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
2024-11-11 10:54:09 -05:00
- name: Upload coverage to Codecov
2024-11-13 14:16:55 -05:00
run: ${GITHUB_ACTION_PATH}/dist/codecov.sh
2024-11-11 10:54:09 -05:00
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
CC_BINARY: ${{ inputs.binary }}
CC_BUILD: ${{ inputs.override_build }}
CC_BUILD_URL: ${{ inputs.override_build_url }}
CC_CODE: ${{ inputs.report_code }}
CC_DIR: ${{ inputs.directory }}
CC_DISABLE_FILE_FIXES: ${{ inputs.disable_file_fixes }}
CC_DISABLE_SEARCH: ${{ inputs.disable_search }}
CC_DRY_RUN: ${{ inputs.dry_run }}
CC_ENTERPRISE_URL: ${{ inputs.url }}
CC_ENV: ${{ inputs.env_vars }}
CC_EXCLUDES: ${{ inputs.exclude }}
CC_FAIL_ON_ERROR: ${{ inputs.fail_ci_if_error }}
CC_FILES: ${{ inputs.files }}
CC_FLAGS: ${{ inputs.flags }}
CC_GCOV_ARGS: ${{ inputs.gcov_args }}
CC_GCOV_EXECUTABLE: ${{ inputs.gcov_executable }}
CC_GCOV_IGNORE: ${{ inputs.gcov_ignore }}
CC_GCOV_INCLUDE: ${{ inputs.gcov_include }}
CC_GIT_SERVICE: ${{ inputs.git_service }}
CC_HANDLE_NO_REPORTS_FOUND: ${{ inputs.handle_no_reports_found }}
CC_JOB_CODE: ${{ inputs.job_code }}
CC_LEGACY: ${{ inputs.use_legacy_upload_endpoint }}
CC_NAME: ${{ inputs.name }}
CC_NETWORK_FILTER: ${{ inputs.network_filter }}
CC_NETWORK_PREFIX: ${{ inputs.network_prefix }}
CC_NETWORK_ROOT_FOLDER: ${{ inputs.root_dir }}
CC_OS: ${{ inputs.os }}
CC_PARENT_SHA: ${{ inputs.commit_parent }}
CC_PLUGINS: ${{ inputs.plugins }}
CC_REPORT_TYPE: ${{ inputs.report_type }}
CC_SKIP_VALIDATION: ${{ inputs.skip_validation }}
CC_SLUG: ${{ inputs.slug }}
CC_SWIFT_PROJECT: ${{ inputs.swift_project }}
CC_VERBOSE: ${{ inputs.verbose }}
CC_VERSION: ${{ inputs.version }}
2024-11-13 13:18:24 -05:00
CC_YML_PATH: ${{ inputs.codecov_yml_path }}