Skip to content

Commit cde97fa

Browse files
author
Kerkesni
committed
add coverage to functional tests
Issue: CLDSRV-618
1 parent 401a990 commit cde97fa

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
# Read from environment variable to avoid syntax issues
24+
# related to gha templating
25+
for profile in $INPUT_PROFILES; do
26+
PROFILES="${PROFILES} --profile ${profile}"
27+
done
28+
docker compose ${PROFILES} down
29+
shell: bash
30+
env:
31+
INPUT_PROFILES: ${{ inputs.profiles }}
32+
working-directory: .github/docker
33+
34+
- name: Upload coverage reports to Codecov
35+
uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ inputs.codecov-token }}
38+
directory: /tmp/coverage/${{ github.job }}
39+
flags: ${{ inputs.flags }}
40+
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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ 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: >
260+
sproxyd
261+
mongo
262+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
263+
if: always()
256264
- name: Upload logs to artifacts
257265
uses: scality/action-artifacts@v4
258266
with:
@@ -291,6 +299,12 @@ jobs:
291299
yarn run ft_test | tee /tmp/artifacts/${{ github.job }}/tests.log
292300
env:
293301
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
302+
- name: Cleanup and upload coverage
303+
uses: ./.github/actions/cleanup-and-coverage
304+
with:
305+
profiles: mongo
306+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
307+
if: always()
294308
- name: Upload logs to artifacts
295309
uses: scality/action-artifacts@v4
296310
with:
@@ -331,6 +345,12 @@ jobs:
331345
yarn run ft_mixed_bucket_format_version | tee /tmp/artifacts/${{ github.job }}/mixed-tests.log
332346
env:
333347
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
348+
- name: Cleanup and upload coverage
349+
uses: ./.github/actions/cleanup-and-coverage
350+
with:
351+
profiles: mongo
352+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
353+
if: always()
334354
- name: Upload logs to artifacts
335355
uses: scality/action-artifacts@v4
336356
with:
@@ -374,6 +394,12 @@ jobs:
374394
set -o pipefail;
375395
bash wait_for_local_port.bash 8000 40
376396
yarn run ft_test | tee /tmp/artifacts/${{ matrix.job-name }}/tests.log
397+
- name: Cleanup and upload coverage
398+
uses: ./.github/actions/cleanup-and-coverage
399+
with:
400+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
401+
flags: ${{ matrix.job-name }}
402+
if: always()
377403
- name: Upload logs to artifacts
378404
uses: scality/action-artifacts@v4
379405
with:
@@ -408,6 +434,11 @@ jobs:
408434
set -ex -o pipefail;
409435
bash wait_for_local_port.bash 8000 40
410436
yarn run test_utapi_v2 | tee /tmp/artifacts/${{ github.job }}/tests.log
437+
- name: Cleanup and upload coverage
438+
uses: ./.github/actions/cleanup-and-coverage
439+
with:
440+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
441+
if: always()
411442
- name: Upload logs to artifacts
412443
uses: scality/action-artifacts@v4
413444
with:
@@ -452,6 +483,13 @@ jobs:
452483
set -ex -o pipefail;
453484
bash wait_for_local_port.bash 8000 40
454485
yarn run test_quota | tee /tmp/artifacts/${{ github.job }}/tests.log
486+
- name: Cleanup and upload coverage
487+
uses: ./.github/actions/cleanup-and-coverage
488+
with:
489+
profiles: mongo
490+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
491+
flags: ${{ github.job }}${{ matrix.inflights.value == 'true' && '-inflights' || '' }}
492+
if: always()
455493
- name: Upload logs to artifacts
456494
uses: scality/action-artifacts@v4
457495
with:
@@ -490,6 +528,12 @@ jobs:
490528
bash wait_for_local_port.bash 8000 40
491529
bash wait_for_local_port.bash 5696 40
492530
yarn run ft_kmip | tee /tmp/artifacts/${{ github.job }}/tests.log
531+
- name: Cleanup and upload coverage
532+
uses: ./.github/actions/cleanup-and-coverage
533+
with:
534+
profiles: pykmip
535+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
536+
if: always()
493537
- name: Upload logs to artifacts
494538
uses: scality/action-artifacts@v4
495539
with:
@@ -568,6 +612,12 @@ jobs:
568612
S3BACKEND: file
569613
S3VAULT: mem
570614
S3METADATA: mongodb
615+
- name: Cleanup and upload coverage
616+
uses: ./.github/actions/cleanup-and-coverage
617+
with:
618+
profiles: ceph
619+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
620+
if: always()
571621
- name: Upload logs to artifacts
572622
uses: scality/action-artifacts@v4
573623
with:

0 commit comments

Comments
 (0)