ci: Use one artifact for all coverage files
Instead of three separate artifacts.
This commit is contained in:
committed by
Benjamin Bouvier
parent
2c964b07ab
commit
eff57ad483
@@ -120,29 +120,17 @@ jobs:
|
||||
echo "Storing commit SHA ${{ github.event.pull_request.head.sha }}"
|
||||
echo "${{ github.event.pull_request.head.sha }}" > commit_sha.txt
|
||||
|
||||
# Workaround for https://github.com/orgs/community/discussions/25220
|
||||
# Triggered sub-workflow is not able to detect the original commit/PR which is available
|
||||
# in this workflow.
|
||||
- name: Store PR number in artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pr_number
|
||||
path: pr_number.txt
|
||||
|
||||
- name: Store commit SHA in artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: commit_sha
|
||||
path: commit_sha.txt
|
||||
|
||||
# This stores the coverage report in artifacts. The actual upload to Codecov
|
||||
# is executed by a different workflow `upload_coverage.yml`. The reason for this
|
||||
# split is because `on.pull_request` workflows don't have access to secrets.
|
||||
# This stores the coverage report and metadata in artifacts.
|
||||
# The actual upload to Codecov is executed by a different workflow `upload_coverage.yml`.
|
||||
# The reason for this split is because `on.pull_request` workflows don't have access to secrets.
|
||||
- name: Store coverage report in artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: codecov_report
|
||||
path: codecov_report.json
|
||||
path: |
|
||||
codecov_report.json
|
||||
pr_number.txt
|
||||
commit_sha.txt
|
||||
|
||||
- run: |
|
||||
echo 'The coverage report was stored in Github artifacts.'
|
||||
|
||||
@@ -46,43 +46,9 @@ jobs:
|
||||
});
|
||||
fs.writeFileSync('codecov_report.zip', Buffer.from(download.data));
|
||||
|
||||
let prNumber = artifacts.data.artifacts.filter((artifact) => {
|
||||
return artifact.name == "pr_number";
|
||||
});
|
||||
|
||||
if (prNumber.length != 1) {
|
||||
throw new Error("Unexpected number of {pr_number} artifacts: " + prNumber.length);
|
||||
}
|
||||
|
||||
var download = await github.rest.actions.downloadArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: prNumber[0].id,
|
||||
archive_format: 'zip',
|
||||
});
|
||||
fs.writeFileSync('pr_number.zip', Buffer.from(download.data));
|
||||
|
||||
let commitSha = artifacts.data.artifacts.filter((artifact) => {
|
||||
return artifact.name == "commit_sha";
|
||||
});
|
||||
|
||||
if (commitSha.length != 1) {
|
||||
throw new Error("Unexpected number of {commit_sha} artifacts: " + commitSha.length);
|
||||
}
|
||||
|
||||
var download = await github.rest.actions.downloadArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: commitSha[0].id,
|
||||
archive_format: 'zip',
|
||||
});
|
||||
fs.writeFileSync('commit_sha.zip', Buffer.from(download.data));
|
||||
|
||||
- id: parse_previous_artifacts
|
||||
run: |
|
||||
unzip codecov_report.zip
|
||||
unzip pr_number.zip
|
||||
unzip commit_sha.zip
|
||||
|
||||
echo "Detected PR is: $(<pr_number.txt)"
|
||||
echo "Detected commit_sha is: $(<commit_sha.txt)"
|
||||
|
||||
Reference in New Issue
Block a user