Skip to content

Commit da1c5e6

Browse files
author
Kerkesni
committed
add coverage to functional tests
Issue: CLDSRV-618
1 parent 84174ed commit da1c5e6

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Cleanup and Coverage'
2+
description: 'Stops CI services and uploads coverage reports to Codecov'
3+
4+
inputs:
5+
profiles:
6+
description: 'Docker Compose profiles to use (space-separated)'
7+
required: false
8+
default: ''
9+
codecov-token:
10+
description: 'Codecov token for uploading reports'
11+
required: true
12+
flags:
13+
description: 'Flags to identify the coverage report'
14+
required: false
15+
default: '${{ github.job }}'
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Stop CI services
21+
run: |
22+
PROFILES=""
23+
for profile in ${{ inputs.profiles }}; do
24+
PROFILES="${PROFILES} --profile ${profile}"
25+
done
26+
docker compose ${PROFILES} down
27+
shell: bash
28+
working-directory: .github/docker
29+
30+
- name: Upload coverage reports to Codecov
31+
uses: codecov/codecov-action@v5
32+
with:
33+
token: ${{ inputs.codecov-token }}
34+
directory: /tmp/coverage/${{ github.job }}
35+
flags: ${{ inputs.flags }}
36+
if: ${{ !cancelled() }}

.github/actions/setup-ci/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ runs:
1616
run: |-
1717
set -exu;
1818
mkdir -p /tmp/artifacts/${JOB_NAME}/;
19+
- name: Setup coverage directory
20+
shell: bash
21+
run: |-
22+
set -exu;
23+
mkdir -p /tmp/coverage/${JOB_NAME}/;
1924
- uses: actions/setup-node@v4
2025
with:
2126
node-version: '22'

.github/docker/docker-compose.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
services:
22
cloudserver:
33
image: ${CLOUDSERVER_IMAGE}
4-
command: sh -c "yarn start > /artifacts/s3.log"
4+
command: |
5+
bash -c "
6+
# Using tini to handle signals properly
7+
tini -s -g -- npx nyc --clean --silent yarn start > /artifacts/s3.log &
8+
PID=$$!
9+
generate_coverage() {
10+
echo 'Stopping NodeJS processes...'
11+
kill -TERM $$PID 2>/dev/null || true
12+
wait $$PID
13+
echo 'Generating coverage report...'
14+
npx nyc report --report-dir /coverage/test --reporter=lcov --reporter=text-summary
15+
}
16+
trap generate_coverage SIGTERM
17+
wait $$PID
18+
"
519
network_mode: "host"
620
volumes:
721
- /tmp/ssl:/ssl
822
- /tmp/ssl-kmip:/ssl-kmip
923
- ${HOME}/.aws/credentials:/root/.aws/credentials
1024
- /tmp/artifacts/${JOB_NAME}:/artifacts
25+
- /tmp/coverage/${JOB_NAME}:/coverage/test
1126
environment:
1227
- CI=true
1328
- ENABLE_LOCAL_CACHE=true

.github/workflows/tests.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ jobs:
253253
yarn run multiple_backend_test | tee /tmp/artifacts/${{ github.job }}/tests.log
254254
env:
255255
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
256+
- name: Cleanup and upload coverage
257+
uses: ./.github/actions/cleanup-and-coverage
258+
with:
259+
profiles: 'sproxyd mongo'
260+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
261+
if: always()
256262
- name: Upload logs to artifacts
257263
uses: scality/action-artifacts@v4
258264
with:
@@ -291,6 +297,12 @@ jobs:
291297
yarn run ft_test | tee /tmp/artifacts/${{ github.job }}/tests.log
292298
env:
293299
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
300+
- name: Cleanup and upload coverage
301+
uses: ./.github/actions/cleanup-and-coverage
302+
with:
303+
profiles: 'mongo'
304+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
305+
if: always()
294306
- name: Upload logs to artifacts
295307
uses: scality/action-artifacts@v4
296308
with:
@@ -331,6 +343,12 @@ jobs:
331343
yarn run ft_mixed_bucket_format_version | tee /tmp/artifacts/${{ github.job }}/mixed-tests.log
332344
env:
333345
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
346+
- name: Cleanup and upload coverage
347+
uses: ./.github/actions/cleanup-and-coverage
348+
with:
349+
profiles: 'mongo'
350+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
351+
if: always()
334352
- name: Upload logs to artifacts
335353
uses: scality/action-artifacts@v4
336354
with:
@@ -374,6 +392,12 @@ jobs:
374392
set -o pipefail;
375393
bash wait_for_local_port.bash 8000 40
376394
yarn run ft_test | tee /tmp/artifacts/${{ matrix.job-name }}/tests.log
395+
- name: Cleanup and upload coverage
396+
uses: ./.github/actions/cleanup-and-coverage
397+
with:
398+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
399+
flags: ${{ matrix.job-name }}
400+
if: always()
377401
- name: Upload logs to artifacts
378402
uses: scality/action-artifacts@v4
379403
with:
@@ -408,6 +432,11 @@ jobs:
408432
set -ex -o pipefail;
409433
bash wait_for_local_port.bash 8000 40
410434
yarn run test_utapi_v2 | tee /tmp/artifacts/${{ github.job }}/tests.log
435+
- name: Cleanup and upload coverage
436+
uses: ./.github/actions/cleanup-and-coverage
437+
with:
438+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
439+
if: always()
411440
- name: Upload logs to artifacts
412441
uses: scality/action-artifacts@v4
413442
with:
@@ -452,6 +481,13 @@ jobs:
452481
set -ex -o pipefail;
453482
bash wait_for_local_port.bash 8000 40
454483
yarn run test_quota | tee /tmp/artifacts/${{ github.job }}/tests.log
484+
- name: Cleanup and upload coverage
485+
uses: ./.github/actions/cleanup-and-coverage
486+
with:
487+
profiles: 'mongo'
488+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
489+
flags: ${{ github.job }}${{ matrix.inflights.value == 'true' && '-inflights' || '' }}
490+
if: always()
455491
- name: Upload logs to artifacts
456492
uses: scality/action-artifacts@v4
457493
with:
@@ -490,6 +526,12 @@ jobs:
490526
bash wait_for_local_port.bash 8000 40
491527
bash wait_for_local_port.bash 5696 40
492528
yarn run ft_kmip | tee /tmp/artifacts/${{ github.job }}/tests.log
529+
- name: Cleanup and upload coverage
530+
uses: ./.github/actions/cleanup-and-coverage
531+
with:
532+
profiles: 'pykmip'
533+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
534+
if: always()
493535
- name: Upload logs to artifacts
494536
uses: scality/action-artifacts@v4
495537
with:
@@ -568,6 +610,12 @@ jobs:
568610
S3BACKEND: file
569611
S3VAULT: mem
570612
S3METADATA: mongodb
613+
- name: Cleanup and upload coverage
614+
uses: ./.github/actions/cleanup-and-coverage
615+
with:
616+
profiles: 'ceph'
617+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
618+
if: always()
571619
- name: Upload logs to artifacts
572620
uses: scality/action-artifacts@v4
573621
with:

0 commit comments

Comments
 (0)