From 84d03ee80c7509562226e54fcc0469ecc122beca Mon Sep 17 00:00:00 2001 From: Abdulrhmn Ghanem Date: Fri, 14 Oct 2022 07:43:31 +0200 Subject: [PATCH] processor: run tests as root in the container - We need to install packages, compile ts, and move assets before running the actual testing code. - The `node` user doesn't have permessions to do anything of these tasks. Update scripts/clear_volumes_and_test_processor.sh Co-authored-by: Kaspar Emanuel --- docker-compose.override.yml | 1 + processor/Dockerfile | 1 - scripts/clear_volumes_and_test_processor.sh | 7 +++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 1629a979b6..04192920ee 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -40,6 +40,7 @@ services: dockerfile: Dockerfile processor: + user: root build: context: processor/ dockerfile: Dockerfile diff --git a/processor/Dockerfile b/processor/Dockerfile index 0ab20e568e..2ff4ecebe9 100644 --- a/processor/Dockerfile +++ b/processor/Dockerfile @@ -33,4 +33,3 @@ RUN addgroup --gid 1000 node && \ USER node CMD ["node", "dist/src/server.js"] - diff --git a/scripts/clear_volumes_and_test_processor.sh b/scripts/clear_volumes_and_test_processor.sh index 51e70fc9fc..290dbf7ce3 100755 --- a/scripts/clear_volumes_and_test_processor.sh +++ b/scripts/clear_volumes_and_test_processor.sh @@ -20,8 +20,11 @@ docker-compose down -v # you can pass arguments to mocha e.g. `-g multi` args="$(concatenate_args "$@")" + +# We need to install packages, compile ts, and move assets before running the actual testing code. +# The `node` user doesn't have permission to do any of these tasks. docker-compose run \ - -u node \ + -u root \ -e LOG_LEVEL=debug \ -e DATA_DIR=/data/test \ - processor sh -c "whoami && stat /data /gitea-data /app" + processor sh -c "yarn install && yarn tsc && yarn cp-assets && yarn cp-test-assets && yarn test ${args}"