Skip to content

test: test-project switch from mounting to building image with docker #1482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 23, 2025
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ Thumbs.db
**/coverage
.nyc_output
test-results

**/Dockerfile
**/docker-compose*.yml
**/docker-compose*.yaml
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ensure script files have LF line endings
*.sh text eol=lf
*.bash text eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/pr-testing-with-test-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ jobs:
shell: bash
- if: steps.should_run.outputs.shouldrun == 'true'
name: Run test
run: NODE_IMAGE_TAG=${{ matrix.node }} docker compose up --abort-on-container-exit --force-recreate
run: NODE_VERSION=${{ matrix.node }} docker compose up --abort-on-container-exit --force-recreate
working-directory: ./apps/generator/test/test-project
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:18-alpine AS base
ARG NODE_VERSION=18
FROM node:${NODE_VERSION}-alpine AS base

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions apps/generator/test/test-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ The purpose of this project is to test AsyncAPI Generator library use case outsi

Instead of running tests with `npm test`, make sure you have Docker Compose and run the following command:

Linux/MacOS: `NODE_IMAGE_TAG=18 docker-compose up --abort-on-container-exit --force-recreate`.
Linux/MacOS: `NODE_VERSION=18 docker-compose up --abort-on-container-exit --force-recreate`.

Windows: `set NODE_IMAGE_TAG=18&& docker-compose up --abort-on-container-exit --force-recreate`.
Windows: `set NODE_VERSION=18&& docker-compose up --abort-on-container-exit --force-recreate`.
22 changes: 7 additions & 15 deletions apps/generator/test/test-project/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
version: '3'

services:
verdaccio:
image: verdaccio/verdaccio:5
ports:
- '4873:4873'
volumes:
- './verdaccio:/verdaccio/conf'
networks:
- mynetwork

test-project:
privileged: true
image: "node:${NODE_IMAGE_TAG}"
volumes:
- ../../../../:/apptemp
command: bash /apptemp/apps/generator/test/test-project/test-entrypoint.sh
networks:
- mynetwork

networks:
mynetwork:
driver: bridge
pull_policy: build
build:
context: ../../../../ # Root of the project
args:
NODE_VERSION: ${NODE_VERSION}
user: root # Use root user to avoid permission issues when creating directories
command: ["sh", "/app/apps/generator/test/test-project/test.sh", "test-project"]
12 changes: 0 additions & 12 deletions apps/generator/test/test-project/test-entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion apps/generator/test/test-project/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Starting registry test
sudo chown -R 1001:121 "/root/.npm"

# Always run these steps
cd app
cd /app
Copy link

@coderabbitai coderabbitai bot Apr 22, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle potential cd /app failure
The new absolute path change is correct, but without error handling a failed cd could let subsequent commands run in the wrong directory.
Apply this diff to exit on failure:

- cd /app
+ cd /app || exit 1

This aligns with ShellCheck SC2164.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd /app
- cd /app
+ cd /app || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 54-54: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

Copy link
Member

Choose a reason for hiding this comment

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

@nightknighto you don't like rabbit? 😄

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor Author

@nightknighto nightknighto Apr 23, 2025

Choose a reason for hiding this comment

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

It's good in many things, but this suggestion definitely isn't 😂


echo "##########
Running installation in root
Expand Down