mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
3 Commits
v5.5.0
...
fail-ci-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2bc7b3d58 | ||
|
|
a48be3a378 | ||
|
|
d404e59e88 |
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": [
|
||||
"google"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
@@ -1,12 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
69
.github/workflows/codeql-analysis.yml
vendored
69
.github/workflows/codeql-analysis.yml
vendored
@@ -1,69 +0,0 @@
|
||||
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '24 6 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.28.18
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3.28.18
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.28.18
|
||||
14
.github/workflows/enforce-license-compliance.yml
vendored
14
.github/workflows/enforce-license-compliance.yml
vendored
@@ -1,14 +0,0 @@
|
||||
name: Enforce License Compliance
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
enforce-license-compliance:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Enforce License Compliance'
|
||||
uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main
|
||||
with:
|
||||
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
|
||||
237
.github/workflows/main.yml
vendored
237
.github/workflows/main.yml
vendored
@@ -1,236 +1,29 @@
|
||||
---
|
||||
name: Workflow for Codecov Action
|
||||
on: [push, pull_request]
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: pip install -r src/scripts/app/requirements.txt
|
||||
run: npm install
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
- name: Run tests and collect coverage
|
||||
run: pytest src/scripts/app/ --cov
|
||||
|
||||
run: yarn run test
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: false
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||
file: ./coverage/coverage-final.json
|
||||
flags: demo
|
||||
name: codecov-demo
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-${{ matrix.os }}
|
||||
flags: script
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: demo-${{ matrix.os }}
|
||||
name: codecov-demo
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (version)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: version-${{ matrix.os }}
|
||||
name: codecov-version
|
||||
version: v9.1.0
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
run-macos-latest-xlarge:
|
||||
if: github.head.repo.full_name == 'codecov/codecov-action'
|
||||
runs-on: macos-latest-xlarge
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Install dependencies
|
||||
run: pip install -r src/scripts/app/requirements.txt
|
||||
- name: Run tests and collect coverage
|
||||
run: pytest src/scripts/app/ --cov
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-macos-latest-xlarge
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: demo-macos-latest-xlarge
|
||||
name: codecov-demo
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (oidc)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-${{ matrix.os }}
|
||||
name: codecov-script
|
||||
use_oidc: true
|
||||
verbose: true
|
||||
- name: Upload coverage to Codecov (version)
|
||||
uses: ./
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: version-maxos-latest-xlarge
|
||||
name: codecov-version
|
||||
version: v9.1.0
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
run-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: python:latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt-get update && apt-get install -y git
|
||||
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-container
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: demo-container
|
||||
name: codecov-demo
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (version)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: version-container
|
||||
name: codecov-version
|
||||
version: v9.1.0
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
run-alpine-missing-deps:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
steps:
|
||||
- name: Install only some deps (missing gpg and bash)
|
||||
run: |
|
||||
apk add git
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Upload coverage to Codecov (should fail due to missing dependencies)
|
||||
id: codecov-upload
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-alpine-missing-deps
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Verify dependency check failed
|
||||
run: |
|
||||
if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then
|
||||
echo "✓ Action correctly failed due to missing dependencies"
|
||||
exit 0
|
||||
else
|
||||
echo "✗ Action should have failed but didn't"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run-alpine-success:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
steps:
|
||||
- name: Install all required deps
|
||||
run: |
|
||||
apk add git curl gnupg bash
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Upload coverage to Codecov (should succeed)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-alpine-success
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: demo-alpine-success
|
||||
name: codecov-demo
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload coverage to Codecov (version)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
|
||||
flags: version-alpine-success
|
||||
name: codecov-version
|
||||
version: v9.1.0
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
run-alpine-partial-deps:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
steps:
|
||||
- name: Install only some deps (missing gpg and bash)
|
||||
run: |
|
||||
apk add git curl
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Upload coverage to Codecov (should fail due to missing gpg and bash)
|
||||
id: codecov-upload
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script-alpine-partial-deps
|
||||
name: codecov-script
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Verify dependency check failed
|
||||
run: |
|
||||
if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then
|
||||
echo "✓ Action correctly failed due to missing dependencies (gpg and bash)"
|
||||
exit 0
|
||||
else
|
||||
echo "✗ Action should have failed but didn't"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
62
.github/workflows/scorecards-analysis.yml
vendored
62
.github/workflows/scorecards-analysis.yml
vendored
@@ -1,62 +0,0 @@
|
||||
name: Scorecards supply-chain security
|
||||
on:
|
||||
# Only the default branch is supported.
|
||||
branch_protection_rule:
|
||||
schedule:
|
||||
- cron: '43 20 * * 1'
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
if: github.repository == 'codecov/codecov-action'
|
||||
name: Scorecards analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Used to receive a badge. (Upcoming feature)
|
||||
id-token: write
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v4.2.2 # v3.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecards on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||
|
||||
# Publish the results for public repositories to enable scorecard badges. For more details, see
|
||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories, `publish_results` will automatically be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@v3.28.18 # v1.0.26
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
||||
[submodule "src/scripts"]
|
||||
path = src/scripts
|
||||
url = https://github.com/codecov/wrapper
|
||||
branch = main
|
||||
1013
CHANGELOG.md
1013
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,12 @@
|
||||
|
||||
:tada: Thanks for taking the time to contribute! :tada:
|
||||
|
||||
The following is a set of guidelines for contributing to this repository, which is hosted in the [Codecov Organization](https://github.com/codecov) on GitHub.
|
||||
The following is a set of guidelines for contributing to this repository, which is hosted in the [Codecov Organization](https://github.com/codecov) on GitHub.
|
||||
|
||||
## What does this repo do?
|
||||
|
||||
This repo is a GitHub Action, meaning it integrates with the GitHub Actions CI/CD pipeline. It's meant to take formatted reports with code coverage stats and upload them to codecov.io. Our Node action uses the Actions toolkit to make system calls that allow us to run Codecov's bash uploader inside of Node. Essentially what we're doing in this action is downloading Codecov's bash uploader script from codecov.io/bash, saving it as a file in the current directory, executing the file via `exec` calls, then removing the script from the current directory.
|
||||
This repo is a GitHub Action, meaning it integrates with the GitHub Actions CI/CD pipeline. It's meant to take formatted reports with code coverage stats and upload them to codecov.io. Our Node action uses the Actions toolkit to make system calls that allow us to run Codecov's bash uploader inside of Node. Essentially what we're doing in this action is downloading Codecov's bash uploader script from codecov.io/bash, saving it as a file in the current directory, executing the file via `exec` calls, then removing the script from the current directory.
|
||||
|
||||
## PRs, Issues, and Support
|
||||
|
||||
Feel free to clone, modify code and request a PR to this repository. All PRs and issues will be reviewed by the Codecov team. If your PR/issue has been sitting for a while or if you have any questions, ping us at support@codecov.io
|
||||
Feel free to clone, modify code and request a PR to this repository. All PRs and issues will be reviewed by the Codecov team. If your PR/issue has been sitting for a while or if you have any questions, ping us at support@codecov.io
|
||||
|
||||
10
Makefile
10
Makefile
@@ -1,7 +1,7 @@
|
||||
deploy:
|
||||
$(eval VERSION := $(shell cat src/version))
|
||||
git tag -d v5
|
||||
git push origin :v5
|
||||
git tag v5
|
||||
git tag v$(VERSION) -s -m ""
|
||||
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
||||
git tag -d v1
|
||||
git push origin :v1
|
||||
git tag v1
|
||||
git tag v$(VERSION) -m ""
|
||||
git push origin --tags
|
||||
|
||||
257
README.md
257
README.md
@@ -1,181 +1,79 @@
|
||||
# Codecov GitHub Action
|
||||
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
||||
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
||||
|
||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||
|
||||
## v5 Release
|
||||
|
||||
`v5` of the Codecov GitHub Action will use the [Codecov Wrapper](https://github.com/codecov/wrapper) to encapsulate the [CLI](https://github.com/codecov/codecov-cli). This will help ensure that the Action gets updates quicker.
|
||||
|
||||
### Migration Guide
|
||||
|
||||
The `v5` release also coincides with the opt-out feature for tokens for public repositories. In the `Global 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 see [how to upload without a token](https://docs.codecov.com/docs/codecov-tokens#uploading-without-a-token).
|
||||
|
||||
> [!WARNING] > **The following arguments have been changed**
|
||||
>
|
||||
> - `file` (this has been deprecated in favor of `files`)
|
||||
> - `plugin` (this has been deprecated in favor of `plugins`)
|
||||
|
||||
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 the `action.yml` [file](https://github.com/codecov/codecov-action/blob/main/action.yml).
|
||||
|
||||
## v4 Release
|
||||
|
||||
`v4` of the Codecov GitHub Action will use the [Codecov CLI](https://github.com/codecov/codecov-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](https://docs.codecov.com/docs/codecov-uploader#supporting-token-less-uploads-for-forks-of-open-source-repos-using-codecov)
|
||||
- Various arguments to the Action have been removed
|
||||
|
||||
### Dependabot
|
||||
|
||||
- For repositories using `Dependabot`, 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 your `CODECOV_TOKEN` as a Dependabot Secret. For more information, see ["Configuring access to private registries for Dependabot."](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/configuring-access-to-private-registries-for-dependabot#storing-credentials-for-dependabot-to-use)
|
||||
|
||||
`v3` versions and below will not have access to CLI features (e.g. global upload token, ATS).
|
||||
>The latest release of this Action adds support for tokenless uploads from GitHub Actions!
|
||||
|
||||
## Usage
|
||||
|
||||
> [!CAUTION]
|
||||
> In order for the Action to work seamlessly, you will need to have `bash`, `curl`, `git`, and `gpg` installed on your runner. You will also need to run [actions/checkout](https://github.com/actions/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 (`@v1` is recommended) as a `step` within your `workflow.yml` file.
|
||||
|
||||
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v5` is recommended) as a `step` within your `workflow.yml` file.
|
||||
|
||||
|
||||
This Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, [store it](https://docs.codecov.com/docs/adding-the-codecov-token#github-actions) as a `secret`).
|
||||
|
||||
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
|
||||
If you have a *private repository*, this Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, store it as a `secret`). Optionally, you can choose to include up to four additional inputs to customize the upload context. **For public repositories, no token is needed**
|
||||
|
||||
Inside your `.github/workflows/workflow.yml` file:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: codecov/codecov-action@v5
|
||||
with:
|
||||
fail_ci_if_error: true # optional (default = false)
|
||||
files: ./coverage1.xml,./coverage2.xml # optional
|
||||
flags: unittests # optional
|
||||
name: codecov-umbrella # optional
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
verbose: true # optional (default = false)
|
||||
```
|
||||
|
||||
The Codecov token can also be passed in via environment variables:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: codecov/codecov-action@v5
|
||||
with:
|
||||
fail_ci_if_error: true # optional (default = false)
|
||||
files: ./coverage1.xml,./coverage2.xml # optional
|
||||
flags: unittests # optional
|
||||
name: codecov-umbrella # optional
|
||||
verbose: true # optional (default = false)
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This assumes that you've set your Codecov token inside _Settings > Secrets_ as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are _not_ 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 the `use_oidc` argument:
|
||||
|
||||
```yaml
|
||||
- uses: codecov/codecov-action@v5
|
||||
- uses: actions/checkout@master
|
||||
- uses: codecov/codecov-action@v1
|
||||
with:
|
||||
use_oidc: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||
files: ./coverage1.xml,./coverage2.xml # optional
|
||||
flags: unittests # optional
|
||||
name: codecov-umbrella # optional
|
||||
fail_ci_if_error: true # optional (default = false)
|
||||
verbose: true # optional (default = false)
|
||||
```
|
||||
|
||||
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 for `id-token` for this to work:
|
||||
|
||||
```yaml
|
||||
permissions:
|
||||
id-token: write
|
||||
```
|
||||
|
||||
This can be set at either the workflow or job level. See GitHub's [docs](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) for more details.
|
||||
>**Note**: This assumes that you've set your Codecov token inside *Settings > Secrets* as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are *not* available to forks of repositories.
|
||||
|
||||
## Arguments
|
||||
|
||||
Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:
|
||||
Codecov's Action currently supports five inputs from the user: `token`, `file`, `flags`,`name`, and `fail_ci_if_error`. These inputs, along with their descriptions and usage contexts, are listed in the table below:
|
||||
|
||||
| Input | Description | Required |
|
||||
| :--- | :--- | :---: |
|
||||
| `base_sha` | 'The base SHA to select. This is only used in the "pr-base-picking" run command' | Optional
|
||||
| `binary` | The file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed. | Optional
|
||||
| `codecov_yml_path` | The 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-codecovyml | Optional
|
||||
| `commit_parent` | SHA (with 40 chars) of what should be the parent of this commit. | Optional
|
||||
| `directory` | Folder to search for coverage files. Default to the current working directory | Optional
|
||||
| `disable_file_fixes` | 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 | Optional
|
||||
| `disable_search` | Disable search for coverage files. This is helpful when specifying what files you want to upload with the files option. | Optional
|
||||
| `disable_safe_directory` | Disable setting safe directory. Set to true to disable. | Optional
|
||||
| `disable_telem` | Disable sending telemetry data to Codecov. Set to true to disable. | Optional
|
||||
| `dry_run` | Don't upload files to Codecov | Optional
|
||||
| `env_vars` | Environment variables to tag the upload with (e.g. PYTHON \| OS,PYTHON) | Optional
|
||||
| `exclude` | Comma-separated list of folders to exclude from search. | Optional
|
||||
| `fail_ci_if_error` | On error, exit with non-zero code | Optional
|
||||
| `files` | Comma-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
|
||||
| `flags` | Comma-separated list of flags to upload to group coverage metrics. | Optional
|
||||
| `force` | Only used for empty-upload run command | Optional
|
||||
| `git_service` | Override the git_service (e.g. github_enterprise) | Optional
|
||||
| `gcov_args` | Extra arguments to pass to gcov | Optional
|
||||
| Input | Description | Usage |
|
||||
| :---: | :---: | :---: |
|
||||
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
|
||||
| `files` | Comma-separated paths to the coverage report(s) | Optional
|
||||
| `directory` | Directory to search for coverage reports. | Optional
|
||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
|
||||
| | |
|
||||
| `aws_curl_args` | Extra curl arguments to communicate with AWS. | Optional
|
||||
| `codecov_curl_args` | Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" | Optional
|
||||
| `commit_parent` | 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. | Optional
|
||||
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
||||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||
| `functionalities` | Toggle functionalities | Optional
|
||||
| | `coveragepy` Disable python coverage |
|
||||
| | `fix` Disable report fixing |
|
||||
| | `gcov` Disable gcov |
|
||||
| | `gcovout` Disable gcov output |
|
||||
| | `html` Enable coverage for HTML files |
|
||||
| | `network` Disable uploading the file network |
|
||||
| | `recursesubs` Enable recurse submodules in git projects when searching for source files | |
|
||||
| | `search` Disable searching for reports |
|
||||
| | `xcode` Disable xcode processing |
|
||||
| `gcov_path_include` | Paths to include during gcov gathering (as a glob) | Optional
|
||||
| `gcov_args` | extra arguments to pass to gcov | Optional
|
||||
| `gcov_executable` | gcov executable to run. Defaults to 'gcov' | Optional
|
||||
| `gcov_ignore` | Paths to ignore during gcov gathering | Optional
|
||||
| `gcov_include` | Paths to include during gcov gathering | Optional
|
||||
| `handle_no_reports_found` | If no coverage reports are found, do not raise an exception. | Optional
|
||||
| `job_code` | | Optional
|
||||
| `name` | Custom defined name of the upload. Visible in the Codecov UI | Optional
|
||||
| `network_filter` | 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. | Optional
|
||||
| `network_prefix` | Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing. | Optional
|
||||
| `os` | Override the assumed OS. Options available at cli.codecov.io | Optional
|
||||
| `override_branch` | Specify the branch to be displayed with this commit on Codecov | Optional
|
||||
| `override_build` | Specify the build number manually | Optional
|
||||
| `override_build_url` | The URL of the build where this is running | Optional
|
||||
| `override_commit` | Commit SHA (with 40 chars) | Optional
|
||||
| `override_pr` | Specify the pull request number manually. Used to override pre-existing CI environment variables. | Optional
|
||||
| `plugins` | Comma-separated list of plugins to run. Specify `noop` to turn off all plugins | Optional
|
||||
| `recurse_submodules` | Whether to enumerate files inside of submodules for path-fixing purposes. Off by default. | Optional
|
||||
| `report_code` | The code of the report if using local upload. If unsure, leave unset. Read more here https://docs.codecov.com/docs/the-codecov-cli#how-to-use-local-upload | Optional
|
||||
| `report_type` | The type of file to upload, coverage by default. Possible values are "test_results", "coverage". | Optional
|
||||
| `root_dir` | Root folder from which to consider paths on the network section. Defaults to current working directory. | Optional
|
||||
| `run_command` | Choose which CLI command to run. Options are "upload-coverage", "empty-upload", "pr-base-picking", "send-notifications". "upload-coverage" is run by default.' | Optional
|
||||
| `skip_validation` | Skip 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_project` | Specify the swift project name. Useful for optimization. | Optional
|
||||
| `token` | Repository Codecov token. Used to authorize report uploads | Optional
|
||||
| `url` | Set to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers. | Optional
|
||||
| `use_legacy_upload_endpoint` | Use the legacy upload endpoint. | Optional
|
||||
| `use_oidc` | Use OIDC instead of token. This will ignore any token supplied | Optional
|
||||
| `use_pypi` | Use the pypi version of the CLI instead of from cli.codecov.io. If specified, integrity checking will be bypassed. | Optional
|
||||
| `verbose` | Enable verbose logging | Optional
|
||||
| `version` | Which version of the Codecov CLI to use (defaults to 'latest') | Optional
|
||||
| `working-directory` | Directory in which to execute codecov.sh | Optional
|
||||
| `gcov_path_exclude` | Paths to ignore during gcov gathering (as a glob) | Optional
|
||||
| `gcov_prefix` | Prefix filepaths to help resolve path fixing | Optional
|
||||
| `gcov_root_dir` | Project root directory, also used when preparing gcov | Optional
|
||||
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
|
||||
| `name` | Custom defined name for the upload | Optional
|
||||
| `override_branch` | Specify the branch name | Optional
|
||||
| `override_build` | Specify the build number | Optional
|
||||
| `override_commit` | Specify the commit SHA | Optional
|
||||
| `override_pr` | Specify the pull request number | Optional
|
||||
| `override_tag` | Specify the git tag | Optional
|
||||
| `path_to_write_report` | Write upload file to path before uploading | Optional
|
||||
| `root_dir` | Used when not in git/hg project to identify project root directory | Optional
|
||||
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
||||
| `xcode_derived_data` | Custom Derived Data Path for Coverage.profdata and gcov processing | Optional
|
||||
| `xcode_package` | Specify packages to build coverage. Uploader will only build these packages. This can significantly reduces time to build coverage reports. -J 'MyAppName' Will match "MyAppName" and "MyAppNameTests" -J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests" | Optional
|
||||
|
||||
### Example `workflow.yml` with Codecov Action
|
||||
|
||||
@@ -190,31 +88,31 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
PYTHON: "3.10"
|
||||
PYTHON: '3.7'
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@main
|
||||
with:
|
||||
python-version: "3.10"
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
pip install pytest
|
||||
pip install pytest-cov
|
||||
pytest --cov=./ --cov-report=xml
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
directory: ./coverage/reports/
|
||||
env_vars: OS,PYTHON
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage1.xml,./coverage2.xml,!./cache
|
||||
flags: unittests
|
||||
name: codecov-umbrella
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
verbose: true
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
pip install pytest
|
||||
pip install pytest-cov
|
||||
pytest --cov=./ --cov-report=xml
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage1.xml,./coverage2.xml
|
||||
directory: ./coverage/reports/
|
||||
flags: unittests
|
||||
env_vars: OS,PYTHON
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: true
|
||||
path_to_write_report: ./coverage/codecov_report.txt
|
||||
verbose: true
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).
|
||||
@@ -223,4 +121,5 @@ Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).
|
||||
|
||||
The code in this project is released under the [MIT License](LICENSE).
|
||||
|
||||
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_large)
|
||||
|
||||
347
action.yml
347
action.yml
@@ -1,346 +1,103 @@
|
||||
---
|
||||
# yamllint disable rule:line-length
|
||||
name: 'Codecov'
|
||||
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
||||
author: 'Thomas Hu <@thomasrockhu-codecov> | Codecov'
|
||||
author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov'
|
||||
inputs:
|
||||
base_sha:
|
||||
description: 'The base SHA to select. This is only used in the "pr-base-picking" run command'
|
||||
token:
|
||||
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||
required: false
|
||||
binary:
|
||||
description: 'The file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed.'
|
||||
required: false
|
||||
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
|
||||
commit_parent:
|
||||
description: 'SHA (with 40 chars) of what should be the parent of this commit.'
|
||||
files:
|
||||
description: 'Comma-separated list of files to upload'
|
||||
required: false
|
||||
directory:
|
||||
description: 'Folder to search for coverage files. Default to the current working directory'
|
||||
description: 'Directory to search for coverage reports.'
|
||||
required: false
|
||||
disable_file_fixes:
|
||||
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'
|
||||
flags:
|
||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||
required: false
|
||||
default: 'false'
|
||||
disable_search:
|
||||
description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the files option.'
|
||||
aws_curl_args:
|
||||
description: 'Extra curl arguments to communicate with AWS.'
|
||||
required: false
|
||||
default: 'false'
|
||||
disable_safe_directory:
|
||||
description: 'Disable setting safe directory. Set to true to disable.'
|
||||
codecov_curl_args:
|
||||
description: 'Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy"'
|
||||
required: false
|
||||
default: 'false'
|
||||
disable_telem:
|
||||
description: 'Disable sending telemetry data to Codecov. Set to true to disable.'
|
||||
commit_parent:
|
||||
description: '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 providers API, the parent is determined via finding the closest ancestor to the commit.'
|
||||
required: false
|
||||
default: 'false'
|
||||
dry_run:
|
||||
description: "Don't upload files to Codecov"
|
||||
required: false
|
||||
default: 'false'
|
||||
env_vars:
|
||||
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||
required: false
|
||||
exclude:
|
||||
description: 'Comma-separated list of folders to exclude from search.'
|
||||
required: false
|
||||
fail_ci_if_error:
|
||||
description: 'On error, exit with non-zero code'
|
||||
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||
required: false
|
||||
default: 'false'
|
||||
files:
|
||||
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.'
|
||||
file:
|
||||
description: 'Path to coverage file to upload'
|
||||
required: false
|
||||
flags:
|
||||
description: 'Comma-separated list of flags to upload to group coverage metrics.'
|
||||
functionalities:
|
||||
description: 'Comma-separated list, see the README for options and their usage'
|
||||
required: false
|
||||
force:
|
||||
description: 'Only used for empty-upload run command'
|
||||
required: false
|
||||
git_service:
|
||||
description: 'Override the git_service (e.g. github_enterprise)'
|
||||
required: false
|
||||
default: 'github'
|
||||
gcov_args:
|
||||
description: 'Extra arguments to pass to gcov'
|
||||
description: 'extra arguments to pass to gcov'
|
||||
required: false
|
||||
gcov_executable:
|
||||
description: "gcov executable to run. Defaults to 'gcov'"
|
||||
description: 'gcov executable to run. Defaults to gcov'
|
||||
required: false
|
||||
default: 'gcov'
|
||||
gcov_ignore:
|
||||
description: 'Paths to ignore during gcov gathering'
|
||||
gcov_path_exclude:
|
||||
description: 'Paths to ignore during gcov gathering (as a glob)'
|
||||
required: false
|
||||
gcov_include:
|
||||
description: "Paths to include during gcov gathering"
|
||||
gcov_path_include:
|
||||
description: 'Paths to include during gcov gathering (as a glob)'
|
||||
required: false
|
||||
handle_no_reports_found:
|
||||
description: 'If no coverage reports are found, do not raise an exception.'
|
||||
gcov_prefix:
|
||||
description: 'Prefix filepaths to help resolve path fixing'
|
||||
required: false
|
||||
default: 'false'
|
||||
job_code:
|
||||
description: ''
|
||||
gcov_root_dir:
|
||||
description: 'Project root directory, also used when preparing gcov'
|
||||
required: false
|
||||
move_coverage_to_trash:
|
||||
description: 'Move discovered coverage reports to the trash'
|
||||
required: false
|
||||
name:
|
||||
description: 'Custom defined name of the upload. Visible in the Codecov UI'
|
||||
description: 'User defined upload name. Visible in Codecov UI'
|
||||
required: false
|
||||
network_filter:
|
||||
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.'
|
||||
required: false
|
||||
network_prefix:
|
||||
description: 'Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing.'
|
||||
required: false
|
||||
os:
|
||||
description: 'Override the assumed OS. Options available at cli.codecov.io'
|
||||
description: 'Used to restrict the set of git/hg files that can be matched with filenames in the coverage report. This is useful for monorepos or other setups where a full filepath may not be specified in the coverage report, and that shortened filepath may appear multiple times in a directory structure (e.g. __init__.py)'
|
||||
required: false
|
||||
override_branch:
|
||||
description: 'Specify the branch to be displayed with this commit on Codecov'
|
||||
description: 'Specify the branch name'
|
||||
required: false
|
||||
override_build:
|
||||
description: 'Specify the build number manually'
|
||||
required: false
|
||||
override_build_url:
|
||||
description: 'The URL of the build where this is running'
|
||||
description: 'Specify the build number'
|
||||
required: false
|
||||
override_commit:
|
||||
description: 'Commit SHA (with 40 chars)'
|
||||
description: 'Specify the commit SHA'
|
||||
required: false
|
||||
override_pr:
|
||||
description: 'Specify the pull request number manually. Used to override pre-existing CI environment variables.'
|
||||
description: 'Specify the pull request number'
|
||||
required: false
|
||||
plugins:
|
||||
description: 'Comma-separated list of plugins to run. Specify `noop` to turn off all plugins'
|
||||
override_tag:
|
||||
description: 'Specify the git tag'
|
||||
required: false
|
||||
recurse_submodules:
|
||||
description: 'Whether to enumerate files inside of submodules for path-fixing purposes. Off by default.'
|
||||
default: 'false'
|
||||
report_code:
|
||||
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 "test_results", "coverage".'
|
||||
path_to_write_report:
|
||||
description: 'Write upload file to path before uploading'
|
||||
required: false
|
||||
root_dir:
|
||||
description: 'Root folder from which to consider paths on the network section. Defaults to current working directory.'
|
||||
description: 'Used when not in git/hg project to identify project root directory'
|
||||
required: false
|
||||
run_command:
|
||||
description: 'Choose which CLI command to run. Options are "upload-coverage", "empty-upload", "pr-base-picking", "send-notifications". "upload-coverage" is run by default.'
|
||||
required: false
|
||||
default: 'upload-coverage'
|
||||
skip_validation:
|
||||
description: 'Skip integrity checking of the CLI. This is NOT recommended.'
|
||||
required: false
|
||||
default: 'false'
|
||||
slug:
|
||||
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'
|
||||
required: false
|
||||
url:
|
||||
description: 'Set to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers.'
|
||||
required: false
|
||||
use_legacy_upload_endpoint:
|
||||
description: 'Use the legacy upload endpoint.'
|
||||
required: false
|
||||
default: 'false'
|
||||
use_oidc:
|
||||
description: 'Use OIDC instead of token. This will ignore any token supplied'
|
||||
required: false
|
||||
default: 'false'
|
||||
use_pypi:
|
||||
description: 'Use the pypi version of the CLI instead of from cli.codecov.io'
|
||||
required: false
|
||||
default: 'false'
|
||||
verbose:
|
||||
description: 'Enable verbose logging'
|
||||
description: 'Specify whether the Codecov output should be verbose'
|
||||
required: false
|
||||
default: 'false'
|
||||
version:
|
||||
description: "Which version of the Codecov CLI to use (defaults to 'latest')"
|
||||
required: false
|
||||
default: 'latest'
|
||||
working-directory:
|
||||
description: 'Directory in which to execute codecov.sh'
|
||||
required: false
|
||||
|
||||
xcode_derived_data:
|
||||
description: 'Custom Derived Data Path for Coverage.profdata and gcov processing'
|
||||
required: false
|
||||
xcode_package:
|
||||
description: 'Specify packages to build coverage. Uploader will only build these packages'
|
||||
required: false
|
||||
branding:
|
||||
color: 'red'
|
||||
icon: 'umbrella'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check system dependencies
|
||||
shell: sh
|
||||
run: |
|
||||
missing_deps=""
|
||||
|
||||
# Check for required commands
|
||||
for cmd in bash git curl gpg; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
missing_deps="$missing_deps $cmd"
|
||||
fi
|
||||
done
|
||||
|
||||
# Report missing required dependencies
|
||||
if [ -n "$missing_deps" ]; then
|
||||
echo "Error: The following required dependencies are missing:$missing_deps"
|
||||
echo "Please install these dependencies before using this action."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All required system dependencies are available."
|
||||
- name: Action version
|
||||
shell: bash
|
||||
run: |
|
||||
CC_ACTION_VERSION=$(cat ${GITHUB_ACTION_PATH}/src/version)
|
||||
echo -e "\033[0;32m==>\033[0m Running Action version $CC_ACTION_VERSION"
|
||||
- name: Set safe directory
|
||||
if: ${{ inputs.disable_safe_directory != 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
git config --global --add safe.directory "${{ github.workspace }}"
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Set fork
|
||||
shell: bash
|
||||
run: |
|
||||
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
|
||||
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 }}
|
||||
|
||||
- name: Get OIDC token
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
id: oidc
|
||||
with:
|
||||
script: |
|
||||
if (process.env.CC_USE_OIDC === 'true' && process.env.CC_FORK != 'true') {
|
||||
const id_token = await core.getIDToken(process.env.CC_OIDC_AUDIENCE)
|
||||
return id_token
|
||||
}
|
||||
env:
|
||||
CC_OIDC_AUDIENCE: ${{ inputs.url || 'https://codecov.io' }}
|
||||
CC_USE_OIDC: ${{ inputs.use_oidc }}
|
||||
|
||||
- name: Get and set token
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ inputs.use_oidc }}" == 'true' ] && [ "$CC_FORK" != 'true' ];
|
||||
then
|
||||
echo "CC_TOKEN=$CC_OIDC_TOKEN" >> "$GITHUB_ENV"
|
||||
elif [ -n "${{ env.CODECOV_TOKEN }}" ];
|
||||
then
|
||||
echo -e "\033[0;32m==>\033[0m Token set from env"
|
||||
echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV"
|
||||
else
|
||||
if [ -n "${{ inputs.token }}" ];
|
||||
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"
|
||||
fi
|
||||
fi
|
||||
env:
|
||||
CC_OIDC_TOKEN: ${{ steps.oidc.outputs.result }}
|
||||
CC_OIDC_AUDIENCE: ${{ inputs.url || 'https://codecov.io' }}
|
||||
|
||||
- name: Override branch for forks
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "$CC_FORK" == 'true' ]
|
||||
then
|
||||
echo -e "\033[0;32m==>\033[0m Fork detected, setting branch to $GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
|
||||
TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
|
||||
CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
|
||||
echo "TOKENLESS=$TOKENLESS" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
echo "CC_BRANCH=$CC_BRANCH" >> "$GITHUB_ENV"
|
||||
env:
|
||||
CC_BRANCH: ${{ inputs.override_branch }}
|
||||
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 }}
|
||||
|
||||
- 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 }}
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
run: ${GITHUB_ACTION_PATH}/dist/codecov.sh
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
env:
|
||||
CC_BASE_SHA: ${{ inputs.base_sha }}
|
||||
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_DISABLE_TELEM: ${{ inputs.disable_telem }}
|
||||
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_FORCE: ${{ inputs.force }}
|
||||
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_RECURSE_SUBMODULES: ${{ inputs.recurse_submodules }}
|
||||
CC_REPORT_TYPE: ${{ inputs.report_type }}
|
||||
CC_RUN_CMD: ${{ inputs.run_command }}
|
||||
CC_SERVICE: ${{ inputs.git_service }}
|
||||
CC_SKIP_VALIDATION: ${{ inputs.skip_validation }}
|
||||
CC_SLUG: ${{ inputs.slug }}
|
||||
CC_SWIFT_PROJECT: ${{ inputs.swift_project }}
|
||||
CC_USE_PYPI: ${{ inputs.use_pypi }}
|
||||
CC_VERBOSE: ${{ inputs.verbose }}
|
||||
CC_VERSION: ${{ inputs.version }}
|
||||
CC_YML_PATH: ${{ inputs.codecov_yml_path }}
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
76
changelog.py
76
changelog.py
@@ -1,76 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
def update_changelog():
|
||||
with open('src/version', 'r') as f:
|
||||
version = f.read()
|
||||
changelog = [f"## v{version}"]
|
||||
changelog.append("### What\'s Changed")
|
||||
|
||||
with open('CHANGELOG.md', 'r') as f:
|
||||
previous = f.readline().replace("##", '').strip()
|
||||
|
||||
if previous == version:
|
||||
print(f"No changes to version {version}")
|
||||
return
|
||||
print(f"Adding logs from {previous}..v{version}")
|
||||
|
||||
raw_current_branch = subprocess.run([
|
||||
"git",
|
||||
"branch",
|
||||
"--show-current",
|
||||
], capture_output=True)
|
||||
current_branch = raw_current_branch.stdout.decode('utf-8').strip()
|
||||
|
||||
raw_commits = subprocess.run([
|
||||
"git",
|
||||
"log",
|
||||
f"{previous}..{current_branch}",
|
||||
"--oneline",
|
||||
], capture_output=True)
|
||||
commits = [line[:7] for line in raw_commits.stdout.decode('utf-8').split('\n')]
|
||||
print(commits)
|
||||
|
||||
prs = set()
|
||||
for commit in commits:
|
||||
if not commit:
|
||||
continue
|
||||
commit_output = subprocess.run([
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--json',
|
||||
'author,number,title,url',
|
||||
'--search',
|
||||
f'"{commit}"',
|
||||
'--state',
|
||||
'merged',
|
||||
], capture_output=True)
|
||||
|
||||
commit_details = commit_output.stdout.decode('utf-8')
|
||||
if not commit_details or not json.loads(commit_details):
|
||||
continue
|
||||
commit_details = json.loads(commit_details)[0]
|
||||
|
||||
|
||||
if not commit_details['number']:
|
||||
continue
|
||||
if commit_details['number'] in prs:
|
||||
continue
|
||||
prs.add(commit_details['number'])
|
||||
changelog.append(f"* {commit_details['title']} by @{commit_details['author']['login']} in {commit_details['url']}")
|
||||
|
||||
changelog.append('\n')
|
||||
changelog.append(f"**Full Changelog**: https://github.com/codecov/codecov-action/compare/{previous}..v{version}\n")
|
||||
|
||||
with open('CHANGELOG.md', 'r') as f:
|
||||
for line in f:
|
||||
changelog.append(line.strip())
|
||||
|
||||
with open('CHANGELOG.md', 'w') as f:
|
||||
f.write('\n'.join(changelog))
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
update_changelog()
|
||||
@@ -1,11 +1,11 @@
|
||||
import Calculator from './calculator';
|
||||
import Calculator from './calculator'
|
||||
|
||||
test('adds 2 + 3 to equal 5', () => {
|
||||
const calc = new Calculator();
|
||||
const calc = new Calculator()
|
||||
expect(calc.add(2, 3)).toBe(5);
|
||||
});
|
||||
|
||||
test('subtracts 2 - 3 to equal -1', () => {
|
||||
const calc = new Calculator();
|
||||
const calc = new Calculator()
|
||||
expect(calc.subtract(2, 3)).toBe(-1);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Coverage from './coverage';
|
||||
import Coverage from "./coverage";
|
||||
|
||||
test('test uncovered if', () => {
|
||||
const coverageObj = new Coverage();
|
||||
|
||||
1884
dist/codecov
vendored
Normal file
1884
dist/codecov
vendored
Normal file
File diff suppressed because it is too large
Load Diff
269
dist/codecov.sh
vendored
269
dist/codecov.sh
vendored
@@ -1,269 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set +u
|
||||
say() {
|
||||
echo -e "$1"
|
||||
}
|
||||
exit_if_error() {
|
||||
say "$r==> $1$x"
|
||||
if [ "$CC_FAIL_ON_ERROR" = true ];
|
||||
then
|
||||
say "$r Exiting...$x"
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
lower() {
|
||||
echo $(echo $1 | sed 's/CC//' | sed 's/_/-/g' | tr '[:upper:]' '[:lower:]')
|
||||
}
|
||||
k_arg() {
|
||||
if [ -n "$(eval echo \$"CC_$1")" ];
|
||||
then
|
||||
echo "--$(lower "$1")"
|
||||
fi
|
||||
}
|
||||
v_arg() {
|
||||
if [ -n "$(eval echo \$"CC_$1")" ];
|
||||
then
|
||||
echo "$(eval echo \$"CC_$1")"
|
||||
fi
|
||||
}
|
||||
write_bool_args() {
|
||||
if [ "$(eval echo \$$1)" = "true" ] || [ "$(eval echo \$$1)" = "1" ];
|
||||
then
|
||||
echo "-$(lower $1)"
|
||||
fi
|
||||
}
|
||||
b="\033[0;36m" # variables/constants
|
||||
g="\033[0;32m" # info/debug
|
||||
r="\033[0;31m" # errors
|
||||
x="\033[0m"
|
||||
retry="--retry 5 --retry-delay 2"
|
||||
CC_WRAPPER_VERSION="0.2.7"
|
||||
CC_VERSION="${CC_VERSION:-latest}"
|
||||
CC_FAIL_ON_ERROR="${CC_FAIL_ON_ERROR:-false}"
|
||||
CC_RUN_CMD="${CC_RUN_CMD:-upload-coverage}"
|
||||
CC_CLI_TYPE=${CC_CLI_TYPE:-"codecov-cli"}
|
||||
say " _____ _
|
||||
/ ____| | |
|
||||
| | ___ __| | ___ ___ _____ __
|
||||
| | / _ \\ / _\` |/ _ \\/ __/ _ \\ \\ / /
|
||||
| |___| (_) | (_| | __/ (_| (_) \\ V /
|
||||
\\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/
|
||||
$r Wrapper-$CC_WRAPPER_VERSION$x
|
||||
"
|
||||
if [[ "$CC_CLI_TYPE" != "codecov-cli" && "$CC_CLI_TYPE" != "sentry-prevent-cli" ]]; then
|
||||
echo "Invalid CC_CLI_TYPE: '$CC_CLI_TYPE'. Must be 'codecov-cli' or 'sentry-prevent-cli'"
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$CC_BINARY" ];
|
||||
then
|
||||
if [ -f "$CC_BINARY" ];
|
||||
then
|
||||
CC_FILENAME=$CC_BINARY
|
||||
CC_COMMAND=$CC_BINARY
|
||||
else
|
||||
exit_if_error "Could not find binary file $CC_BINARY"
|
||||
fi
|
||||
elif [ "$CC_USE_PYPI" == "true" ];
|
||||
then
|
||||
if ! pip install "${CC_CLI_TYPE}$([ "$CC_VERSION" == "latest" ] && echo "" || echo "==$CC_VERSION")"; then
|
||||
exit_if_error "Could not install via pypi."
|
||||
exit
|
||||
fi
|
||||
CC_COMMAND="${CC_CLI_TYPE}"
|
||||
else
|
||||
if [ -n "$CC_OS" ];
|
||||
then
|
||||
say "$g==>$x Overridden OS: $b${CC_OS}$x"
|
||||
else
|
||||
CC_OS="windows"
|
||||
family=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
[[ $family == "darwin" ]] && CC_OS="macos"
|
||||
[[ $family == "linux" ]] && CC_OS="linux"
|
||||
[[ $CC_OS == "linux" ]] && \
|
||||
osID=$(grep -e "^ID=" /etc/os-release | cut -c4-)
|
||||
[[ $osID == "alpine" ]] && CC_OS="alpine"
|
||||
[[ $(arch) == "aarch64" && $family == "linux" ]] && CC_OS+="-arm64"
|
||||
say "$g==>$x Detected $b${CC_OS}$x"
|
||||
fi
|
||||
CC_FILENAME="${CC_CLI_TYPE%-cli}"
|
||||
[[ $CC_OS == "windows" ]] && CC_FILENAME+=".exe"
|
||||
CC_COMMAND="./$CC_FILENAME"
|
||||
[[ $CC_OS == "macos" ]] && \
|
||||
! command -v gpg 2>&1 >/dev/null && \
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
|
||||
CC_URL="${CC_CLI_URL:-https://cli.codecov.io}"
|
||||
CC_URL="$CC_URL/${CC_VERSION}"
|
||||
CC_URL="$CC_URL/${CC_OS}/${CC_FILENAME}"
|
||||
say "$g ->$x Downloading $b${CC_URL}$x"
|
||||
curl -O $retry "$CC_URL"
|
||||
say "$g==>$x Finishing downloading $b${CC_OS}:${CC_VERSION}$x"
|
||||
v_url="https://cli.codecov.io/api/${CC_OS}/${CC_VERSION}"
|
||||
v=$(curl $retry --retry-all-errors -s "$v_url" -H "Accept:application/json" | tr \{ '\n' | tr , '\n' | tr \} '\n' | grep "\"version\"" | awk -F'"' '{print $4}' | tail -1)
|
||||
say " Version: $b$v$x"
|
||||
say " "
|
||||
fi
|
||||
if [ "$CC_SKIP_VALIDATION" == "true" ] || [ -n "$CC_BINARY" ] || [ "$CC_USE_PYPI" == "true" ];
|
||||
then
|
||||
say "$r==>$x Bypassing validation..."
|
||||
if [ "$CC_SKIP_VALIDATION" == "true" ];
|
||||
then
|
||||
chmod +x "$CC_COMMAND"
|
||||
fi
|
||||
else
|
||||
echo "$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)" | \
|
||||
gpg --no-default-keyring --import
|
||||
# One-time step
|
||||
say "$g==>$x Verifying GPG signature integrity"
|
||||
sha_url="https://cli.codecov.io"
|
||||
sha_url="${sha_url}/${CC_VERSION}/${CC_OS}"
|
||||
sha_url="${sha_url}/${CC_FILENAME}.SHA256SUM"
|
||||
say "$g ->$x Downloading $b${sha_url}$x"
|
||||
say "$g ->$x Downloading $b${sha_url}.sig$x"
|
||||
say " "
|
||||
curl -Os $retry --connect-timeout 2 "$sha_url"
|
||||
curl -Os $retry --connect-timeout 2 "${sha_url}.sig"
|
||||
if ! gpg --verify "${CC_FILENAME}.SHA256SUM.sig" "${CC_FILENAME}.SHA256SUM";
|
||||
then
|
||||
exit_if_error "Could not verify signature. Please contact Codecov if problem continues"
|
||||
fi
|
||||
if ! (shasum -a 256 -c "${CC_FILENAME}.SHA256SUM" 2>/dev/null || \
|
||||
sha256sum -c "${CC_FILENAME}.SHA256SUM");
|
||||
then
|
||||
exit_if_error "Could not verify SHASUM. Please contact Codecov if problem continues"
|
||||
fi
|
||||
say "$g==>$x CLI integrity verified"
|
||||
say
|
||||
chmod +x "$CC_COMMAND"
|
||||
fi
|
||||
if [ -n "$CC_BINARY_LOCATION" ];
|
||||
then
|
||||
mkdir -p "$CC_BINARY_LOCATION" && mv "$CC_FILENAME" $_
|
||||
say "$g==>$x ${CC_CLI_TYPE} binary moved to ${CC_BINARY_LOCATION}"
|
||||
fi
|
||||
if [ "$CC_DOWNLOAD_ONLY" = "true" ];
|
||||
then
|
||||
say "$g==>$x ${CC_CLI_TYPE} download only called. Exiting..."
|
||||
exit
|
||||
fi
|
||||
CC_CLI_ARGS=()
|
||||
CC_CLI_ARGS+=( $(k_arg AUTO_LOAD_PARAMS_FROM) $(v_arg AUTO_LOAD_PARAMS_FROM))
|
||||
CC_CLI_ARGS+=( $(k_arg ENTERPRISE_URL) $(v_arg ENTERPRISE_URL))
|
||||
if [ -n "$CC_YML_PATH" ]
|
||||
then
|
||||
CC_CLI_ARGS+=( "--codecov-yml-path" )
|
||||
CC_CLI_ARGS+=( "$CC_YML_PATH" )
|
||||
fi
|
||||
CC_CLI_ARGS+=( $(write_bool_args CC_DISABLE_TELEM) )
|
||||
CC_CLI_ARGS+=( $(write_bool_args CC_VERBOSE) )
|
||||
CC_ARGS=()
|
||||
if [ "$CC_RUN_CMD" == "upload-coverage" ]; then
|
||||
# Args for create commit
|
||||
CC_ARGS+=( $(write_bool_args CC_FAIL_ON_ERROR) )
|
||||
CC_ARGS+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
|
||||
CC_ARGS+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
|
||||
CC_ARGS+=( $(k_arg PR) $(v_arg PR))
|
||||
CC_ARGS+=( $(k_arg SHA) $(v_arg SHA))
|
||||
CC_ARGS+=( $(k_arg SLUG) $(v_arg SLUG))
|
||||
# Args for create report
|
||||
CC_ARGS+=( $(k_arg CODE) $(v_arg CODE))
|
||||
# Args for do upload
|
||||
CC_ARGS+=( $(k_arg ENV) $(v_arg ENV))
|
||||
OLDIFS=$IFS;IFS=,
|
||||
CC_ARGS+=( $(k_arg BRANCH) $(v_arg BRANCH))
|
||||
CC_ARGS+=( $(k_arg BUILD) $(v_arg BUILD))
|
||||
CC_ARGS+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
|
||||
CC_ARGS+=( $(k_arg DIR) $(v_arg DIR))
|
||||
CC_ARGS+=( $(write_bool_args CC_DISABLE_FILE_FIXES) )
|
||||
CC_ARGS+=( $(write_bool_args CC_DISABLE_SEARCH) )
|
||||
CC_ARGS+=( $(write_bool_args CC_DRY_RUN) )
|
||||
if [ -n "$CC_EXCLUDES" ];
|
||||
then
|
||||
for directory in $CC_EXCLUDES; do
|
||||
CC_ARGS+=( "--exclude" "$directory" )
|
||||
done
|
||||
fi
|
||||
if [ -n "$CC_FILES" ];
|
||||
then
|
||||
for file in $CC_FILES; do
|
||||
CC_ARGS+=( "--file" "$file" )
|
||||
done
|
||||
fi
|
||||
if [ -n "$CC_FLAGS" ];
|
||||
then
|
||||
for flag in $CC_FLAGS; do
|
||||
CC_ARGS+=( "--flag" "$flag" )
|
||||
done
|
||||
fi
|
||||
CC_ARGS+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
|
||||
CC_ARGS+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
|
||||
CC_ARGS+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
|
||||
CC_ARGS+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
|
||||
CC_ARGS+=( $(write_bool_args CC_HANDLE_NO_REPORTS_FOUND) )
|
||||
CC_ARGS+=( $(write_bool_args CC_RECURSE_SUBMODULES) )
|
||||
CC_ARGS+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
|
||||
CC_ARGS+=( $(write_bool_args CC_LEGACY) )
|
||||
if [ -n "$CC_NAME" ];
|
||||
then
|
||||
CC_ARGS+=( "--name" "$CC_NAME" )
|
||||
fi
|
||||
CC_ARGS+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
|
||||
CC_ARGS+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
|
||||
CC_ARGS+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
|
||||
if [ -n "$CC_PLUGINS" ];
|
||||
then
|
||||
for plugin in $CC_PLUGINS; do
|
||||
CC_ARGS+=( "--plugin" "$plugin" )
|
||||
done
|
||||
fi
|
||||
CC_ARGS+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
|
||||
CC_ARGS+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
|
||||
IFS=$OLDIFS
|
||||
elif [ "$CC_RUN_CMD" == "empty-upload" ]; then
|
||||
CC_ARGS+=( $(k_arg BRANCH) $(v_arg BRANCH))
|
||||
CC_ARGS+=( $(write_bool_args CC_FAIL_ON_ERROR) )
|
||||
CC_ARGS+=( $(write_bool_args CC_FORCE) )
|
||||
CC_ARGS+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
|
||||
CC_ARGS+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
|
||||
CC_ARGS+=( $(k_arg PR) $(v_arg PR))
|
||||
CC_ARGS+=( $(k_arg SHA) $(v_arg SHA))
|
||||
CC_ARGS+=( $(k_arg SLUG) $(v_arg SLUG))
|
||||
elif [ "$CC_RUN_CMD" == "pr-base-picking" ]; then
|
||||
CC_ARGS+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
|
||||
CC_ARGS+=( $(k_arg PR) $(v_arg PR))
|
||||
CC_ARGS+=( $(k_arg SLUG) $(v_arg SLUG))
|
||||
CC_ARGS+=( $(k_arg SERVICE) $(v_arg SERVICE))
|
||||
elif [ "$CC_RUN_CMD" == "send-notifications" ]; then
|
||||
CC_ARGS+=( $(k_arg SHA) $(v_arg SHA))
|
||||
CC_ARGS+=( $(write_bool_args CC_FAIL_ON_ERROR) )
|
||||
CC_ARGS+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
|
||||
CC_ARGS+=( $(k_arg SLUG) $(v_arg SLUG))
|
||||
else
|
||||
exit_if_error "Invalid run command specified: $CC_RUN_CMD"
|
||||
exit
|
||||
fi
|
||||
unset NODE_OPTIONS
|
||||
# github.com/codecov/uploader/issues/475
|
||||
if [ -n "$CC_TOKEN_VAR" ];
|
||||
then
|
||||
token="$(eval echo \$$CC_TOKEN_VAR)"
|
||||
else
|
||||
token="$(eval echo $CC_TOKEN)"
|
||||
fi
|
||||
say "$g ->$x Token length: ${#token}"
|
||||
token_str=""
|
||||
token_arg=()
|
||||
if [ -n "$token" ];
|
||||
then
|
||||
token_str+=" -t <redacted>"
|
||||
token_arg+=( " -t " "$token")
|
||||
fi
|
||||
say "$g==>$x Running $CC_RUN_CMD"
|
||||
say " $b$CC_COMMAND $(echo "${CC_CLI_ARGS[@]}") $CC_RUN_CMD$token_str $(echo "${CC_ARGS[@]}")$x"
|
||||
if ! $CC_COMMAND \
|
||||
${CC_CLI_ARGS[*]} \
|
||||
${CC_RUN_CMD} \
|
||||
${token_arg[*]} \
|
||||
"${CC_ARGS[@]}";
|
||||
then
|
||||
exit_if_error "Failed to run $CC_RUN_CMD"
|
||||
fi
|
||||
7717
dist/index.js
vendored
Normal file
7717
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -2,12 +2,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
cp src/scripts/dist/codecov.sh dist/codecov.sh
|
||||
git add dist/codecov.sh
|
||||
|
||||
git diff --cached --name-only | if grep --quiet "src/version"
|
||||
then
|
||||
python changelog.py
|
||||
fi
|
||||
|
||||
git add CHANGELOG.md
|
||||
npm install
|
||||
npm run lint --fix
|
||||
npm run build
|
||||
git add src/
|
||||
git add dist/
|
||||
git add package-lock.json
|
||||
|
||||
4
jest.config.js
Normal file
4
jest.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
}
|
||||
7381
package-lock.json
generated
Normal file
7381
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
package.json
Normal file
46
package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "codecov-action",
|
||||
"version": "1.5.2",
|
||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint src/*.*",
|
||||
"test": "yarn run test-script && yarn run test-calculator && yarn run test-coverage",
|
||||
"test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
||||
"test-coverage": "jest --testPathPattern=demo/coverage-test/ --coverage --coverageDirectory=coverage/coverage-test",
|
||||
"test-script": "jest --testPathPattern=src/ --coverage --coverageDirectory=coverage/script",
|
||||
"build": "ncc build src/index.ts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/codecov/codecov-action.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Ibrahim Ali",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/codecov/codecov-action/issues"
|
||||
},
|
||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.4.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/github": "^5.0.0",
|
||||
"fs": "0.0.1-security",
|
||||
"request": "^2.88.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^14.17.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.26.1",
|
||||
"@typescript-eslint/parser": "^4.26.1",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.28.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-junit": "^12.2.0",
|
||||
"ts-jest": "^26.5.6",
|
||||
"typescript": "^4.3.2",
|
||||
"yarn": "^1.22.10"
|
||||
}
|
||||
}
|
||||
151
src/buildExec.test.ts
Normal file
151
src/buildExec.test.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
import buildExec from './buildExec';
|
||||
const github = require('@actions/github');
|
||||
|
||||
import VERSION from './version';
|
||||
|
||||
const context = github.context;
|
||||
|
||||
test('no arguments', () => {
|
||||
const {execArgs, filepath, failCi} = buildExec();
|
||||
|
||||
const args = [
|
||||
'codecov.sh',
|
||||
'-n',
|
||||
'',
|
||||
'-F',
|
||||
'',
|
||||
'-Q',
|
||||
`github-action-${VERSION}`,
|
||||
];
|
||||
if (context.eventName == 'pull_request') {
|
||||
args.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||
}
|
||||
expect(execArgs).toEqual(args);
|
||||
expect(filepath).toEqual('codecov.sh');
|
||||
expect(failCi).toBeFalsy();
|
||||
});
|
||||
|
||||
test('all arguments', () => {
|
||||
const envs = {
|
||||
'move_coverage_to_trash': 'true',
|
||||
'commit_parent': '83231650328f11695dfb754ca0f540516f188d27',
|
||||
'aws_curl_args': '--timeout 1',
|
||||
'codecov_curl_args': '--timeout 2',
|
||||
'env_vars': 'OS,PYTHON',
|
||||
'fail_ci_if_error': 'true',
|
||||
'file': 'coverage.xml',
|
||||
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
||||
'flags': 'test',
|
||||
'functionalities':
|
||||
'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs',
|
||||
'gcov_args': '--timeout 3',
|
||||
'gcov_root_dr': 'gcov_dir/',
|
||||
'gcov_path_exclude': '**/exclude-dir/*.*',
|
||||
'gcov_executable': 'gcov',
|
||||
'gcov_path_include': '**/include-dir/*.*',
|
||||
'gcov_prefix': 'demo',
|
||||
'name': 'codecov',
|
||||
'network_filter': 'dir1',
|
||||
'override_branch': 'thomasrockhu/test',
|
||||
'override_build': '1',
|
||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||
'override_pr': '2',
|
||||
'override_tag': 'v1.2',
|
||||
'root_dir': 'root/',
|
||||
'directory': 'coverage/',
|
||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||
'verbose': 't',
|
||||
'working-directory': 'src',
|
||||
'path_to_write_report': 'codecov/',
|
||||
'xcode_derived_data': '~/Library/Developer/Xcode/DerivedData',
|
||||
'xcode_package': 'MyApp',
|
||||
};
|
||||
|
||||
for (const env of Object.keys(envs)) {
|
||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||
}
|
||||
|
||||
const {execArgs, filepath, failCi} = buildExec();
|
||||
expect(execArgs).toEqual([
|
||||
'src/codecov.sh',
|
||||
'-n',
|
||||
'codecov',
|
||||
'-F',
|
||||
'test',
|
||||
'-Q',
|
||||
`github-action-${VERSION}`,
|
||||
'-c',
|
||||
'-N',
|
||||
'83231650328f11695dfb754ca0f540516f188d27',
|
||||
'-A',
|
||||
'--timeout 1',
|
||||
'-U',
|
||||
'--timeout 2',
|
||||
'-e',
|
||||
'OS,PYTHON',
|
||||
'-Z',
|
||||
'-f',
|
||||
'coverage.xml',
|
||||
'-f',
|
||||
'dir1/coverage.xml',
|
||||
'-f',
|
||||
'dir2/coverage.xml',
|
||||
'-X',
|
||||
'gcov',
|
||||
'-X',
|
||||
'coveragepy',
|
||||
'-X',
|
||||
'fix',
|
||||
'-X',
|
||||
'search',
|
||||
'-X',
|
||||
'code',
|
||||
'-X',
|
||||
'network',
|
||||
'-X',
|
||||
'gcovout',
|
||||
'-X',
|
||||
'html',
|
||||
'-X',
|
||||
'recursesubs',
|
||||
'-a',
|
||||
'--timeout 3',
|
||||
'-g',
|
||||
'**/exclude-dir/*.*',
|
||||
'-x',
|
||||
'gcov',
|
||||
'-G',
|
||||
'**/include-dir/*.*',
|
||||
'-k',
|
||||
'demo',
|
||||
'-i',
|
||||
'dir1',
|
||||
'-B',
|
||||
'thomasrockhu/test',
|
||||
'-b',
|
||||
'1',
|
||||
'-C',
|
||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||
'-P',
|
||||
'2',
|
||||
'-T',
|
||||
'v1.2',
|
||||
'-R',
|
||||
'root/',
|
||||
'-s',
|
||||
'coverage/',
|
||||
'-v',
|
||||
'-q',
|
||||
'codecov/',
|
||||
'-D',
|
||||
'~/Library/Developer/Xcode/DerivedData',
|
||||
'-J',
|
||||
'MyApp',
|
||||
]);
|
||||
expect(filepath).toEqual('src/codecov.sh');
|
||||
expect(failCi).toBeTruthy();
|
||||
|
||||
for (const env of Object.keys(envs)) {
|
||||
delete process.env['INPUT_' + env.toUpperCase()];
|
||||
}
|
||||
});
|
||||
188
src/buildExec.ts
Normal file
188
src/buildExec.ts
Normal file
@@ -0,0 +1,188 @@
|
||||
const core = require('@actions/core');
|
||||
const github = require('@actions/github');
|
||||
|
||||
import VERSION from './version';
|
||||
|
||||
const context = github.context;
|
||||
|
||||
const isTrue = (variable) => {
|
||||
const lowercase = variable.toLowerCase();
|
||||
return (
|
||||
lowercase === '1' ||
|
||||
lowercase === 't' ||
|
||||
lowercase === 'true' ||
|
||||
lowercase === 'y' ||
|
||||
lowercase === 'yes'
|
||||
);
|
||||
};
|
||||
|
||||
const buildExec = () => {
|
||||
const clean = core.getInput('move_coverage_to_trash');
|
||||
const commitParent = core.getInput('commit_parent');
|
||||
const curlAwsArgs = core.getInput('aws_curl_args');
|
||||
const curlCodecovArgs = core.getInput('codecov_curl_args');
|
||||
const envVars = core.getInput('env_vars');
|
||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||
const file = core.getInput('file');
|
||||
const files = core.getInput('files');
|
||||
const flags = core.getInput('flags');
|
||||
const functionalities = core.getInput('functionalities');
|
||||
const gcovArgs = core.getInput('gcov_args');
|
||||
const gcovDir = core.getInput('gcov_root_dir');
|
||||
const gcovExclude = core.getInput('gcov_path_exclude');
|
||||
const gcovExec = core.getInput('gcov_executable');
|
||||
const gcovInclude = core.getInput('gcov_path_include');
|
||||
const gcovPrefix = core.getInput('gcov_prefix');
|
||||
const name = core.getInput('name');
|
||||
const networkFilter = core.getInput('network_filter');
|
||||
const overrideBranch = core.getInput('override_branch');
|
||||
const overrideBuild = core.getInput('override_build');
|
||||
const overrideCommit = core.getInput('override_commit');
|
||||
const overridePr = core.getInput('override_pr');
|
||||
const overrideTag = core.getInput('override_tag');
|
||||
const rootDir = core.getInput('root_dir');
|
||||
const searchDir = core.getInput('directory');
|
||||
const token = core.getInput('token');
|
||||
const verbose = isTrue(core.getInput('verbose'));
|
||||
const workingDir = core.getInput('working-directory');
|
||||
const writePath = core.getInput('path_to_write_report');
|
||||
const xcodeDerivedData = core.getInput('xcode_derived_data');
|
||||
const xcodePackage = core.getInput('xcode_package');
|
||||
|
||||
const filepath = workingDir ?
|
||||
workingDir + '/codecov.sh' : 'codecov.sh';
|
||||
|
||||
const execArgs = [filepath];
|
||||
execArgs.push(
|
||||
'-n',
|
||||
`${name}`,
|
||||
'-F',
|
||||
`${flags}`,
|
||||
'-Q',
|
||||
`github-action-${VERSION}`,
|
||||
);
|
||||
|
||||
const options:any = {};
|
||||
options.env = Object.assign(process.env, {
|
||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||
GITHUB_REF: process.env.GITHUB_REF,
|
||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
||||
});
|
||||
|
||||
const envVarsArg = [];
|
||||
for (const envVar of envVars.split(',')) {
|
||||
const envVarClean = envVar.trim();
|
||||
if (envVarClean) {
|
||||
options.env[envVarClean] = process.env[envVarClean];
|
||||
envVarsArg.push(envVarClean);
|
||||
}
|
||||
}
|
||||
|
||||
if (token) {
|
||||
options.env.CODECOV_TOKEN = token;
|
||||
}
|
||||
if (clean) {
|
||||
execArgs.push('-c');
|
||||
}
|
||||
if (commitParent) {
|
||||
execArgs.push('-N', `${commitParent}`);
|
||||
}
|
||||
if (curlAwsArgs) {
|
||||
execArgs.push('-A', `${curlAwsArgs}`);
|
||||
}
|
||||
if (curlCodecovArgs) {
|
||||
execArgs.push('-U', `${curlCodecovArgs}`);
|
||||
}
|
||||
if (envVarsArg.length) {
|
||||
execArgs.push('-e', envVarsArg.join(','));
|
||||
}
|
||||
if (failCi) {
|
||||
execArgs.push('-Z');
|
||||
}
|
||||
if (file) {
|
||||
execArgs.push('-f', `${file}`);
|
||||
}
|
||||
if (files) {
|
||||
files.split(',').forEach((f) => {
|
||||
execArgs.push('-f', `${f}`);
|
||||
});
|
||||
}
|
||||
if (functionalities) {
|
||||
functionalities.split(',').forEach((f) => {
|
||||
execArgs.push('-X', `${f}`);
|
||||
});
|
||||
}
|
||||
if (gcovArgs) {
|
||||
execArgs.push('-a', `${gcovArgs}`);
|
||||
}
|
||||
if (gcovDir) {
|
||||
execArgs.push('-p', `${gcovDir}`);
|
||||
}
|
||||
if (gcovExclude) {
|
||||
execArgs.push('-g', `${gcovExclude}`);
|
||||
}
|
||||
if (gcovExec) {
|
||||
execArgs.push('-x', `${gcovExec}`);
|
||||
}
|
||||
if (gcovInclude) {
|
||||
execArgs.push('-G', `${gcovInclude}`);
|
||||
}
|
||||
if (gcovPrefix) {
|
||||
execArgs.push('-k', `${gcovPrefix}`);
|
||||
}
|
||||
if (networkFilter) {
|
||||
execArgs.push('-i', `${networkFilter}`);
|
||||
}
|
||||
if (overrideBranch) {
|
||||
execArgs.push('-B', `${overrideBranch}`);
|
||||
}
|
||||
if (overrideBuild) {
|
||||
execArgs.push('-b', `${overrideBuild}`);
|
||||
}
|
||||
if (overrideCommit) {
|
||||
execArgs.push('-C', `${overrideCommit}`);
|
||||
} else if (
|
||||
`${context.eventName}` == 'pull_request' ||
|
||||
`${context.eventName}` == 'pull_request_target'
|
||||
) {
|
||||
execArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||
}
|
||||
if (overridePr) {
|
||||
execArgs.push('-P', `${overridePr}`);
|
||||
} else if (
|
||||
`${context.eventName}` == 'pull_request_target'
|
||||
) {
|
||||
execArgs.push('-P', `${context.payload.number}`);
|
||||
}
|
||||
if (overrideTag) {
|
||||
execArgs.push('-T', `${overrideTag}`);
|
||||
}
|
||||
if (rootDir) {
|
||||
execArgs.push('-R', `${rootDir}`);
|
||||
}
|
||||
if (searchDir) {
|
||||
execArgs.push('-s', `${searchDir}`);
|
||||
}
|
||||
if (verbose) {
|
||||
execArgs.push('-v');
|
||||
}
|
||||
if (workingDir) {
|
||||
options.cwd = workingDir;
|
||||
}
|
||||
if (writePath) {
|
||||
execArgs.push('-q', `${writePath}`);
|
||||
}
|
||||
if (xcodeDerivedData) {
|
||||
execArgs.push('-D', `${xcodeDerivedData}`);
|
||||
}
|
||||
if (xcodePackage) {
|
||||
execArgs.push('-J', `${xcodePackage}`);
|
||||
}
|
||||
|
||||
return {execArgs, options, filepath, failCi};
|
||||
};
|
||||
|
||||
export default buildExec;
|
||||
1884
src/codecov
Normal file
1884
src/codecov
Normal file
File diff suppressed because it is too large
Load Diff
53
src/index.ts
Normal file
53
src/index.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
const core = require('@actions/core');
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
import buildExec from './buildExec';
|
||||
|
||||
const codecovScript = fs.readFileSync(__dirname + '/codecov');
|
||||
|
||||
let failCi;
|
||||
try {
|
||||
const {execArgs, options, filepath, failCi} = buildExec();
|
||||
|
||||
fs.writeFile(filepath, codecovScript, (err) => {
|
||||
if (err && failCi) {
|
||||
throw err;
|
||||
} else if (err) {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
|
||||
exec.exec('bash', execArgs, options)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
if (failCi) {
|
||||
core.setFailed(
|
||||
`Codecov failed with the following error: ${err.message}`,
|
||||
);
|
||||
} else {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
})
|
||||
.then((status) => {
|
||||
console.log(status);
|
||||
unlinkFile();
|
||||
});
|
||||
|
||||
const unlinkFile = () => {
|
||||
fs.unlink(filepath, (err) => {
|
||||
if (err && failCi) {
|
||||
throw err;
|
||||
} else if (err) {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
if (failCi) {
|
||||
core.setFailed(`Codecov failed with the following error: ${error.message}`);
|
||||
} else {
|
||||
core.warning(`Codecov warning: ${error.message}`);
|
||||
}
|
||||
}
|
||||
Submodule src/scripts deleted from 473e292469
@@ -1 +0,0 @@
|
||||
5.5.0
|
||||
3
src/version.ts
Normal file
3
src/version.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const VERSION = 'v1.5.2';
|
||||
|
||||
export default VERSION;
|
||||
5
tsconfig.json
Normal file
5
tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user