Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
services:
cloudserver:
image: ${CLOUDSERVER_IMAGE}
command: |
bash -c "
# Using tini to handle signals properly
tini -s -g -- npx nyc --clean --silent yarn start > /artifacts/s3.log 2> /artifacts/s3-stderr.log &
PID=$$!
generate_coverage() {
echo 'Stopping NodeJS processes...'
kill -TERM $$PID 2>/dev/null || true
wait $$PID
echo 'Generating coverage report...'
npx nyc report --report-dir /coverage/test --reporter=lcov --reporter=text-summary
}
trap generate_coverage SIGTERM
wait $$PID
"
network_mode: "host"
volumes:
- /tmp/ssl:/ssl
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,21 @@ jobs:
with:
context: .
push: true
target: production
tags: ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push test coverage image
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to create a new tagged image just for the coverage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there so you can run the docker compose from the CI for a specific releases version with coverage.

Copy link
Copy Markdown
Contributor Author

@BourgoisMickael BourgoisMickael Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed we could skip coverage outside CI when targetting a specific version.
But the image is small, there's only 1 additinal layer for nyc and a change of CMD, that's 15s build time

uses: docker/build-push-action@v5
with:
context: .
push: true
target: testcoverage
tags: ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}-testcoverage
cache-from: type=gha
cache-to: type=gha,mode=max
Comment thread
tcarmet marked this conversation as resolved.

- name: Build and push federation image
uses: docker/build-push-action@v5
with:
Expand Down
36 changes: 26 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ jobs:
with:
push: true
context: .
target: production
provenance: false
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
Expand All @@ -187,6 +188,21 @@ jobs:
cache-from: type=gha,scope=cloudserver
cache-to: type=gha,mode=max,scope=cloudserver

- name: Build and push cloudserver image test coverage
uses: docker/build-push-action@v5
with:
push: true
context: .
target: testcoverage
provenance: false
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
labels: |
git.repository=${{ github.repository }}
git.commit-sha=${{ github.sha }}
cache-from: type=gha,scope=cloudserver
cache-to: type=gha,mode=max,scope=cloudserver
Comment thread
tcarmet marked this conversation as resolved.

- name: Build and push federation image
uses: docker/build-push-action@v5
with:
Expand Down Expand Up @@ -229,7 +245,7 @@ jobs:
runs-on: ubuntu-24.04
needs: build
env:
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
S3BACKEND: mem
S3_LOCATION_FILE: /usr/src/app/tests/locationConfig/locationConfigTests.json
Expand Down Expand Up @@ -295,7 +311,7 @@ jobs:
S3_LOCATION_FILE: /usr/src/app/tests/locationConfig/locationConfigTests.json
DEFAULT_BUCKET_KEY_FORMAT: v0
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
JOB_NAME: ${{ github.job }}
steps:
- name: Checkout
Expand Down Expand Up @@ -348,7 +364,7 @@ jobs:
DEFAULT_BUCKET_KEY_FORMAT: v1
METADATA_MAX_CACHED_BUCKETS: 1
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
JOB_NAME: ${{ github.job }}
steps:
- name: Checkout
Expand Down Expand Up @@ -405,7 +421,7 @@ jobs:
env:
S3BACKEND: file
S3VAULT: mem
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
MPU_TESTING: "yes"
ENABLE_NULL_VERSION_COMPAT_MODE: "${{ matrix.enable-null-compat }}"
Expand Down Expand Up @@ -459,7 +475,7 @@ jobs:
ENABLE_UTAPI_V2: t
S3BACKEND: mem
BUCKET_DENY_FILTER: utapi-event-filter-deny-bucket
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
JOB_NAME: ${{ github.job }}
steps:
Expand Down Expand Up @@ -515,7 +531,7 @@ jobs:
SCUBA_HOST: localhost
SCUBA_PORT: 8100
SCUBA_HEALTHCHECK_FREQUENCY: 100
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
JOB_NAME: ${{ github.job }}
steps:
Expand Down Expand Up @@ -562,7 +578,7 @@ jobs:
S3BACKEND: file
S3VAULT: mem
MPU_TESTING: "yes"
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
PYKMIP_IMAGE: ghcr.io/${{ github.repository }}/pykmip:${{ github.sha }}
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
JOB_NAME: ${{ github.job }}
Expand Down Expand Up @@ -622,7 +638,7 @@ jobs:
S3BACKEND: file
S3VAULT: mem
MPU_TESTING: true
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
PYKMIP_IMAGE: ghcr.io/${{ github.repository }}/pykmip:${{ github.sha }}
JOB_NAME: ${{ github.job }}
COMPOSE_FILE: docker-compose.yaml:docker-compose.sse.yaml
Expand Down Expand Up @@ -688,7 +704,7 @@ jobs:
MPU_TESTING: "yes"
S3_LOCATION_FILE: /usr/src/app/tests/locationConfig/locationConfigCeph.json
MONGODB_IMAGE: ghcr.io/${{ github.repository }}/ci-mongodb:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
JOB_NAME: ${{ github.job }}
ENABLE_NULL_VERSION_COMPAT_MODE: true # needed with mongodb backend
steps:
Expand Down Expand Up @@ -809,7 +825,7 @@ jobs:
VAULT_VERSION_CURRENT: 7.70.32
CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION: ghcr.io/${{ github.repository }}:9.0.8
VAULT_IMAGE_BEFORE_SSE_MIGRATION: ghcr.io/scality/vault:7.70.31
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
VAULT_IMAGE: ghcr.io/scality/vault:7.70.32
KMS_IMAGE: nsmithuk/local-kms:3.11.7
MPU_TESTING: "yes"
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Comment thread
tcarmet marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COPY package.json yarn.lock /usr/src/app/
RUN yarn install --production --ignore-optional --frozen-lockfile --ignore-engines --network-concurrency 1

################################################################################
FROM node:${NODE_VERSION}
FROM node:${NODE_VERSION} AS production

ENV NO_PROXY=localhost,127.0.0.1
ENV no_proxy=localhost,127.0.0.1
Expand All @@ -55,3 +55,10 @@ VOLUME ["/usr/src/app/localData","/usr/src/app/localMetadata"]
ENTRYPOINT ["tini", "-g", "--", "/usr/src/app/docker-entrypoint.sh"]

CMD [ "yarn", "start" ]

################################################################################
FROM production AS testcoverage

RUN yarn global add nyc

CMD [ "./docker-test-with-coverage.sh" ]
16 changes: 16 additions & 0 deletions docker-test-with-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

Comment thread
BourgoisMickael marked this conversation as resolved.
nyc --clean --silent yarn start > /artifacts/s3.log 2> /artifacts/s3-stderr.log &

PID=$!

generate_coverage() {
echo 'Stopping NodeJS processes...'
kill -TERM $PID 2>/dev/null || true
wait $PID
Comment on lines +9 to +10
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a potential race condition where the process might exit before wait $PID is called, causing the wait to fail. Consider checking if the process is still running before waiting.

Suggested change
kill -TERM $PID 2>/dev/null || true
wait $PID
if kill -0 $PID 2>/dev/null; then
wait $PID
fi

Copilot uses AI. Check for mistakes.
echo 'Generating coverage report...'
nyc report --report-dir /coverage/test --reporter=lcov --reporter=text-summary
}

trap generate_coverage SIGTERM
wait $PID
Loading