mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
267 Commits
v4.0.0-bet
...
v4.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9fd7d16f6 | ||
|
|
6f7612c64d | ||
|
|
26c7e28d7e | ||
|
|
6f744f78de | ||
|
|
543c3d42fc | ||
|
|
e379426d37 | ||
|
|
42656e4cb1 | ||
|
|
2296b6ba9e | ||
|
|
bd77bc323c | ||
|
|
180b964407 | ||
|
|
4beef3e59f | ||
|
|
8bacbcdafc | ||
|
|
0036103d21 | ||
|
|
f9253eb652 | ||
|
|
135f82e412 | ||
|
|
4b21c320b5 | ||
|
|
2439dfc05c | ||
|
|
bb813333f9 | ||
|
|
d2bac1a14c | ||
|
|
9f15ff6db1 | ||
|
|
60a33a541b | ||
|
|
943cea186c | ||
|
|
955f1f08ad | ||
|
|
922d8d7b31 | ||
|
|
764e2e4bac | ||
|
|
dd5d48487d | ||
|
|
6f75c27045 | ||
|
|
4168d1398b | ||
|
|
abe5d5a96b | ||
|
|
cdaae0e243 | ||
|
|
a06c39c510 | ||
|
|
a87fadc201 | ||
|
|
4ef269f796 | ||
|
|
992fc4eb1f | ||
|
|
9e145151be | ||
|
|
e1b169f283 | ||
|
|
4809d8a8f6 | ||
|
|
543b309c01 | ||
|
|
621cd670ee | ||
|
|
e4dbd7e64b | ||
|
|
893cfea3da | ||
|
|
e12e94d346 | ||
|
|
8cf010f6e4 | ||
|
|
0cbef546c8 | ||
|
|
af2ee03a4e | ||
|
|
3d7297c4a2 | ||
|
|
ca3e2d9612 | ||
|
|
f5469482a3 | ||
|
|
76ee96d868 | ||
|
|
9a146cf9d5 | ||
|
|
d3911e8ec2 | ||
|
|
d81eade746 | ||
|
|
e28ff129e5 | ||
|
|
7594baaf0c | ||
|
|
81c0a51dcc | ||
|
|
f5e203f3d9 | ||
|
|
7c48363ed3 | ||
|
|
69e5d09ca1 | ||
|
|
feaf700b2a | ||
|
|
7b6a727a4a | ||
|
|
ccf7a1fd43 | ||
|
|
f03f015db9 | ||
|
|
5fe1d91fef | ||
|
|
679cd7bee6 | ||
|
|
51fc5dccf6 | ||
|
|
5ba2c853f8 | ||
|
|
afaa0c08b8 | ||
|
|
a1504ae490 | ||
|
|
a05a16bd04 | ||
|
|
fb010ae47e | ||
|
|
125fc84a9a | ||
|
|
c9dbf6a905 | ||
|
|
59fc46f14a | ||
|
|
3889fddabb | ||
|
|
d42a336584 | ||
|
|
fd624e50e7 | ||
|
|
6d798873df | ||
|
|
37364fa731 | ||
|
|
2791a5c4fe | ||
|
|
b71af43c1e | ||
|
|
29f97fc54f | ||
|
|
645d2a5926 | ||
|
|
f691d469fb | ||
|
|
5ecb98a3c6 | ||
|
|
5a299d1127 | ||
|
|
dad251dcaf | ||
|
|
e8bbe5fc01 | ||
|
|
a6fd87fc19 | ||
|
|
76c8cd6163 | ||
|
|
1290bddc88 | ||
|
|
951ef79006 | ||
|
|
bb71c1ba2f | ||
|
|
acc5d43cad | ||
|
|
fab3a2f0ed | ||
|
|
daf8061cef | ||
|
|
a4d9e6ca72 | ||
|
|
c852ea6812 | ||
|
|
91f8da92ad | ||
|
|
a249bea245 | ||
|
|
8deb5f497d | ||
|
|
c34fe147c2 | ||
|
|
86801cdd03 | ||
|
|
8dff8940ff | ||
|
|
84508663e9 | ||
|
|
e8419092e9 | ||
|
|
363a65ad48 | ||
|
|
640b86a455 | ||
|
|
375c033fbe | ||
|
|
d701256d7a | ||
|
|
0bb547ab49 | ||
|
|
55e8381a3e | ||
|
|
7afa10ed9b | ||
|
|
d820d60619 | ||
|
|
3a20752bdd | ||
|
|
c16abc29c9 | ||
|
|
3e33441c19 | ||
|
|
85aacc9654 | ||
|
|
4ea9be0fa3 | ||
|
|
164fadeaa7 | ||
|
|
4621ecce09 | ||
|
|
251ba34669 | ||
|
|
5a593a5341 | ||
|
|
a15c0e43ca | ||
|
|
8be6ba5782 | ||
|
|
e774838850 | ||
|
|
54bcd8715e | ||
|
|
8ba77ef8d7 | ||
|
|
c60aa801e3 | ||
|
|
2fc4847d3f | ||
|
|
0cfda1dd0a | ||
|
|
7d3a55eb5e | ||
|
|
fe84a0b3c0 | ||
|
|
e12c9402c4 | ||
|
|
ef7f8a5d3c | ||
|
|
b8a1d6a424 | ||
|
|
6ef7ea4c74 | ||
|
|
f62c5eebfe | ||
|
|
fdbfa4b889 | ||
|
|
9855cf7bd1 | ||
|
|
162c44c603 | ||
|
|
a9883cc0b2 | ||
|
|
8c40c8cd55 | ||
|
|
781907b2be | ||
|
|
93b3dea0bf | ||
|
|
82ab52d110 | ||
|
|
e0b68c6749 | ||
|
|
1f9f5573d1 | ||
|
|
09686fcfcb | ||
|
|
f30e4959ba | ||
|
|
a7b945cea4 | ||
|
|
98ab2c591b | ||
|
|
43235cc5ae | ||
|
|
0cf8684c82 | ||
|
|
8e1e730371 | ||
|
|
61293af0e8 | ||
|
|
7a070cbe5b | ||
|
|
909716592c | ||
|
|
ac042eaf0f | ||
|
|
2ee76754cf | ||
|
|
ed33b8792b | ||
|
|
205d0f3bf2 | ||
|
|
f7a40362d5 | ||
|
|
347aed814d | ||
|
|
240e6ae968 | ||
|
|
22b99ac1d7 | ||
|
|
c256d56669 | ||
|
|
b655832634 | ||
|
|
f3c893f625 | ||
|
|
d64049153d | ||
|
|
082211867f | ||
|
|
36c4c273ec | ||
|
|
3557dec46e | ||
|
|
d09fc58aca | ||
|
|
53405dd159 | ||
|
|
9cae541a7d | ||
|
|
7a6de893e7 | ||
|
|
67144c77f4 | ||
|
|
7574dbd6ec | ||
|
|
bbeaa14035 | ||
|
|
560836068e | ||
|
|
bd76fb6ca2 | ||
|
|
81da1cc4bc | ||
|
|
6b11576289 | ||
|
|
ab88a5b6c7 | ||
|
|
e9a38394a1 | ||
|
|
35eb77e000 | ||
|
|
eb2fd70b01 | ||
|
|
2d2a8f93e1 | ||
|
|
4a1b7c9084 | ||
|
|
6e1433e83b | ||
|
|
6a5356fcde | ||
|
|
05c8e34a27 | ||
|
|
bc023a2d94 | ||
|
|
b0466b47a0 | ||
|
|
f33d135af5 | ||
|
|
438fa9e3ac | ||
|
|
4df8175b4e | ||
|
|
b414989bf5 | ||
|
|
8474edbadb | ||
|
|
8656f6c1c6 | ||
|
|
9234907bdc | ||
|
|
3789238b3b | ||
|
|
920a494b79 | ||
|
|
83b6689bed | ||
|
|
fdcdb22cba | ||
|
|
7d665f44bb | ||
|
|
4b48428164 | ||
|
|
4646528f20 | ||
|
|
f8eb26ef37 | ||
|
|
5e2c2ecdbd | ||
|
|
f4993f1f51 | ||
|
|
11e76d658b | ||
|
|
94d82392c4 | ||
|
|
34bba43c95 | ||
|
|
028beb0e20 | ||
|
|
b98ba29eaf | ||
|
|
70827de827 | ||
|
|
eef87f60cd | ||
|
|
35d91fd4ea | ||
|
|
6dacea127a | ||
|
|
ca9e0edcd3 | ||
|
|
aca8ff1dcc | ||
|
|
83d30f0e41 | ||
|
|
aceeca9bb1 | ||
|
|
d7fb5255d7 | ||
|
|
4a43355a6e | ||
|
|
d4985dcf35 | ||
|
|
535356c890 | ||
|
|
cdcd85ee2a | ||
|
|
525bbfffeb | ||
|
|
03dadc24b6 | ||
|
|
277c1b5977 | ||
|
|
f79a6d89b1 | ||
|
|
5bafa6898e | ||
|
|
0bd02822a2 | ||
|
|
d128348047 | ||
|
|
838dde6607 | ||
|
|
12886f0366 | ||
|
|
74d2e8d453 | ||
|
|
392e27ba63 | ||
|
|
72c1031b41 | ||
|
|
9ae347ac89 | ||
|
|
9701436596 | ||
|
|
32bfff88bd | ||
|
|
cafbda5927 | ||
|
|
ef2b0df87f | ||
|
|
f8c4fc3b04 | ||
|
|
4682b7b2df | ||
|
|
356138457c | ||
|
|
2f1c584520 | ||
|
|
b6dbf98f30 | ||
|
|
76d318c315 | ||
|
|
df7f1afac7 | ||
|
|
10187ae73d | ||
|
|
0b0064c1d1 | ||
|
|
44a150985a | ||
|
|
428cda1b1c | ||
|
|
572779f95b | ||
|
|
d6353e1297 | ||
|
|
d6b8a01e05 | ||
|
|
59959656dc | ||
|
|
3f71d3b255 | ||
|
|
266a44bf8b | ||
|
|
2409ca5030 | ||
|
|
b65fbdcf97 | ||
|
|
c4cf8a4f03 | ||
|
|
845c445181 |
@@ -17,6 +17,7 @@
|
|||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"max-len": ["error", { "code": 120 }],
|
||||||
"linebreak-style": 0
|
"linebreak-style": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
.github/workflows/codeql-analysis.yml
vendored
12
.github/workflows/codeql-analysis.yml
vendored
@@ -12,10 +12,10 @@ name: "CodeQL"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
branches: [ master ]
|
branches: [ main ]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '24 6 * * 5'
|
- cron: '24 6 * * 5'
|
||||||
|
|
||||||
@@ -37,11 +37,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.2.0
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2.21.5
|
uses: github/codeql-action/init@v3.26.9
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# 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)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2.21.5
|
uses: github/codeql-action/autobuild@v3.26.9
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -66,4 +66,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2.21.5
|
uses: github/codeql-action/analyze@v3.26.9
|
||||||
|
|||||||
14
.github/workflows/enforce-license-compliance.yml
vendored
Normal file
14
.github/workflows/enforce-license-compliance.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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 }}
|
||||||
73
.github/workflows/main.yml
vendored
73
.github/workflows/main.yml
vendored
@@ -1,17 +1,24 @@
|
|||||||
name: Workflow for Codecov Action
|
name: Workflow for Codecov Action
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
no-deps:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.2.0
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Lint
|
||||||
|
run: npm run lint
|
||||||
|
- name: Run tests and collect coverage
|
||||||
|
run: npm run test
|
||||||
- name: Upload coverage to Codecov (script)
|
- name: Upload coverage to Codecov (script)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
files: ./coverage/script/coverage-final.json
|
files: ./coverage/script/coverage-final.json
|
||||||
flags: script,${{ matrix.os }}
|
flags: script,${{ matrix.os }}
|
||||||
name: codecov-script
|
name: codecov-script
|
||||||
@@ -20,6 +27,7 @@ jobs:
|
|||||||
- name: Upload coverage to Codecov (demo)
|
- name: Upload coverage to Codecov (demo)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
@@ -29,21 +37,64 @@ jobs:
|
|||||||
- name: Upload coverage to Codecov (version)
|
- name: Upload coverage to Codecov (version)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: version,${{ matrix.os }}
|
flags: version,${{ matrix.os }}
|
||||||
name: codecov-version
|
name: codecov-version
|
||||||
version: v0.2.0
|
version: v0.7.3
|
||||||
verbose: true
|
verbose: true
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
run:
|
|
||||||
runs-on: ${{ matrix.os }}
|
run-macos-latest-xlarge:
|
||||||
strategy:
|
if: github.head.repo.full_name == 'codecov/codecov-action'
|
||||||
matrix:
|
runs-on: macos-latest-xlarge
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.2.0
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Lint
|
||||||
|
run: npm run lint
|
||||||
|
- name: Run tests and collect coverage
|
||||||
|
run: npm run test
|
||||||
|
- 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
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: demo,macos-latest-xlarge
|
||||||
|
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
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: version,maxos-latest-xlarge
|
||||||
|
name: codecov-version
|
||||||
|
version: v0.6.0
|
||||||
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
|
run-container:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: node:18
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4.2.0
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Lint
|
- name: Lint
|
||||||
@@ -74,6 +125,6 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: version,${{ matrix.os }}
|
flags: version,${{ matrix.os }}
|
||||||
name: codecov-version
|
name: codecov-version
|
||||||
version: v0.2.0
|
version: v0.6.0
|
||||||
verbose: true
|
verbose: true
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
19
.github/workflows/scorecards-analysis.yml
vendored
19
.github/workflows/scorecards-analysis.yml
vendored
@@ -5,13 +5,14 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '43 20 * * 1'
|
- cron: '43 20 * * 1'
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ main ]
|
||||||
|
|
||||||
# Declare default permissions as read only.
|
# Declare default permissions as read only.
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
|
if: github.repository == 'codecov/codecov-action'
|
||||||
name: Scorecards analysis
|
name: Scorecards analysis
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
@@ -21,15 +22,15 @@ jobs:
|
|||||||
id-token: write
|
id-token: write
|
||||||
actions: read
|
actions: read
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v4.0.0 # v3.0.0
|
uses: actions/checkout@v4.2.0 # v3.0.0
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
|
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
@@ -40,22 +41,22 @@ jobs:
|
|||||||
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||||
|
|
||||||
# Publish the results for public repositories to enable scorecard badges. For more details, see
|
# Publish the results for public repositories to enable scorecard badges. For more details, see
|
||||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||||
# For private repositories, `publish_results` will automatically be set to `false`, regardless
|
# For private repositories, `publish_results` will automatically be set to `false`, regardless
|
||||||
# of the value entered here.
|
# of the value entered here.
|
||||||
publish_results: true
|
publish_results: true
|
||||||
|
|
||||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||||
# format to the repository Actions tab.
|
# format to the repository Actions tab.
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
||||||
with:
|
with:
|
||||||
name: SARIF file
|
name: SARIF file
|
||||||
path: results.sarif
|
path: results.sarif
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
# Upload the results to GitHub's code scanning dashboard.
|
# Upload the results to GitHub's code scanning dashboard.
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@v2.21.5 # v1.0.26
|
uses: github/codeql-action/upload-sarif@v3.26.9 # v1.0.26
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 4.0.0-beta.2
|
||||||
|
### Fixes
|
||||||
|
- #1085 not adding -n if empty to do-upload command
|
||||||
|
|
||||||
## 4.0.0-beta.1
|
## 4.0.0-beta.1
|
||||||
|
|
||||||
`v4` represents a move from the [universal uploader](https://github.com/codecov/uploader) to the [Codecov CLI](https://github.com/codecov/codecov-cli). Although this will unlock new features for our users, the CLI is not yet at feature parity with the universal uploader.
|
`v4` represents a move from the [universal uploader](https://github.com/codecov/uploader) to the [Codecov CLI](https://github.com/codecov/codecov-cli). Although this will unlock new features for our users, the CLI is not yet at feature parity with the universal uploader.
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,7 +1,7 @@
|
|||||||
deploy:
|
deploy:
|
||||||
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
||||||
git tag -d v3
|
git tag -d v4
|
||||||
git push origin :v3
|
git push origin :v4
|
||||||
git tag v3
|
git tag v4
|
||||||
git tag v$(VERSION) -s -m ""
|
git tag v$(VERSION) -s -m ""
|
||||||
git push origin --tags
|
git push origin --tags
|
||||||
|
|||||||
143
README.md
143
README.md
@@ -1,96 +1,119 @@
|
|||||||
# Codecov GitHub Action
|
# 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://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
||||||
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
||||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||||
|
|
||||||
## v4 Beta Release
|
## 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. Currently, `v4` is in beta.
|
`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
|
### Breaking Changes
|
||||||
- No current support for `aarch64` and `alpine` architectures.
|
- 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)
|
||||||
- Tokenless uploading is unsupported
|
|
||||||
- Various arguments to the Action have been removed
|
- Various arguments to the Action have been removed
|
||||||
|
|
||||||
`v3` versions and below will not have access to CLI features (e.g. global upload token).
|
### 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)
|
||||||
|
|
||||||
## ⚠️ Deprecation of v1
|
`v3` versions and below will not have access to CLI features (e.g. global upload token, ATS).
|
||||||
**As of February 1, 2022, v1 has been fully sunset and no longer functions**
|
|
||||||
|
|
||||||
Due to the [deprecation](https://about.codecov.io/blog/introducing-codecovs-new-uploader/) of the underlying bash uploader,
|
|
||||||
the Codecov GitHub Action has released `v2`/`v3` which will use the new [uploader](https://github.com/codecov/uploader). You can learn
|
|
||||||
more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/).
|
|
||||||
|
|
||||||
We will be restricting any updates to the `v1` Action to security updates and hotfixes.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v3` 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 (`@v4` is recommended) as a `step` within your `workflow.yml` file.
|
||||||
|
|
||||||
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**
|
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
|
||||||
|
|
||||||
Inside your `.github/workflows/workflow.yml` file:
|
Inside your `.github/workflows/workflow.yml` file:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@main
|
||||||
- uses: codecov/codecov-action@v3
|
- uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
fail_ci_if_error: true # optional (default = false)
|
||||||
files: ./coverage1.xml,./coverage2.xml # optional
|
files: ./coverage1.xml,./coverage2.xml # optional
|
||||||
flags: unittests # optional
|
flags: unittests # optional
|
||||||
name: codecov-umbrella # optional
|
name: codecov-umbrella # optional
|
||||||
fail_ci_if_error: true # optional (default = false)
|
token: ${{ secrets.CODECOV_TOKEN }} # required
|
||||||
verbose: true # optional (default = false)
|
verbose: true # optional (default = false)
|
||||||
```
|
```
|
||||||
>**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.
|
|
||||||
|
The Codecov token can also be passed in via environment variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@main
|
||||||
|
- uses: codecov/codecov-action@v4
|
||||||
|
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 }}
|
||||||
|
```
|
||||||
|
> [!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.
|
||||||
|
|
||||||
|
### Using OIDC
|
||||||
|
For users with [OpenID Connect(OIDC) enabled](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect), the Codecov token is not necessary. You can use OIDC with the `use_oidc` argument as following.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
use_oidc: true
|
||||||
|
```
|
||||||
|
|
||||||
|
Any token supplied will be ignored, as Codecov will default to the OIDC token for verification.
|
||||||
|
|
||||||
## Arguments
|
## 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 supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:
|
||||||
|
|
||||||
| Input | Description | Usage |
|
| Input | Description | Required |
|
||||||
| :---: | :---: | :---: |
|
| :--- | :--- | :---: |
|
||||||
| `token` | Used to authorize coverage report uploads | *Required |
|
| `token` | Repository Codecov token. Used to authorize report uploads | *Required
|
||||||
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
|
| `codecov_yml_path` | Specify the path to the Codecov YML | 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
|
| `commit_parent` | Override to specify the parent commit SHA | Optional
|
||||||
|
| `directory` | Directory to search for coverage reports. | Optional
|
||||||
|
| `disable_search` | Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option. | Optional
|
||||||
|
| `disable_file_fixes` | Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets) | Optional
|
||||||
| `dry_run` | Don't upload files to Codecov | Optional
|
| `dry_run` | Don't upload files to Codecov | Optional
|
||||||
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
| `env_vars` | Environment variables to tag the upload with (e.g. PYTHON \| OS,PYTHON) | Optional
|
||||||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
| `exclude` | Folders to exclude from search | Optional
|
||||||
| `files` | Comma-separated paths to the coverage report(s). Negated paths are supported by starting with `!` | Optional
|
| `fail_ci_if_error` | Specify whether or not CI build should fail if Codecov runs into an error during upload | Optional
|
||||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
|
| `file` | Path to coverage file to upload | Optional
|
||||||
| `full_report` | Specify the path of a full Codecov report to re-upload | Optional
|
| `files` | Comma-separated list of files to upload | Optional
|
||||||
| `functionalities` | Toggle functionalities | Optional
|
| `flags` | Flag upload to group coverage metrics (e.g. unittests \| integration \| ui,chrome) | Optional
|
||||||
| -- `network` | Disable uploading the file network | Optional
|
| `handle_no_reports_found` | Raise no exceptions when no coverage reports found | Optional
|
||||||
| -- `fixes` | Enable file fixes to ignore common lines from coverage | Optional
|
| `job_code` | The job code | Optional
|
||||||
| -- `search` | Disable searching for coverage files | Optional
|
| `name` | User defined upload name. Visible in Codecov UI | Optional
|
||||||
| `gcov` | Run with gcov support | Optional
|
| `os` | Override the assumed OS. Options are linux \| macos \| windows \| . | Optional
|
||||||
| `gcov_args` | Extra arguments to pass to gcov | Optional
|
|
||||||
| `gcov_ignore` | Paths to ignore during gcov gathering | Optional
|
|
||||||
| `gcov_include` | Paths to include during gcov gathering | Optional
|
|
||||||
| `gcov_executable` | gcov executable to run. Defaults to gcov. | Optional
|
|
||||||
| `name` | Custom defined name for the upload | Optional
|
|
||||||
| `network_filter` | Specify a filter on the files listed in the network section of the Codecov report. 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` | Specify the OS (linux, macos, windows, alpine) | Optional
|
|
||||||
| `override_branch` | Specify the branch name | Optional
|
| `override_branch` | Specify the branch name | Optional
|
||||||
| `override_build` | Specify the build number | Optional
|
| `override_build` | Specify the build number | Optional
|
||||||
|
| `override_build_url` | The URL of the build where this is running | Optional
|
||||||
| `override_commit` | Specify the commit SHA | Optional
|
| `override_commit` | Specify the commit SHA | Optional
|
||||||
| `override_pr` | Specify the pull request number | Optional
|
| `override_pr` | Specify the pull request number | Optional
|
||||||
| `override_tag` | Specify the git tag | Optional
|
| `plugin` | plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all. | Optional
|
||||||
| `root_dir` | Used when not in git/hg project to identify project root directory | Optional
|
| `plugins` | Comma-separated list of plugins for use during upload. | Optional
|
||||||
| `directory` | Directory to search for coverage reports. | Optional
|
| `report_code` | The code of the report. If unsure, do not include | Optional
|
||||||
|
| `root_dir` | Used to specify the location of your .git root to identify project root directory | Optional
|
||||||
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
||||||
| `swift` | Run with swift coverage support | Optional
|
| `url` | Specify the base url to upload (Enterprise use) | Optional
|
||||||
| -- `swift_project` | Specify the swift project to speed up coverage conversion | Optional
|
| `use_legacy_upload_endpoint` | Use the legacy upload endpoint | Optional
|
||||||
| `upstream_proxy` | The upstream http proxy server to connect through | Optional
|
| `use_oidc` | Use OpenID Connect for verification instead of token. This will ignore any token supplied. Please see [GitHub documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) for details.
|
||||||
| `url` | Change the upload host (Enterprise use) | Optional
|
|
||||||
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||||
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
|
| `version` | Specify which version of the Codecov CLI should be used. Defaults to `latest` | Optional
|
||||||
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
| `working-directory` | Directory in which to execute codecov.sh | Optional
|
||||||
| `xtra_args` | Add additional uploader args that may be missing in the Action | Optional
|
|
||||||
|
|
||||||
|
|
||||||
### Example `workflow.yml` with Codecov Action
|
### Example `workflow.yml` with Codecov Action
|
||||||
|
|
||||||
@@ -107,9 +130,9 @@ jobs:
|
|||||||
OS: ${{ matrix.os }}
|
OS: ${{ matrix.os }}
|
||||||
PYTHON: '3.10'
|
PYTHON: '3.10'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@main
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@master
|
uses: actions/setup-python@main
|
||||||
with:
|
with:
|
||||||
python-version: 3.10
|
python-version: 3.10
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
@@ -118,15 +141,15 @@ jobs:
|
|||||||
pip install pytest-cov
|
pip install pytest-cov
|
||||||
pytest --cov=./ --cov-report=xml
|
pytest --cov=./ --cov-report=xml
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
directory: ./coverage/reports/
|
directory: ./coverage/reports/
|
||||||
env_vars: OS,PYTHON
|
env_vars: OS,PYTHON
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
files: ./coverage1.xml,./coverage2.xml,!./cache
|
files: ./coverage1.xml,./coverage2.xml,!./cache
|
||||||
flags: unittests
|
flags: unittests
|
||||||
name: codecov-umbrella
|
name: codecov-umbrella
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
verbose: true
|
verbose: true
|
||||||
```
|
```
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
71
action.yml
71
action.yml
@@ -3,19 +3,25 @@ description: 'GitHub Action that uploads coverage reports for your repository to
|
|||||||
author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov'
|
author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov'
|
||||||
inputs:
|
inputs:
|
||||||
token:
|
token:
|
||||||
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
description: 'Repository Codecov token. Used to authorize report uploads'
|
||||||
required: false
|
required: false
|
||||||
file:
|
codecov_yml_path:
|
||||||
description: 'Path to coverage file to upload'
|
description: 'Specify the path to the Codecov YML'
|
||||||
required: false
|
required: false
|
||||||
files:
|
commit_parent:
|
||||||
description: 'Comma-separated list of files to upload'
|
description: 'Override to specify the parent commit SHA'
|
||||||
required: false
|
required: false
|
||||||
directory:
|
directory:
|
||||||
description: 'Directory to search for coverage reports.'
|
description: 'Directory to search for coverage reports.'
|
||||||
required: false
|
required: false
|
||||||
flags:
|
disable_file_fixes:
|
||||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
description: 'Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)'
|
||||||
|
required: false
|
||||||
|
disable_search:
|
||||||
|
description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option.'
|
||||||
|
required: false
|
||||||
|
disable_safe_directory:
|
||||||
|
description: 'Disable setting safe directory. Set to true to disable.'
|
||||||
required: false
|
required: false
|
||||||
dry_run:
|
dry_run:
|
||||||
description: "Don't upload files to Codecov"
|
description: "Don't upload files to Codecov"
|
||||||
@@ -23,15 +29,39 @@ inputs:
|
|||||||
env_vars:
|
env_vars:
|
||||||
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||||
required: false
|
required: false
|
||||||
|
exclude:
|
||||||
|
description: 'Folders to exclude from search'
|
||||||
|
required: false
|
||||||
fail_ci_if_error:
|
fail_ci_if_error:
|
||||||
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||||
required: false
|
required: false
|
||||||
gcov:
|
file:
|
||||||
description: 'Run with gcov support'
|
description: 'Path to coverage file to upload'
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: 'Comma-separated list of files to upload'
|
||||||
|
required: false
|
||||||
|
flags:
|
||||||
|
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||||
|
required: false
|
||||||
|
git_service:
|
||||||
|
description: 'Override the git_service (e.g. github_enterprise)'
|
||||||
|
required: false
|
||||||
|
handle_no_reports_found:
|
||||||
|
description: 'Raise no exceptions when no coverage reports found'
|
||||||
|
required: false
|
||||||
|
job_code:
|
||||||
|
description: 'The job code'
|
||||||
required: false
|
required: false
|
||||||
name:
|
name:
|
||||||
description: 'User defined upload name. Visible in Codecov UI'
|
description: 'User defined upload name. Visible in Codecov UI'
|
||||||
required: false
|
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:
|
os:
|
||||||
description: 'Override the assumed OS. Options are linux | macos | windows.'
|
description: 'Override the assumed OS. Options are linux | macos | windows.'
|
||||||
required: false
|
required: false
|
||||||
@@ -41,18 +71,39 @@ inputs:
|
|||||||
override_build:
|
override_build:
|
||||||
description: 'Specify the build number'
|
description: 'Specify the build number'
|
||||||
required: false
|
required: false
|
||||||
|
override_build_url:
|
||||||
|
description: 'The URL of the build where this is running'
|
||||||
|
required: false
|
||||||
override_commit:
|
override_commit:
|
||||||
description: 'Specify the commit SHA'
|
description: 'Specify the commit SHA'
|
||||||
required: false
|
required: false
|
||||||
override_pr:
|
override_pr:
|
||||||
description: 'Specify the pull request number'
|
description: 'Specify the pull request number'
|
||||||
required: false
|
required: false
|
||||||
|
plugin:
|
||||||
|
description: 'plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all.'
|
||||||
|
required: false
|
||||||
|
plugins:
|
||||||
|
description: 'Comma-separated list of plugins for use during upload.'
|
||||||
|
required: false
|
||||||
|
report_code:
|
||||||
|
description: 'The code of the report. If unsure, do not include'
|
||||||
|
required: false
|
||||||
root_dir:
|
root_dir:
|
||||||
description: 'Used when not in git/hg project to identify project root directory'
|
description: 'Used when not in git/hg project to identify project root directory'
|
||||||
required: false
|
required: false
|
||||||
slug:
|
slug:
|
||||||
description: 'Specify the slug manually (Enterprise use)'
|
description: 'Specify the slug manually (Enterprise use)'
|
||||||
required: false
|
required: false
|
||||||
|
url:
|
||||||
|
description: 'Specify the base url to upload (Enterprise use)'
|
||||||
|
required: false
|
||||||
|
use_legacy_upload_endpoint:
|
||||||
|
description: 'Use the legacy upload endpoint'
|
||||||
|
required: false
|
||||||
|
use_oidc:
|
||||||
|
description: 'Use OIDC instead of token. This will ignore any token supplied'
|
||||||
|
required: false
|
||||||
verbose:
|
verbose:
|
||||||
description: 'Specify whether the Codecov output should be verbose'
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
required: false
|
required: false
|
||||||
@@ -66,5 +117,5 @@ branding:
|
|||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
46024
dist/index.js
vendored
Executable file → Normal file
46024
dist/index.js
vendored
Executable file → Normal file
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/sourcemap-register.js
vendored
2
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
5269
package-lock.json
generated
5269
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "4.0.0-beta.1",
|
"version": "4.6.0",
|
||||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -25,21 +25,20 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^6.0.0",
|
||||||
"node-fetch": "^3.3.2",
|
"undici": "5.28.4"
|
||||||
"openpgp": "5.10"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.4",
|
"@octokit/webhooks-types": "^7.5.1",
|
||||||
"@types/node": "^20.6.0",
|
"@types/jest": "^29.5.13",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
"@typescript-eslint/eslint-plugin": "^8.8.0",
|
||||||
"@typescript-eslint/parser": "^6.7.0",
|
"@typescript-eslint/parser": "^8.8.0",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"@vercel/ncc": "^0.38.2",
|
||||||
"eslint": "^8.49.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
"jest": "^29.6.4",
|
"jest": "^29.7.0",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^5.2.0"
|
"typescript": "^5.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,25 @@ import {
|
|||||||
buildGeneralExec,
|
buildGeneralExec,
|
||||||
buildReportExec,
|
buildReportExec,
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
|
getToken,
|
||||||
} from './buildExec';
|
} from './buildExec';
|
||||||
|
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
||||||
test('general args', () => {
|
let OLDOS = process.env.RUNNER_OS;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
OLDOS = process.env.RUNNER_OS;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env.RUNNER_OS = OLDOS;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('general args', async () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
codecov_yml_path: 'dev/codecov.yml',
|
||||||
url: 'https://codecov.enterprise.com',
|
url: 'https://codecov.enterprise.com',
|
||||||
verbose: 't',
|
verbose: 't',
|
||||||
};
|
};
|
||||||
@@ -19,10 +31,12 @@ test('general args', () => {
|
|||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {args, verbose} = buildGeneralExec();
|
const {args, verbose} = await buildGeneralExec();
|
||||||
|
|
||||||
expect(args).toEqual(
|
expect(args).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
'--codecov-yml-path',
|
||||||
|
'dev/codecov.yml',
|
||||||
'--enterprise-url',
|
'--enterprise-url',
|
||||||
'https://codecov.enterprise.com',
|
'https://codecov.enterprise.com',
|
||||||
'-v',
|
'-v',
|
||||||
@@ -33,15 +47,14 @@ test('general args', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('upload args using context', async () => {
|
||||||
test('upload args using context', () => {
|
|
||||||
const expectedArgs = [
|
const expectedArgs = [
|
||||||
'-n',
|
'--git-service',
|
||||||
'',
|
'github',
|
||||||
];
|
];
|
||||||
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
const {uploadExecArgs, uploadCommand} = await buildUploadExec();
|
||||||
if (context.eventName == 'pull_request') {
|
if (context.eventName == 'pull_request') {
|
||||||
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
}
|
}
|
||||||
if (context.eventName == 'pull_request_target') {
|
if (context.eventName == 'pull_request_target') {
|
||||||
expectedArgs.push('-P', `${context.payload.number}`);
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
@@ -51,38 +64,57 @@ test('upload args using context', () => {
|
|||||||
expect(uploadCommand).toEqual('do-upload');
|
expect(uploadCommand).toEqual('do-upload');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('upload args', () => {
|
test('upload args', async () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
'codecov_yml_path': 'dev/codecov.yml',
|
||||||
|
'commit_parent': 'fakeparentcommit',
|
||||||
'directory': 'coverage/',
|
'directory': 'coverage/',
|
||||||
|
'disable_file_fixes': 'true',
|
||||||
|
'disable_search': 'true',
|
||||||
'dry_run': 'true',
|
'dry_run': 'true',
|
||||||
'env_vars': 'OS,PYTHON',
|
'env_vars': 'OS,PYTHON',
|
||||||
|
'exclude': 'node_modules/',
|
||||||
'fail_ci_if_error': 'true',
|
'fail_ci_if_error': 'true',
|
||||||
'file': 'coverage.xml',
|
'file': 'coverage.xml',
|
||||||
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
'files': 'dir1/coverage.xml,dir2/coverage.xml,',
|
||||||
'flags': 'test,test2',
|
'flags': 'test,test2',
|
||||||
|
'git_service': 'github_enterprise',
|
||||||
|
'handle_no_reports_found': 'true',
|
||||||
|
'job_code': '32',
|
||||||
'name': 'codecov',
|
'name': 'codecov',
|
||||||
|
'os': 'macos',
|
||||||
'override_branch': 'thomasrockhu/test',
|
'override_branch': 'thomasrockhu/test',
|
||||||
'override_build': '1',
|
'override_build': '1',
|
||||||
|
'override_build_url': 'https://example.com/build/2',
|
||||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'override_pr': '2',
|
'override_pr': '2',
|
||||||
|
'network_filter': 'subA/',
|
||||||
|
'network_prefix': 'forA/',
|
||||||
|
'plugin': 'xcode',
|
||||||
|
'plugins': 'pycoverage,compress-pycoverage',
|
||||||
|
'report_code': 'testCode',
|
||||||
'root_dir': 'root/',
|
'root_dir': 'root/',
|
||||||
'slug': 'fakeOwner/fakeRepo',
|
'slug': 'fakeOwner/fakeRepo',
|
||||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
'url': 'https://enterprise.example.com',
|
||||||
|
'use_legacy_upload_endpoint': 'true',
|
||||||
|
'verbose': 'true',
|
||||||
|
'version': '0.1.2',
|
||||||
'working-directory': 'src',
|
'working-directory': 'src',
|
||||||
'plugin': 'xcode',
|
|
||||||
'exclude': 'src',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
const {uploadExecArgs, uploadCommand} = await buildUploadExec();
|
||||||
const expectedArgs = [
|
const expectedArgs = [
|
||||||
'-n',
|
'--disable-file-fixes',
|
||||||
'codecov',
|
'--disable-search',
|
||||||
'-d',
|
'-d',
|
||||||
'-e',
|
'-e',
|
||||||
'OS,PYTHON',
|
'OS,PYTHON',
|
||||||
|
'--exclude',
|
||||||
|
'node_modules/',
|
||||||
'-Z',
|
'-Z',
|
||||||
'-f',
|
'-f',
|
||||||
'coverage.xml',
|
'coverage.xml',
|
||||||
@@ -94,24 +126,42 @@ test('upload args', () => {
|
|||||||
'test',
|
'test',
|
||||||
'-F',
|
'-F',
|
||||||
'test2',
|
'test2',
|
||||||
|
'--git-service',
|
||||||
|
'github_enterprise',
|
||||||
|
'--handle-no-reports-found',
|
||||||
|
'--job-code',
|
||||||
|
'32',
|
||||||
|
'-n',
|
||||||
|
'codecov',
|
||||||
|
'--network-filter',
|
||||||
|
'subA/',
|
||||||
|
'--network-prefix',
|
||||||
|
'forA/',
|
||||||
'-B',
|
'-B',
|
||||||
'thomasrockhu/test',
|
'thomasrockhu/test',
|
||||||
'-b',
|
'-b',
|
||||||
'1',
|
'1',
|
||||||
|
'--build-url',
|
||||||
|
'https://example.com/build/2',
|
||||||
'-C',
|
'-C',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'-P',
|
'-P',
|
||||||
'2',
|
'2',
|
||||||
|
'--plugin',
|
||||||
|
'xcode',
|
||||||
|
'--plugin',
|
||||||
|
'pycoverage',
|
||||||
|
'--plugin',
|
||||||
|
'compress-pycoverage',
|
||||||
|
'--report-code',
|
||||||
|
'testCode',
|
||||||
'--network-root-folder',
|
'--network-root-folder',
|
||||||
'root/',
|
'root/',
|
||||||
'-s',
|
'-s',
|
||||||
'coverage/',
|
'coverage/',
|
||||||
'-r',
|
'-r',
|
||||||
'fakeOwner/fakeRepo',
|
'fakeOwner/fakeRepo',
|
||||||
'--plugin',
|
'--legacy',
|
||||||
'xcode',
|
|
||||||
'--exclude',
|
|
||||||
'src',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(uploadExecArgs).toEqual(expectedArgs);
|
expect(uploadExecArgs).toEqual(expectedArgs);
|
||||||
@@ -122,45 +172,32 @@ test('upload args', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('report args', () => {
|
test('report args', async () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
git_service: 'github_enterprise',
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: 'fakePR',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
fail_ci_if_error: 'true',
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {reportExecArgs, reportCommand} = buildReportExec();
|
const {reportExecArgs, reportCommand} = await buildReportExec();
|
||||||
|
|
||||||
expect(reportExecArgs).toEqual(
|
const expectedArgs = [
|
||||||
expect.arrayContaining([
|
'--git-service',
|
||||||
'-C',
|
'github_enterprise',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'-C',
|
||||||
'--slug',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'fakeOwner/fakeRepo',
|
'-P',
|
||||||
]));
|
'fakePR',
|
||||||
expect(reportCommand).toEqual('create-report');
|
'--slug',
|
||||||
for (const env of Object.keys(envs)) {
|
'fakeOwner/fakeRepo',
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
'-Z',
|
||||||
}
|
];
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
test('report args using context', () => {
|
|
||||||
const envs = {
|
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
|
||||||
};
|
|
||||||
for (const env of Object.keys(envs)) {
|
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
|
||||||
}
|
|
||||||
const expectedArgs : string[] = [];
|
|
||||||
if (context.eventName == 'pull_request') {
|
|
||||||
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const {reportExecArgs, reportCommand} = buildReportExec();
|
|
||||||
|
|
||||||
expect(reportExecArgs).toEqual(expectedArgs);
|
expect(reportExecArgs).toEqual(expectedArgs);
|
||||||
expect(reportCommand).toEqual('create-report');
|
expect(reportCommand).toEqual('create-report');
|
||||||
@@ -170,46 +207,85 @@ test('report args using context', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('commit args', () => {
|
test('report args using context', async () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
};
|
||||||
|
for (const env of Object.keys(envs)) {
|
||||||
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
|
}
|
||||||
|
const expectedArgs: string[] = [
|
||||||
|
'--git-service',
|
||||||
|
'github',
|
||||||
|
];
|
||||||
|
if (context.eventName == 'pull_request') {
|
||||||
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const {reportExecArgs, reportCommand} = await buildReportExec();
|
||||||
|
|
||||||
|
expect(reportExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(reportCommand).toEqual('create-report');
|
||||||
|
for (const env of Object.keys(envs)) {
|
||||||
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('commit args', async () => {
|
||||||
|
const envs = {
|
||||||
|
git_service: 'github_enterprise',
|
||||||
|
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
||||||
|
override_branch: 'thomasrockhu/test',
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: '2',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
override_branch: 'thomasrockhu/test',
|
fail_ci_if_error: 'true',
|
||||||
override_pr: '2',
|
|
||||||
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {commitExecArgs, commitCommand} = buildCommitExec();
|
const {commitExecArgs, commitCommand} = await buildCommitExec();
|
||||||
|
const expectedArgs = [
|
||||||
|
'--parent-sha',
|
||||||
|
'83231650328f11695dfb754ca0f540516f188d27',
|
||||||
|
'--git-service',
|
||||||
|
'github_enterprise',
|
||||||
|
'-B',
|
||||||
|
'thomasrockhu/test',
|
||||||
|
'-C',
|
||||||
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
'--pr',
|
||||||
|
'2',
|
||||||
|
'--slug',
|
||||||
|
'fakeOwner/fakeRepo',
|
||||||
|
'-Z',
|
||||||
|
];
|
||||||
|
|
||||||
expect(commitExecArgs).toEqual(
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect.arrayContaining([
|
|
||||||
'-C',
|
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
|
||||||
'--slug',
|
|
||||||
'fakeOwner/fakeRepo',
|
|
||||||
'-B',
|
|
||||||
'thomasrockhu/test',
|
|
||||||
'--pr',
|
|
||||||
'2',
|
|
||||||
'--parent-sha',
|
|
||||||
'83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
]));
|
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('commit args using context', () => {
|
test('commit args using context', async () => {
|
||||||
const expectedArgs :string[] = [];
|
const expectedArgs: string[] = [
|
||||||
|
'--git-service',
|
||||||
|
'github',
|
||||||
|
];
|
||||||
|
|
||||||
const {commitExecArgs, commitCommand} = buildCommitExec();
|
const {commitExecArgs, commitCommand} = await buildCommitExec();
|
||||||
|
if (
|
||||||
|
(context.eventName == 'pull_request' || context.eventName == 'pull_request_target') &&
|
||||||
|
context.payload.pull_request?.base.label.split(':')[0] != context.payload.pull_request?.head.label.split(':')[0]
|
||||||
|
) {
|
||||||
|
expectedArgs.push('-B', `${context.payload.pull_request?.head.label}`);
|
||||||
|
}
|
||||||
if (context.eventName == 'pull_request') {
|
if (context.eventName == 'pull_request') {
|
||||||
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
}
|
}
|
||||||
if (context.eventName == 'pull_request_target') {
|
if (context.eventName == 'pull_request_target') {
|
||||||
expectedArgs.push('-P', `${context.payload.number}`);
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
@@ -218,3 +294,75 @@ test('commit args using context', () => {
|
|||||||
expect(commitExecArgs).toEqual(expectedArgs);
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('commit args using github server url', async () => {
|
||||||
|
const expectedArgs: string[] = [
|
||||||
|
'--git-service',
|
||||||
|
'github_enterprise',
|
||||||
|
];
|
||||||
|
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://example.com';
|
||||||
|
|
||||||
|
const {commitExecArgs, commitCommand} = await buildCommitExec();
|
||||||
|
if (
|
||||||
|
(context.eventName == 'pull_request' || context.eventName == 'pull_request_target') &&
|
||||||
|
context.payload.pull_request?.base.label.split(':')[0] != context.payload.pull_request?.head.label.split(':')[0]
|
||||||
|
) {
|
||||||
|
expectedArgs.push('-B', `${context.payload.pull_request?.head.label}`);
|
||||||
|
}
|
||||||
|
if (context.eventName == 'pull_request') {
|
||||||
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
|
}
|
||||||
|
if (context.eventName == 'pull_request_target') {
|
||||||
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(commitCommand).toEqual('create-commit');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('build commit args when token arg is unset and from fork', async () => {
|
||||||
|
context.eventName = 'pull_request';
|
||||||
|
context.payload.pull_request = {
|
||||||
|
'number': 1,
|
||||||
|
'base': {
|
||||||
|
'label': 'hello:main',
|
||||||
|
},
|
||||||
|
'head': {
|
||||||
|
'label': 'world:feat',
|
||||||
|
'sha': 'aaaaaa',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedArgs: string[] = [
|
||||||
|
'--git-service',
|
||||||
|
'github_enterprise',
|
||||||
|
'-B',
|
||||||
|
'world:feat',
|
||||||
|
'-C',
|
||||||
|
`${context.payload.pull_request?.head.sha}`,
|
||||||
|
];
|
||||||
|
|
||||||
|
const {commitExecArgs, commitCommand} = await buildCommitExec();
|
||||||
|
|
||||||
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(commitCommand).toEqual('create-commit');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get token when token arg is unset and from fork', async () => {
|
||||||
|
context.eventName = 'pull_request';
|
||||||
|
context.payload.pull_request = {
|
||||||
|
'number': 1,
|
||||||
|
'base': {
|
||||||
|
'label': 'hello:main',
|
||||||
|
},
|
||||||
|
'head': {
|
||||||
|
'label': 'world:feat',
|
||||||
|
'sha': 'aaaaaa',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const token = await getToken();
|
||||||
|
|
||||||
|
expect(token).toEqual('');
|
||||||
|
});
|
||||||
|
|||||||
309
src/buildExec.ts
309
src/buildExec.ts
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
import {type PullRequestEvent} from '@octokit/webhooks-types';
|
||||||
|
|
||||||
|
import {setFailure} from './helpers';
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
||||||
const isTrue = (variable) => {
|
const isTrue = (variable: string): boolean => {
|
||||||
const lowercase = variable.toLowerCase();
|
const lowercase = variable.toLowerCase();
|
||||||
return (
|
return (
|
||||||
lowercase === '1' ||
|
lowercase === '1' ||
|
||||||
@@ -17,20 +19,81 @@ const isTrue = (variable) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getGitService = (): string => {
|
||||||
|
const overrideGitService = core.getInput('git_service');
|
||||||
|
const serverUrl = process.env.GITHUB_SERVER_URL;
|
||||||
|
if (overrideGitService) {
|
||||||
|
return overrideGitService;
|
||||||
|
} else if (serverUrl !== undefined && serverUrl !== 'https://github.com') {
|
||||||
|
return 'github_enterprise';
|
||||||
|
}
|
||||||
|
return 'github';
|
||||||
|
};
|
||||||
|
|
||||||
const buildCommitExec = () => {
|
const isPullRequestFromFork = (): boolean => {
|
||||||
|
core.info(`eventName: ${context.eventName}`);
|
||||||
|
if (!['pull_request', 'pull_request_target'].includes(context.eventName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseLabel = context.payload.pull_request.base.label;
|
||||||
|
const headLabel = context.payload.pull_request.head.label;
|
||||||
|
|
||||||
|
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
|
||||||
|
return baseLabel.split(':')[0] !== headLabel.split(':')[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
const getToken = async (): Promise<string> => {
|
||||||
|
let token = core.getInput('token');
|
||||||
|
let url = core.getInput('url');
|
||||||
|
const useOIDC = isTrue(core.getInput('use_oidc'));
|
||||||
|
if (useOIDC) {
|
||||||
|
if (!url) {
|
||||||
|
url = 'https://codecov.io';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
token = await core.getIDToken(url);
|
||||||
|
return Promise.resolve(token);
|
||||||
|
} catch (err) {
|
||||||
|
setFailure(
|
||||||
|
`Codecov: Failed to get OIDC token with url: ${url}. ${err.message}`,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getOverrideBranch = (token: string): string => {
|
||||||
|
let overrideBranch = core.getInput('override_branch');
|
||||||
|
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
||||||
|
core.info('==> Fork detected, tokenless uploading used');
|
||||||
|
// backwards compatibility with certain versions of the CLI that expect this
|
||||||
|
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||||
|
overrideBranch =context.payload.pull_request.head.label;
|
||||||
|
}
|
||||||
|
return overrideBranch;
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildCommitExec = async (): Promise<{
|
||||||
|
commitExecArgs: any[];
|
||||||
|
commitOptions: any;
|
||||||
|
commitCommand: string;
|
||||||
|
}> => {
|
||||||
const commitParent = core.getInput('commit_parent');
|
const commitParent = core.getInput('commit_parent');
|
||||||
const overrideBranch = core.getInput('override_branch');
|
const gitService = getGitService();
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = await getToken();
|
||||||
|
const overrideBranch = getOverrideBranch(token);
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
const commitCommand = 'create-commit';
|
const commitCommand = 'create-commit';
|
||||||
const commitExecArgs = [];
|
const commitExecArgs: string[] = [];
|
||||||
|
|
||||||
const commitOptions:any = {};
|
const commitOptions: any = {};
|
||||||
commitOptions.env = Object.assign(process.env, {
|
commitOptions.env = Object.assign(process.env, {
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
@@ -40,47 +103,58 @@ const buildCommitExec = () => {
|
|||||||
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
commitOptions.env.CODECOV_TOKEN = token;
|
commitOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
if (commitParent) {
|
if (commitParent) {
|
||||||
commitExecArgs.push('--parent-sha', `${commitParent}`);
|
commitExecArgs.push('--parent-sha', commitParent);
|
||||||
}
|
}
|
||||||
|
commitExecArgs.push('--git-service', gitService);
|
||||||
|
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
commitExecArgs.push('-B', `${overrideBranch}`);
|
commitExecArgs.push('-B', overrideBranch);
|
||||||
}
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
commitExecArgs.push('-C', `${overrideCommit}`);
|
commitExecArgs.push('-C', overrideCommit);
|
||||||
} else if (
|
} else if (
|
||||||
`${context.eventName}` == 'pull_request' ||
|
['pull_request', 'pull_request_target'].includes(context.eventName)
|
||||||
`${context.eventName}` == 'pull_request_target'
|
|
||||||
) {
|
) {
|
||||||
commitExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
const payload = context.payload as PullRequestEvent;
|
||||||
|
commitExecArgs.push('-C', payload.pull_request.head.sha);
|
||||||
}
|
}
|
||||||
if (overridePr) {
|
if (overridePr) {
|
||||||
commitExecArgs.push('--pr', `${overridePr}`);
|
commitExecArgs.push('--pr', overridePr);
|
||||||
} else if (
|
} else if (context.eventName === 'pull_request_target') {
|
||||||
`${context.eventName}` == 'pull_request_target'
|
const payload = context.payload as PullRequestEvent;
|
||||||
) {
|
commitExecArgs.push('--pr', payload.number.toString());
|
||||||
commitExecArgs.push('--pr', `${context.payload.number}`);
|
|
||||||
}
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
commitExecArgs.push('--slug', `${slug}`);
|
commitExecArgs.push('--slug', slug);
|
||||||
|
}
|
||||||
|
if (failCi) {
|
||||||
|
commitExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
if (workingDir) {
|
||||||
|
commitOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {commitExecArgs, commitOptions, commitCommand};
|
return {commitExecArgs, commitOptions, commitCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildGeneralExec = () => {
|
const buildGeneralExec = (): {
|
||||||
|
args: any[];
|
||||||
|
verbose: boolean;
|
||||||
|
} => {
|
||||||
|
const codecovYmlPath = core.getInput('codecov_yml_path');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
|
if (codecovYmlPath) {
|
||||||
|
args.push('--codecov-yml-path', codecovYmlPath);
|
||||||
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
args.push('--enterprise-url', `${url}`);
|
args.push('--enterprise-url', url);
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
args.push('-v');
|
args.push('-v');
|
||||||
@@ -88,16 +162,23 @@ const buildGeneralExec = () => {
|
|||||||
return {args, verbose};
|
return {args, verbose};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildReportExec = () => {
|
const buildReportExec = async (): Promise<{
|
||||||
|
reportExecArgs: any[];
|
||||||
|
reportOptions: any;
|
||||||
|
reportCommand: string;
|
||||||
|
}> => {
|
||||||
|
const gitService = getGitService();
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = await getToken();
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
const reportCommand = 'create-report';
|
const reportCommand = 'create-report';
|
||||||
const reportExecArgs = [];
|
const reportExecArgs: string[] = [];
|
||||||
|
|
||||||
const reportOptions:any = {};
|
const reportOptions: any = {};
|
||||||
reportOptions.env = Object.assign(process.env, {
|
reportOptions.env = Object.assign(process.env, {
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
@@ -107,54 +188,85 @@ const buildReportExec = () => {
|
|||||||
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
reportOptions.env.CODECOV_TOKEN = token;
|
reportOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
reportExecArgs.push('--git-service', gitService);
|
||||||
|
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
reportExecArgs.push('-C', `${overrideCommit}`);
|
reportExecArgs.push('-C', overrideCommit);
|
||||||
} else if (
|
} else if (
|
||||||
`${context.eventName}` == 'pull_request' ||
|
['pull_request', 'pull_request_target'].includes(context.eventName)
|
||||||
`${context.eventName}` == 'pull_request_target'
|
|
||||||
) {
|
) {
|
||||||
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
const payload = context.payload as PullRequestEvent;
|
||||||
|
reportExecArgs.push('-C', payload.pull_request.head.sha);
|
||||||
|
}
|
||||||
|
if (overridePr) {
|
||||||
|
reportExecArgs.push('-P', overridePr);
|
||||||
|
} else if (context.eventName == 'pull_request_target') {
|
||||||
|
const payload = context.payload as PullRequestEvent;
|
||||||
|
reportExecArgs.push('-P', payload.number.toString());
|
||||||
}
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
reportExecArgs.push('--slug', `${slug}`);
|
reportExecArgs.push('--slug', slug);
|
||||||
|
}
|
||||||
|
if (failCi) {
|
||||||
|
reportExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
if (workingDir) {
|
||||||
|
reportOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {reportExecArgs, reportOptions, reportCommand};
|
return {reportExecArgs, reportOptions, reportCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildUploadExec = () => {
|
const buildUploadExec = async (): Promise<{
|
||||||
const envVars = core.getInput('env_vars');
|
uploadExecArgs: any[];
|
||||||
|
uploadOptions: any;
|
||||||
|
disableSafeDirectory: boolean;
|
||||||
|
failCi: boolean;
|
||||||
|
os: string;
|
||||||
|
uploaderVersion: string;
|
||||||
|
uploadCommand: string;
|
||||||
|
}> => {
|
||||||
|
const disableFileFixes = isTrue(core.getInput('disable_file_fixes'));
|
||||||
|
const disableSafeDirectory = isTrue(core.getInput('disable_safe_directory'));
|
||||||
|
const disableSearch = isTrue(core.getInput('disable_search'));
|
||||||
const dryRun = isTrue(core.getInput('dry_run'));
|
const dryRun = isTrue(core.getInput('dry_run'));
|
||||||
|
const envVars = core.getInput('env_vars');
|
||||||
|
const exclude = core.getInput('exclude');
|
||||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
const file = core.getInput('file');
|
const file = core.getInput('file');
|
||||||
const files = core.getInput('files');
|
const files = core.getInput('files');
|
||||||
const flags = core.getInput('flags');
|
const flags = core.getInput('flags');
|
||||||
|
const gitService = getGitService();
|
||||||
|
const handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found'));
|
||||||
|
const jobCode = core.getInput('job_code');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
|
const networkFilter = core.getInput('network_filter');
|
||||||
|
const networkPrefix = core.getInput('network_prefix');
|
||||||
const os = core.getInput('os');
|
const os = core.getInput('os');
|
||||||
const overrideBranch = core.getInput('override_branch');
|
const overrideBranch = core.getInput('override_branch');
|
||||||
const overrideBuild = core.getInput('override_build');
|
const overrideBuild = core.getInput('override_build');
|
||||||
|
const overrideBuildUrl = core.getInput('override_build_url');
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
|
const plugin = core.getInput('plugin');
|
||||||
|
const plugins = core.getInput('plugins');
|
||||||
|
const reportCode = core.getInput('report_code');
|
||||||
const rootDir = core.getInput('root_dir');
|
const rootDir = core.getInput('root_dir');
|
||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = await getToken();
|
||||||
let uploaderVersion = core.getInput('version');
|
let uploaderVersion = core.getInput('version');
|
||||||
const workingDir = core.getInput('working-directory');
|
const useLegacyUploadEndpoint = isTrue(
|
||||||
const plugin = core.getInput('plugin');
|
core.getInput('use_legacy_upload_endpoint'),
|
||||||
const exclude = core.getInput('exclude');
|
|
||||||
|
|
||||||
const uploadExecArgs = [];
|
|
||||||
uploadExecArgs.push(
|
|
||||||
'-n',
|
|
||||||
`${name}`,
|
|
||||||
);
|
);
|
||||||
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
|
const uploadExecArgs: string[] = [];
|
||||||
const uploadCommand = 'do-upload';
|
const uploadCommand = 'do-upload';
|
||||||
const uploadOptions:any = {};
|
const uploadOptions: any = {};
|
||||||
uploadOptions.env = Object.assign(process.env, {
|
uploadOptions.env = Object.assign(process.env, {
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
@@ -172,79 +284,125 @@ const buildUploadExec = () => {
|
|||||||
envVarsArg.push(envVarClean);
|
envVarsArg.push(envVarClean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
uploadOptions.env.CODECOV_TOKEN = token;
|
uploadOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
if (disableFileFixes) {
|
||||||
|
uploadExecArgs.push('--disable-file-fixes');
|
||||||
|
}
|
||||||
|
if (disableSearch) {
|
||||||
|
uploadExecArgs.push('--disable-search');
|
||||||
|
}
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
uploadExecArgs.push('-d');
|
uploadExecArgs.push('-d');
|
||||||
}
|
}
|
||||||
if (envVarsArg.length) {
|
if (envVarsArg.length) {
|
||||||
uploadExecArgs.push('-e', envVarsArg.join(','));
|
uploadExecArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
}
|
||||||
|
if (exclude) {
|
||||||
|
uploadExecArgs.push('--exclude', exclude);
|
||||||
|
}
|
||||||
if (failCi) {
|
if (failCi) {
|
||||||
uploadExecArgs.push('-Z');
|
uploadExecArgs.push('-Z');
|
||||||
}
|
}
|
||||||
if (file) {
|
if (file) {
|
||||||
uploadExecArgs.push('-f', `${file}`);
|
uploadExecArgs.push('-f', file);
|
||||||
}
|
}
|
||||||
if (files) {
|
if (files) {
|
||||||
files.split(',').map((f) => f.trim()).forEach((f) => {
|
files
|
||||||
uploadExecArgs.push('-f', `${f}`);
|
.split(',')
|
||||||
});
|
.map((f) => f.trim())
|
||||||
|
.forEach((f) => {
|
||||||
|
if (f.length > 0) {
|
||||||
|
// this handles trailing commas
|
||||||
|
uploadExecArgs.push('-f', f);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (flags) {
|
if (flags) {
|
||||||
flags.split(',').map((f) => f.trim()).forEach((f) => {
|
flags
|
||||||
uploadExecArgs.push('-F', `${f}`);
|
.split(',')
|
||||||
});
|
.map((f) => f.trim())
|
||||||
|
.forEach((f) => {
|
||||||
|
uploadExecArgs.push('-F', f);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadExecArgs.push('--git-service', gitService);
|
||||||
|
if (handleNoReportsFound) {
|
||||||
|
uploadExecArgs.push('--handle-no-reports-found');
|
||||||
|
}
|
||||||
|
if (jobCode) {
|
||||||
|
uploadExecArgs.push('--job-code', jobCode);
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
uploadExecArgs.push('-n', name);
|
||||||
|
}
|
||||||
|
if (networkFilter) {
|
||||||
|
uploadExecArgs.push('--network-filter', networkFilter);
|
||||||
|
}
|
||||||
|
if (networkPrefix) {
|
||||||
|
uploadExecArgs.push('--network-prefix', networkPrefix);
|
||||||
}
|
}
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
uploadExecArgs.push('-B', `${overrideBranch}`);
|
uploadExecArgs.push('-B', overrideBranch);
|
||||||
}
|
}
|
||||||
if (overrideBuild) {
|
if (overrideBuild) {
|
||||||
uploadExecArgs.push('-b', `${overrideBuild}`);
|
uploadExecArgs.push('-b', overrideBuild);
|
||||||
|
}
|
||||||
|
if (overrideBuildUrl) {
|
||||||
|
uploadExecArgs.push('--build-url', overrideBuildUrl);
|
||||||
}
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
uploadExecArgs.push('-C', `${overrideCommit}`);
|
uploadExecArgs.push('-C', overrideCommit);
|
||||||
} else if (
|
} else if (
|
||||||
`${context.eventName}` == 'pull_request' ||
|
['pull_request', 'pull_request_target'].includes(context.eventName)
|
||||||
`${context.eventName}` == 'pull_request_target'
|
|
||||||
) {
|
) {
|
||||||
uploadExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
const payload = context.payload as PullRequestEvent;
|
||||||
|
uploadExecArgs.push('-C', payload.pull_request.head.sha);
|
||||||
}
|
}
|
||||||
if (overridePr) {
|
if (overridePr) {
|
||||||
uploadExecArgs.push('-P', `${overridePr}`);
|
uploadExecArgs.push('-P', overridePr);
|
||||||
} else if (
|
} else if (context.eventName == 'pull_request_target') {
|
||||||
`${context.eventName}` == 'pull_request_target'
|
const payload = context.payload as PullRequestEvent;
|
||||||
) {
|
uploadExecArgs.push('-P', payload.number.toString());
|
||||||
uploadExecArgs.push('-P', `${context.payload.number}`);
|
}
|
||||||
|
if (plugin) {
|
||||||
|
uploadExecArgs.push('--plugin', plugin);
|
||||||
|
}
|
||||||
|
if (plugins) {
|
||||||
|
plugins
|
||||||
|
.split(',')
|
||||||
|
.map((p) => p.trim())
|
||||||
|
.forEach((p) => {
|
||||||
|
uploadExecArgs.push('--plugin', p);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (reportCode) {
|
||||||
|
uploadExecArgs.push('--report-code', reportCode);
|
||||||
}
|
}
|
||||||
if (rootDir) {
|
if (rootDir) {
|
||||||
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
uploadExecArgs.push('--network-root-folder', rootDir);
|
||||||
}
|
}
|
||||||
if (searchDir) {
|
if (searchDir) {
|
||||||
uploadExecArgs.push('-s', `${searchDir}`);
|
uploadExecArgs.push('-s', searchDir);
|
||||||
}
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
uploadExecArgs.push('-r', `${slug}`);
|
uploadExecArgs.push('-r', slug);
|
||||||
}
|
}
|
||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
uploadOptions.cwd = workingDir;
|
uploadOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
if (plugin) {
|
|
||||||
uploadExecArgs.push('--plugin', `${plugin}`);
|
|
||||||
}
|
|
||||||
if (exclude) {
|
|
||||||
uploadExecArgs.push('--exclude', `${exclude}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uploaderVersion == '') {
|
if (uploaderVersion == '') {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
if (useLegacyUploadEndpoint) {
|
||||||
|
uploadExecArgs.push('--legacy');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uploadExecArgs,
|
uploadExecArgs,
|
||||||
uploadOptions,
|
uploadOptions,
|
||||||
|
disableSafeDirectory,
|
||||||
failCi,
|
failCi,
|
||||||
os,
|
os,
|
||||||
uploaderVersion,
|
uploaderVersion,
|
||||||
@@ -258,4 +416,5 @@ export {
|
|||||||
buildGeneralExec,
|
buildGeneralExec,
|
||||||
buildReportExec,
|
buildReportExec,
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
|
getToken,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
PLATFORMS,
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
|
getCommand,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
isWindows,
|
isWindows,
|
||||||
PLATFORMS,
|
setSafeDirectory,
|
||||||
getCommand,
|
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
let OLDOS = process.env.RUNNER_OS;
|
let OLDOS = process.env.RUNNER_OS;
|
||||||
@@ -43,6 +46,9 @@ test('getBaseUrl', () => {
|
|||||||
'https://cli.codecov.io/latest/linux/codecov',
|
'https://cli.codecov.io/latest/linux/codecov',
|
||||||
'https://cli.codecov.io/latest/macos/codecov',
|
'https://cli.codecov.io/latest/macos/codecov',
|
||||||
'https://cli.codecov.io/latest/windows/codecov.exe',
|
'https://cli.codecov.io/latest/windows/codecov.exe',
|
||||||
|
'https://cli.codecov.io/latest/alpine/codecov',
|
||||||
|
'https://cli.codecov.io/latest/linux-arm64/codecov',
|
||||||
|
'https://cli.codecov.io/latest/alpine-arm64/codecov',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
@@ -51,19 +57,22 @@ test('getBaseUrl', () => {
|
|||||||
'https://cli.codecov.io/v0.1.0_8880/linux/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/linux/codecov',
|
||||||
'https://cli.codecov.io/v0.1.0_8880/macos/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/macos/codecov',
|
||||||
'https://cli.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
'https://cli.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/alpine/codecov',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/linux-arm64/codecov',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/alpine-arm64/codecov',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isWindows', () => {
|
test('isWindows', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isWindows(platform);
|
return isWindows(platform);
|
||||||
})).toEqual([false, false, true]);
|
})).toEqual([false, false, true, false, false, false]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isValidPlatform', () => {
|
test('isValidPlatform', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isValidPlatform(platform);
|
return isValidPlatform(platform);
|
||||||
})).toEqual([true, true, true]);
|
})).toEqual([true, true, true, true, true, true]);
|
||||||
|
|
||||||
expect(isValidPlatform('fakeos')).toBeFalsy();
|
expect(isValidPlatform('fakeos')).toBeFalsy();
|
||||||
});
|
});
|
||||||
@@ -72,3 +81,16 @@ test('getCommand', () => {
|
|||||||
expect(getCommand('path', ['-v', '-x'], 'do-upload'))
|
expect(getCommand('path', ['-v', '-x'], 'do-upload'))
|
||||||
.toEqual(['path', '-v', '-x', 'do-upload']);
|
.toEqual(['path', '-v', '-x', 'do-upload']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('setSafeDirectory', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = 'testOrg/testRepo';
|
||||||
|
await setSafeDirectory();
|
||||||
|
const testSafeDirectory = ([
|
||||||
|
'git',
|
||||||
|
'config',
|
||||||
|
'--get',
|
||||||
|
'safe.directory',
|
||||||
|
]).join(' ');
|
||||||
|
const safeDirectory = await exec.getExecOutput(testSafeDirectory);
|
||||||
|
expect(safeDirectory.stdout).toBe('testOrg/testRepo\n');
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
const PLATFORMS = [
|
const PLATFORMS = [
|
||||||
'linux',
|
'linux',
|
||||||
'macos',
|
'macos',
|
||||||
'windows',
|
'windows',
|
||||||
];
|
'alpine',
|
||||||
|
'linux-arm64',
|
||||||
|
'alpine-arm64',
|
||||||
|
] as const;
|
||||||
|
type Platform = typeof PLATFORMS[number];
|
||||||
|
|
||||||
const setFailure = (message: string, failCi: boolean): void => {
|
const setFailure = (message: string, failCi: boolean): void => {
|
||||||
failCi ? core.setFailed(message) : core.warning(message);
|
if (failCi) {
|
||||||
if (failCi) {
|
core.setFailed(message);
|
||||||
process.exit();
|
} else {
|
||||||
}
|
core.warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failCi) {
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUploaderName = (platform: string): string => {
|
const getUploaderName = (platform: string): string => {
|
||||||
@@ -21,8 +31,8 @@ const getUploaderName = (platform: string): string => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidPlatform = (platform: string): boolean => {
|
const isValidPlatform = (platform: string): platform is Platform => {
|
||||||
return PLATFORMS.includes(platform);
|
return PLATFORMS.includes(platform as Platform);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isWindows = (platform: string): boolean => {
|
const isWindows = (platform: string): boolean => {
|
||||||
@@ -61,6 +71,19 @@ const getCommand = (
|
|||||||
return fullCommand;
|
return fullCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setSafeDirectory = async () => {
|
||||||
|
const command = ([
|
||||||
|
'git',
|
||||||
|
'config',
|
||||||
|
'--global',
|
||||||
|
'--add',
|
||||||
|
'safe.directory',
|
||||||
|
`${process.env['GITHUB_WORKSPACE']}`,
|
||||||
|
].join(' '));
|
||||||
|
core.info(`==> Running ${command}`);
|
||||||
|
await exec.exec(command);
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
@@ -69,5 +92,6 @@ export {
|
|||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
isWindows,
|
isWindows,
|
||||||
setFailure,
|
setFailure,
|
||||||
|
setSafeDirectory,
|
||||||
getCommand,
|
getCommand,
|
||||||
};
|
};
|
||||||
|
|||||||
175
src/index.ts
175
src/index.ts
@@ -1,6 +1,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
|
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
@@ -12,10 +12,11 @@ import {
|
|||||||
} from './buildExec';
|
} from './buildExec';
|
||||||
import {
|
import {
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
|
getCommand,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
setFailure,
|
setFailure,
|
||||||
getCommand,
|
setSafeDirectory,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import verify from './validate';
|
import verify from './validate';
|
||||||
@@ -23,98 +24,106 @@ import versionInfo from './version';
|
|||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
const run = async (): Promise<void> => {
|
||||||
const {commitExecArgs, commitOptions, commitCommand} = buildCommitExec();
|
try {
|
||||||
const {reportExecArgs, reportOptions, reportCommand} = buildReportExec();
|
const {commitExecArgs, commitOptions, commitCommand} = await buildCommitExec();
|
||||||
const {
|
const {reportExecArgs, reportOptions, reportCommand} = await buildReportExec();
|
||||||
uploadExecArgs,
|
const {
|
||||||
uploadOptions,
|
uploadExecArgs,
|
||||||
failCi,
|
uploadOptions,
|
||||||
os,
|
disableSafeDirectory,
|
||||||
uploaderVersion,
|
failCi,
|
||||||
uploadCommand,
|
os,
|
||||||
} = buildUploadExec();
|
uploaderVersion,
|
||||||
const {args, verbose} = buildGeneralExec();
|
uploadCommand,
|
||||||
|
} = await buildUploadExec();
|
||||||
|
const {args, verbose} = buildGeneralExec();
|
||||||
|
|
||||||
const platform = getPlatform(os);
|
const platform = getPlatform(os);
|
||||||
|
|
||||||
const filename = path.join( __dirname, getUploaderName(platform));
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
// Image will be stored at this path
|
// Image will be stored at this path
|
||||||
const filePath = fs.createWriteStream(filename);
|
const filePath = fs.createWriteStream(filename);
|
||||||
res.pipe(filePath);
|
res.pipe(filePath);
|
||||||
filePath
|
filePath
|
||||||
.on('error', (err) => {
|
.on('error', (err) => {
|
||||||
setFailure(
|
setFailure(
|
||||||
`Codecov: Failed to write uploader binary: ${err.message}`,
|
`Codecov: Failed to write uploader binary: ${err.message}`,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}).on('finish', async () => {
|
}).on('finish', async () => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
|
|
||||||
await verify(filename, platform, uploaderVersion, verbose, failCi);
|
await verify(filename, platform, uploaderVersion, verbose, failCi);
|
||||||
await versionInfo(platform, uploaderVersion);
|
await versionInfo(platform, uploaderVersion);
|
||||||
await fs.chmodSync(filename, '777');
|
await fs.chmodSync(filename, '777');
|
||||||
|
if (!disableSafeDirectory) {
|
||||||
|
await setSafeDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
const unlink = () => {
|
const unlink = (): void => {
|
||||||
fs.unlink(filename, (err) => {
|
fs.unlink(filename, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
setFailure(
|
|
||||||
`Codecov: Could not unlink uploader: ${err.message}`,
|
|
||||||
failCi,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const doUpload = async () => {
|
|
||||||
await exec.exec(getCommand(filename, args, uploadCommand).join(' '),
|
|
||||||
uploadExecArgs,
|
|
||||||
uploadOptions)
|
|
||||||
.catch((err) => {
|
|
||||||
setFailure(
|
setFailure(
|
||||||
`Codecov:
|
`Codecov: Could not unlink uploader: ${err.message}`,
|
||||||
Failed to properly upload report: ${err.message}`,
|
|
||||||
failCi,
|
failCi,
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
};
|
});
|
||||||
const createReport = async () => {
|
};
|
||||||
|
const doUpload = async (): Promise<void> => {
|
||||||
|
await exec.exec(getCommand(filename, args, uploadCommand).join(' '),
|
||||||
|
uploadExecArgs,
|
||||||
|
uploadOptions)
|
||||||
|
.catch((err) => {
|
||||||
|
setFailure(
|
||||||
|
`Codecov:
|
||||||
|
Failed to properly upload report: ${err.message}`,
|
||||||
|
failCi,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const createReport = async (): Promise<void> => {
|
||||||
|
await exec.exec(
|
||||||
|
getCommand(filename, args, reportCommand).join(' '),
|
||||||
|
reportExecArgs,
|
||||||
|
reportOptions)
|
||||||
|
.then(async (exitCode) => {
|
||||||
|
if (exitCode == 0) {
|
||||||
|
await doUpload();
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
setFailure(
|
||||||
|
`Codecov:
|
||||||
|
Failed to properly create report: ${err.message}`,
|
||||||
|
failCi,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
getCommand(filename, args, reportCommand).join(' '),
|
getCommand(
|
||||||
reportExecArgs,
|
filename,
|
||||||
reportOptions)
|
args,
|
||||||
|
commitCommand,
|
||||||
|
).join(' '),
|
||||||
|
commitExecArgs, commitOptions)
|
||||||
.then(async (exitCode) => {
|
.then(async (exitCode) => {
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
await doUpload();
|
await createReport();
|
||||||
}
|
}
|
||||||
|
unlink();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
setFailure(
|
setFailure(
|
||||||
`Codecov:
|
`Codecov: Failed to properly create commit: ${err.message}`,
|
||||||
Failed to properly create report: ${err.message}`,
|
|
||||||
failCi,
|
failCi,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
await exec.exec(
|
});
|
||||||
getCommand(
|
} catch (err) {
|
||||||
filename,
|
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);
|
||||||
args,
|
}
|
||||||
commitCommand,
|
};
|
||||||
).join(' '),
|
|
||||||
commitExecArgs, commitOptions)
|
run();
|
||||||
.then(async (exitCode) => {
|
|
||||||
if (exitCode == 0) {
|
|
||||||
await createReport();
|
|
||||||
}
|
|
||||||
unlink();
|
|
||||||
}).catch((err) => {
|
|
||||||
setFailure(
|
|
||||||
`Codecov: Failed to properly create commit: ${err.message}`,
|
|
||||||
failCi,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);
|
|
||||||
}
|
|
||||||
|
|||||||
129
src/validate.ts
129
src/validate.ts
@@ -1,10 +1,10 @@
|
|||||||
import * as crypto from 'crypto';
|
import {execSync} from 'node:child_process';
|
||||||
import * as fs from 'fs';
|
import * as crypto from 'node:crypto';
|
||||||
import * as path from 'path';
|
import * as fs from 'node:fs';
|
||||||
|
import * as path from 'node:path';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as openpgp from 'openpgp';
|
import {request} from 'undici';
|
||||||
import * as fetch from 'node-fetch';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
@@ -22,68 +22,97 @@ const verify = async (
|
|||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName(platform);
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
// Read in public key
|
|
||||||
const publicKeyArmored = await fs.readFileSync(
|
|
||||||
path.join(__dirname, 'pgp_keys.asc'),
|
|
||||||
'utf-8',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
const shasumRes = await fetch.default(
|
const shasumRes = await request(
|
||||||
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
||||||
);
|
);
|
||||||
const shasum = await shasumRes.text();
|
const shasum = await shasumRes.body.text();
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
console.log(`Received SHA256SUM ${shasum}`);
|
console.log(`Received SHA256SUM ${shasum}`);
|
||||||
}
|
}
|
||||||
|
await fs.writeFileSync(
|
||||||
|
path.join(__dirname, `${uploaderName}.SHA256SUM`),
|
||||||
|
shasum,
|
||||||
|
);
|
||||||
|
|
||||||
const shaSigRes = await fetch.default(
|
const shaSigRes = await request(
|
||||||
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
||||||
);
|
);
|
||||||
const shaSig = await shaSigRes.text();
|
const shaSig = await shaSigRes.body.text();
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
console.log(`Received SHA256SUM signature ${shaSig}`);
|
console.log(`Received SHA256SUM signature ${shaSig}`);
|
||||||
}
|
}
|
||||||
|
await fs.writeFileSync(
|
||||||
|
path.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
|
||||||
|
shaSig,
|
||||||
|
);
|
||||||
|
|
||||||
// Verify shasum
|
const validateSha = async () => {
|
||||||
const verified = await openpgp.verify({
|
const calculateHash = async (filename: string) => {
|
||||||
message: await openpgp.createMessage({text: shasum}),
|
const stream = fs.createReadStream(filename);
|
||||||
signature: await openpgp.readSignature({armoredSignature: shaSig}),
|
const uploaderSha = crypto.createHash(`sha256`);
|
||||||
verificationKeys: await openpgp.readKeys({armoredKeys: publicKeyArmored}),
|
stream.pipe(uploaderSha);
|
||||||
});
|
|
||||||
const valid = await verified.signatures[0].verified;
|
return new Promise((resolve, reject) => {
|
||||||
if (valid) {
|
stream.on('end', () => resolve(
|
||||||
core.info('==> SHASUM file signed by key id ' +
|
`${uploaderSha.digest('hex')} ${uploaderName}`,
|
||||||
verified.signatures[0].keyID.toHex(),
|
));
|
||||||
|
stream.on('error', reject);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const hash = await calculateHash(
|
||||||
|
path.join(__dirname, `${uploaderName}`),
|
||||||
);
|
);
|
||||||
} else {
|
if (hash === shasum) {
|
||||||
setFailure('Codecov: Error validating SHASUM signature', failCi);
|
core.info(`==> Uploader SHASUM verified (${hash})`);
|
||||||
}
|
} else {
|
||||||
|
setFailure(
|
||||||
const calculateHash = async (filename: string) => {
|
'Codecov: Uploader shasum does not match -- ' +
|
||||||
const stream = fs.createReadStream(filename);
|
`uploader hash: ${hash}, public hash: ${shasum}`,
|
||||||
const uploaderSha = crypto.createHash(`sha256`);
|
failCi,
|
||||||
stream.pipe(uploaderSha);
|
);
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
stream.on('end', () => resolve(
|
|
||||||
`${uploaderSha.digest('hex')} ${uploaderName}`,
|
|
||||||
));
|
|
||||||
stream.on('error', reject);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const hash = await calculateHash(filename);
|
const verifySignature = async () => {
|
||||||
if (hash === shasum) {
|
const command = [
|
||||||
core.info(`==> Uploader SHASUM verified (${hash})`);
|
'gpg',
|
||||||
} else {
|
'--logger-fd',
|
||||||
setFailure(
|
'1',
|
||||||
'Codecov: Uploader shasum does not match -- ' +
|
'--verify',
|
||||||
`uploader hash: ${hash}, public hash: ${shasum}`,
|
path.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
|
||||||
failCi,
|
path.join(__dirname, `${uploaderName}.SHA256SUM`),
|
||||||
);
|
].join(' ');
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
await execSync(command, {stdio: 'inherit'});
|
||||||
|
} catch (err) {
|
||||||
|
setFailure(`Codecov: Error verifying gpg signature: ${err.message}`, failCi);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const importKey = async () => {
|
||||||
|
const command = [
|
||||||
|
'gpg',
|
||||||
|
'--logger-fd',
|
||||||
|
'1',
|
||||||
|
'--no-default-keyring',
|
||||||
|
'--import',
|
||||||
|
path.join(__dirname, 'pgp_keys.asc'),
|
||||||
|
].join(' ');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await execSync(command, {stdio: 'inherit'});
|
||||||
|
} catch (err) {
|
||||||
|
setFailure(`Codecov: Error importing gpg key: ${err.message}`, failCi);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await importKey();
|
||||||
|
await verifySignature();
|
||||||
|
await validateSha();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setFailure(`Codecov: Error validating uploader: ${err.message}`, failCi);
|
setFailure(`Codecov: Error validating uploader: ${err.message}`, failCi);
|
||||||
}
|
}
|
||||||
|
|||||||
62
src/version.test.ts
Normal file
62
src/version.test.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import {Agent, MockAgent, setGlobalDispatcher} from 'undici';
|
||||||
|
|
||||||
|
import versionInfo from './version';
|
||||||
|
|
||||||
|
const mockAgent = new MockAgent();
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
setGlobalDispatcher(mockAgent);
|
||||||
|
mockAgent.disableNetConnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await mockAgent.close();
|
||||||
|
setGlobalDispatcher(new Agent());
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('versionInfo', () => {
|
||||||
|
const platform = 'linux';
|
||||||
|
|
||||||
|
test('should resolve requested version info', async () => {
|
||||||
|
const version = 'latest';
|
||||||
|
const coreInfoSpy = jest.spyOn(core, 'info');
|
||||||
|
|
||||||
|
mockAgent
|
||||||
|
.get('https://cli.codecov.io')
|
||||||
|
.intercept({
|
||||||
|
path: `/${platform}/${version}`,
|
||||||
|
})
|
||||||
|
.reply(200, {
|
||||||
|
version: 'v0.5.2',
|
||||||
|
});
|
||||||
|
|
||||||
|
await versionInfo(platform, version);
|
||||||
|
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledTimes(2);
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledWith('==> Running version latest');
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledWith('==> Running version v0.5.2');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should handle unsupported version', async () => {
|
||||||
|
const version = 'unsupported';
|
||||||
|
const coreInfoSpy = jest.spyOn(core, 'info');
|
||||||
|
|
||||||
|
mockAgent
|
||||||
|
.get('https://cli.codecov.io')
|
||||||
|
.intercept({
|
||||||
|
path: `/${platform}/${version}`,
|
||||||
|
})
|
||||||
|
.reply(404, 'MESSAGE');
|
||||||
|
|
||||||
|
await versionInfo(platform, version);
|
||||||
|
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledTimes(2);
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledWith('==> Running version unsupported');
|
||||||
|
expect(coreInfoSpy).toHaveBeenCalledWith(expect.stringContaining('Could not pull latest version information'));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as fetch from 'node-fetch';
|
import {request} from 'undici';
|
||||||
|
|
||||||
const versionInfo = async (
|
const versionInfo = async (
|
||||||
platform: string,
|
platform: string,
|
||||||
version?: string,
|
version: string,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
if (version) {
|
core.info(`==> Running version ${version}`);
|
||||||
core.info(`==> Running version ${version}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const metadataRes = await fetch.default( `https://uploader.codecov.io/${platform}/latest`, {
|
const metadataRes = await request(`https://cli.codecov.io/${platform}/${version}`, {
|
||||||
headers: {'Accept': 'application/json'},
|
headers: {'Accept': 'application/json'},
|
||||||
});
|
});
|
||||||
const metadata = await metadataRes.json();
|
const metadata = await metadataRes.body.json();
|
||||||
core.info(`==> Running version ${metadata['version']}`);
|
core.info(`==> Running version ${metadata['version']}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.info(`Could not pull latest version information: ${err}`);
|
core.info(`Could not pull latest version information: ${err}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user