|
| 1 | +--- |
| 2 | +# yamllint disable rule:line-length |
1 | 3 | name: 'Codecov'
|
2 | 4 | description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
3 |
| -author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov' |
| 5 | +author: 'Thomas Hu <@thomasrockhu-codecov> | Codecov' |
4 | 6 | inputs:
|
5 |
| - token: |
6 |
| - description: 'Repository Codecov token. Used to authorize report uploads' |
7 |
| - required: false |
8 |
| - codecov_yml_path: |
9 |
| - description: 'Specify the path to the Codecov YML' |
| 7 | + binary: |
| 8 | + description: 'The file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed.' |
10 | 9 | required: false
|
11 | 10 | commit_parent:
|
12 |
| - description: 'Override to specify the parent commit SHA' |
| 11 | + description: 'SHA (with 40 chars) of what should be the parent of this commit.' |
13 | 12 | required: false
|
14 | 13 | directory:
|
15 |
| - description: 'Directory to search for coverage reports.' |
| 14 | + description: 'Folder to search for coverage files. Default to the current working directory' |
16 | 15 | required: false
|
17 | 16 | disable_file_fixes:
|
18 |
| - description: 'Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)' |
| 17 | + 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' |
19 | 18 | required: false
|
| 19 | + default: 'false' |
20 | 20 | disable_search:
|
21 |
| - description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option.' |
| 21 | + description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the files option.' |
22 | 22 | required: false
|
| 23 | + default: 'false' |
23 | 24 | disable_safe_directory:
|
24 | 25 | description: 'Disable setting safe directory. Set to true to disable.'
|
25 | 26 | required: false
|
| 27 | + default: 'false' |
26 | 28 | dry_run:
|
27 | 29 | description: "Don't upload files to Codecov"
|
28 | 30 | required: false
|
| 31 | + default: 'false' |
29 | 32 | env_vars:
|
30 | 33 | description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
31 | 34 | required: false
|
32 | 35 | exclude:
|
33 |
| - description: 'Folders to exclude from search' |
| 36 | + description: 'Comma-separated list of folders to exclude from search.' |
34 | 37 | required: false
|
35 | 38 | fail_ci_if_error:
|
36 |
| - description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload' |
37 |
| - required: false |
38 |
| - file: |
39 |
| - description: 'Path to coverage file to upload' |
| 39 | + description: 'On error, exit with non-zero code' |
40 | 40 | required: false
|
| 41 | + default: 'false' |
41 | 42 | files:
|
42 |
| - description: 'Comma-separated list of files to upload' |
| 43 | + 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.' |
43 | 44 | required: false
|
44 | 45 | flags:
|
45 |
| - description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)' |
| 46 | + description: 'Comma-separated list of flags to upload to group coverage metrics.' |
46 | 47 | required: false
|
47 | 48 | git_service:
|
48 | 49 | description: 'Override the git_service (e.g. github_enterprise)'
|
49 | 50 | required: false
|
| 51 | + default: 'github' |
| 52 | + gcov_args: |
| 53 | + description: 'Extra arguments to pass to gcov' |
| 54 | + required: false |
| 55 | + gcov_executable: |
| 56 | + description: "gcov executable to run. Defaults to 'gcov'" |
| 57 | + required: false |
| 58 | + default: 'gcov' |
| 59 | + gcov_ignore: |
| 60 | + description: 'Paths to ignore during gcov gathering' |
| 61 | + required: false |
| 62 | + gcov_include: |
| 63 | + description: "Paths to include during gcov gathering" |
| 64 | + required: false |
50 | 65 | handle_no_reports_found:
|
51 |
| - description: 'Raise no exceptions when no coverage reports found' |
| 66 | + description: 'If no coverage reports are found, do not raise an exception.' |
52 | 67 | required: false
|
| 68 | + default: 'false' |
53 | 69 | job_code:
|
54 |
| - description: 'The job code' |
| 70 | + description: '' |
55 | 71 | required: false
|
56 | 72 | name:
|
57 |
| - description: 'User defined upload name. Visible in Codecov UI' |
| 73 | + description: 'Custom defined name of the upload. Visible in the Codecov UI' |
58 | 74 | required: false
|
59 | 75 | network_filter:
|
60 |
| - 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' |
| 76 | + 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.' |
61 | 77 | required: false
|
62 | 78 | network_prefix:
|
63 |
| - description: 'Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing' |
| 79 | + description: 'Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing.' |
64 | 80 | required: false
|
65 | 81 | os:
|
66 |
| - description: 'Override the assumed OS. Options are linux | macos | windows.' |
| 82 | + description: 'Override the assumed OS. Options available at cli.codecov.io' |
67 | 83 | required: false
|
68 | 84 | override_branch:
|
69 |
| - description: 'Specify the branch name' |
| 85 | + description: 'Specify the branch to be displayed with this commit on Codecov' |
70 | 86 | required: false
|
71 | 87 | override_build:
|
72 |
| - description: 'Specify the build number' |
| 88 | + description: 'Specify the build number manually' |
73 | 89 | required: false
|
74 | 90 | override_build_url:
|
75 | 91 | description: 'The URL of the build where this is running'
|
76 | 92 | required: false
|
77 | 93 | override_commit:
|
78 |
| - description: 'Specify the commit SHA' |
| 94 | + description: 'Commit SHA (with 40 chars)' |
79 | 95 | required: false
|
80 | 96 | override_pr:
|
81 |
| - description: 'Specify the pull request number' |
82 |
| - required: false |
83 |
| - plugin: |
84 |
| - description: 'plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all.' |
| 97 | + description: 'Specify the pull request number manually. Used to override pre-existing CI environment variables.' |
85 | 98 | required: false
|
86 | 99 | plugins:
|
87 |
| - description: 'Comma-separated list of plugins for use during upload.' |
| 100 | + description: 'Comma-separated list of plugins to run. Specify `noop` to turn off all plugins' |
88 | 101 | required: false
|
89 | 102 | report_code:
|
90 |
| - description: 'The code of the report. If unsure, do not include' |
| 103 | + 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' |
| 104 | + required: false |
| 105 | + report_type: |
| 106 | + description: 'The type of file to upload, coverage by default. Possible values are "testing", "coverage".' |
91 | 107 | required: false
|
92 |
| - root_dir: |
93 |
| - description: 'Used when not in git/hg project to identify project root directory' |
| 108 | + root_folder: |
| 109 | + description: 'Root folder from which to consider paths on the network section. Defaults to current working directory.' |
94 | 110 | required: false
|
| 111 | + skip_validation: |
| 112 | + description: 'Skip integrity checking of the CLI. This is NOT recommended.' |
| 113 | + required: false |
| 114 | + default: 'false' |
95 | 115 | slug:
|
96 |
| - description: 'Specify the slug manually (Enterprise use)' |
| 116 | + 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.' |
| 117 | + required: false |
| 118 | + swift_project: |
| 119 | + description: 'Specify the swift project name. Useful for optimization.' |
| 120 | + required: false |
| 121 | + token: |
| 122 | + description: 'Repository Codecov token. Used to authorize report uploads' |
97 | 123 | required: false
|
98 | 124 | url:
|
99 |
| - description: 'Specify the base url to upload (Enterprise use)' |
| 125 | + description: 'Set to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers.' |
100 | 126 | required: false
|
101 | 127 | use_legacy_upload_endpoint:
|
102 |
| - description: 'Use the legacy upload endpoint' |
| 128 | + description: 'Use the legacy upload endpoint.' |
103 | 129 | required: false
|
| 130 | + default: 'false' |
104 | 131 | use_oidc:
|
105 | 132 | description: 'Use OIDC instead of token. This will ignore any token supplied'
|
106 | 133 | required: false
|
| 134 | + default: 'false' |
107 | 135 | verbose:
|
108 |
| - description: 'Specify whether the Codecov output should be verbose' |
| 136 | + description: 'Enable verbose logging' |
109 | 137 | required: false
|
| 138 | + default: 'false' |
110 | 139 | version:
|
111 |
| - description: 'Specify which version of the Codecov CLI should be used. Defaults to `latest`' |
| 140 | + description: "Which version of the Codecov CLI to use (defaults to 'latest')" |
112 | 141 | required: false
|
| 142 | + default: 'latest' |
113 | 143 | working-directory:
|
114 | 144 | description: 'Directory in which to execute codecov.sh'
|
115 | 145 | required: false
|
| 146 | + |
| 147 | +steps: |
| 148 | + - run: |
| 149 | + name: Upload to Codecov |
| 150 | + command: <<include(scripts/dist/codecov.sh)>> |
| 151 | + when: << parameters.when >> |
116 | 152 | branding:
|
117 | 153 | color: 'red'
|
118 | 154 | icon: 'umbrella'
|
119 | 155 | runs:
|
120 |
| - using: 'node20' |
121 |
| - main: 'dist/index.js' |
| 156 | + using: "composite" |
| 157 | + steps: |
| 158 | + - name: Set safe directory |
| 159 | + if: ${{ inputs.set_safe_directory != 'true' }} |
| 160 | + shell: bash |
| 161 | + run: | |
| 162 | + git config --global --add safe.directory ${{ github.workspace }} |
| 163 | +
|
| 164 | + - name: Get and set token |
| 165 | + shell: bash |
| 166 | + run: | |
| 167 | + if [ ${{ inputs.use_oidc }} == 'true' ]; |
| 168 | + then |
| 169 | + # {"count":1984,"value":"***"} |
| 170 | + CODECOV_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | cut -d\' -f6) |
| 171 | + echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV |
| 172 | + else |
| 173 | + if [ -n ${{ inputs.token }} ]; |
| 174 | + then |
| 175 | + CODECOV_TOKEN=${{ inputs.token }} |
| 176 | + echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV |
| 177 | + fi |
| 178 | + fi |
| 179 | + - name: Upload coverage to Codecov |
| 180 | + run: ./dist/codecov.sh |
| 181 | + shell: bash |
| 182 | + working-directory: ${{ inputs.working-directory }} |
| 183 | + env: |
| 184 | + CC_BINARY: ${{ inputs.binary }} |
| 185 | + CC_BRANCH: ${{ inputs.override_branch }} |
| 186 | + CC_BUILD: ${{ inputs.override_build }} |
| 187 | + CC_BUILD_URL: ${{ inputs.override_build_url }} |
| 188 | + CC_CODE: ${{ inputs.report_code }} |
| 189 | + CC_DIR: ${{ inputs.directory }} |
| 190 | + CC_DISABLE_FILE_FIXES: ${{ inputs.disable_file_fixes }} |
| 191 | + CC_DISABLE_SEARCH: ${{ inputs.disable_search }} |
| 192 | + CC_DRY_RUN: ${{ inputs.dry_run }} |
| 193 | + CC_ENTERPRISE_URL: ${{ inputs.url }} |
| 194 | + CC_ENV: ${{ inputs.env_vars }} |
| 195 | + CC_EXCLUDES: ${{ inputs.exclude }} |
| 196 | + CC_FAIL_ON_ERROR: ${{ inputs.fail_ci_if_error }} |
| 197 | + CC_FILES: ${{ inputs.files }} |
| 198 | + CC_FLAGS: ${{ inputs.flags }} |
| 199 | + CC_GCOV_ARGS: ${{ inputs.gcov_args }} |
| 200 | + CC_GCOV_EXECUTABLE: ${{ inputs.gcov_executable }} |
| 201 | + CC_GCOV_IGNORE: ${{ inputs.gcov_ignore }} |
| 202 | + CC_GCOV_INCLUDE: ${{ inputs.gcov_include }} |
| 203 | + CC_GIT_SERVICE: ${{ inputs.git_service }} |
| 204 | + CC_HANDLE_NO_REPORTS_FOUND: ${{ inputs.handle_no_reports_found }} |
| 205 | + CC_JOB_CODE: ${{ inputs.job_code }} |
| 206 | + CC_LEGACY: ${{ inputs.use_legacy_upload_endpoint }} |
| 207 | + CC_NAME: ${{ inputs.name }} |
| 208 | + CC_NETWORK_FILTER: ${{ inputs.network_filter }} |
| 209 | + CC_NETWORK_PREFIX: ${{ inputs.network_prefix }} |
| 210 | + CC_NETWORK_ROOT_FOLDER: ${{ inputs.root_dir }} |
| 211 | + CC_OS: ${{ inputs.os }} |
| 212 | + CC_PARENT_SHA: ${{ inputs.commit_parent }} |
| 213 | + CC_PLUGINS: ${{ inputs.plugins }} |
| 214 | + CC_PR: ${{ inputs.override_pr }} |
| 215 | + CC_REPORT_TYPE: ${{ inputs.report_type }} |
| 216 | + CC_SHA: ${{ inputs.override_commit }} |
| 217 | + CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} |
| 218 | + CC_SLUG: ${{ inputs.slug }} |
| 219 | + CC_SWIFT_PROJECT: ${{ inputs.swift_project }} |
| 220 | + CC_TOKEN: $CODECOV_TOKEN |
| 221 | + CC_VERBOSE: ${{ inputs.verbose }} |
| 222 | + CC_VERSION: ${{ inputs.version }} |
0 commit comments