mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-02 18:06:16 +00:00
sonarcloud: skip sharded scan steps when the plan job produces no shards
This commit is contained in:
@@ -236,23 +236,23 @@ jobs:
|
||||
cargo llvm-cov --workspace --ignore-run-fail --lcov --output-path lcov.info
|
||||
--ignore-filename-regex "$COVERAGE_IGNORE"
|
||||
- name: Install LLVM tools
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1 && hashFiles('Cargo.toml') != ''
|
||||
run: rustup component add llvm-tools-preview
|
||||
- name: Download shard profiles and archive
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1 && hashFiles('Cargo.toml') != ''
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: profraw-*
|
||||
path: profraw
|
||||
merge-multiple: true
|
||||
- name: Download test archive
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1 && hashFiles('Cargo.toml') != ''
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: nextest-archive
|
||||
path: archive
|
||||
- name: Combine shard coverage
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1 && hashFiles('Cargo.toml') != ''
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -105,6 +105,16 @@ class SonarCloudTests(unittest.TestCase):
|
||||
self.assertIn('--archive-file archive/nextest-archive.tar.zst', tests['run'])
|
||||
self.assertEqual(workflow['jobs']['coverage']['needs'], ['plan', 'build'])
|
||||
|
||||
def test_sharded_scan_steps_only_run_when_the_plan_runs(self):
|
||||
workflow = yaml.load(
|
||||
(ROOT / '.github/workflows/sonarcloud.yml').read_text(), Loader=yaml.BaseLoader)
|
||||
sharded = [step for step in workflow['jobs']['sonarcloud']['steps']
|
||||
if 'inputs.shards > 1' in step.get('if', '')]
|
||||
self.assertGreaterEqual(len(sharded), 4)
|
||||
for step in sharded:
|
||||
with self.subTest(step=step.get('name')):
|
||||
self.assertIn("hashFiles('Cargo.toml') != ''", step['if'])
|
||||
|
||||
def test_scan_fails_when_a_prerequisite_job_failed(self):
|
||||
workflow = yaml.load(
|
||||
(ROOT / '.github/workflows/sonarcloud.yml').read_text(), Loader=yaml.BaseLoader)
|
||||
|
||||
Reference in New Issue
Block a user