Skip to content

Commit 12b0ced

Browse files
CLDSRV-732: Fix flakiness starting cloudserver
The CI fails to wait for S3 after 40s recently s3-stderr has those logs: ``` npm error code E403 npm error 403 403 Forbidden - GET https://registry.npmjs.org/nyc npm error 403 In most cases, you or one of your dependencies are requesting npm error 403 a package version that is forbidden by your security policy, or npm error 403 on a server you do not have access to. npm error A complete log of this run can be found in: /root/.npm/_logs/2025-08-26T12_00_55_746Z-debug-0.log ``` Build another image to include nyc and a command for coverage during tests
1 parent 0cbe863 commit 12b0ced

4 files changed

Lines changed: 41 additions & 17 deletions

File tree

.github/docker/docker-compose.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
services:
22
cloudserver:
3-
image: ${CLOUDSERVER_IMAGE}
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 2> /artifacts/s3-stderr.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-
"
3+
image: ${CLOUDSERVER_IMAGE}-testcoverage
194
network_mode: "host"
205
volumes:
216
- /tmp/ssl:/ssl

.github/workflows/tests.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ jobs:
178178
with:
179179
push: true
180180
context: .
181+
target: production
181182
provenance: false
182183
tags: |
183184
ghcr.io/${{ github.repository }}:${{ github.sha }}
@@ -187,6 +188,21 @@ jobs:
187188
cache-from: type=gha,scope=cloudserver
188189
cache-to: type=gha,mode=max,scope=cloudserver
189190

191+
- name: Build and push cloudserver image test coverage
192+
uses: docker/build-push-action@v5
193+
with:
194+
push: true
195+
context: .
196+
target: testcoverage
197+
provenance: false
198+
tags: |
199+
ghcr.io/${{ github.repository }}:${{ github.sha }}-testcoverage
200+
labels: |
201+
git.repository=${{ github.repository }}
202+
git.commit-sha=${{ github.sha }}
203+
cache-from: type=gha,scope=cloudserver
204+
cache-to: type=gha,mode=max,scope=cloudserver
205+
190206
- name: Build and push federation image
191207
uses: docker/build-push-action@v5
192208
with:

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ COPY package.json yarn.lock /usr/src/app/
3030
RUN yarn install --production --ignore-optional --frozen-lockfile --ignore-engines --network-concurrency 1
3131

3232
################################################################################
33-
FROM node:${NODE_VERSION}
33+
FROM node:${NODE_VERSION} AS production
3434

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

5757
CMD [ "yarn", "start" ]
58+
59+
################################################################################
60+
FROM production AS testcoverage
61+
62+
RUN yarn add nyc
63+
64+
CMD [ "./docker-test-with-coverage.sh" ]

docker-test-with-coverage.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
yarn nyc --clean --silent yarn start > /artifacts/s3.log 2> /artifacts/s3-stderr.log &
4+
5+
PID=$!
6+
7+
generate_coverage() {
8+
echo 'Stopping NodeJS processes...'
9+
kill -TERM $PID 2>/dev/null || true
10+
wait $PID
11+
echo 'Generating coverage report...'
12+
yarn nyc report --report-dir /coverage/test --reporter=lcov --reporter=text-summary
13+
}
14+
15+
trap generate_coverage SIGTERM
16+
wait $PID

0 commit comments

Comments
 (0)