-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feat/keploy experimental #149
base: develop
Are you sure you want to change the base?
Changes from all commits
cf4db5b
30a0ed7
46575ac
caed65c
b18d726
31b12be
6a8fd2e
4c6bafd
7a84be0
697b262
26b56b4
b65b817
f3d89a1
5f83fc8
6debdbb
4bda6e3
28c6c7a
8e0153d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Keploy | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
node_linux: | ||
runs-on: ubuntu-latest | ||
environment: secrets # Ensure you specify the environment if it's an environment-level secret | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js 20 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Print all environment variables for debugging | ||
run: printenv | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Install nyc | ||
run: yarn add [email protected] --dev | ||
|
||
- name: Install Docker | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Install Docker Compose | ||
run: | | ||
mkdir -p $HOME/.docker/cli-plugins | ||
curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64" -o $HOME/.docker/cli-plugins/docker-compose | ||
chmod +x $HOME/.docker/cli-plugins/docker-compose | ||
echo "$HOME/.docker/cli-plugins" >> $GITHUB_PATH | ||
docker-compose --version | ||
|
||
- name: Run the node-express-graphql template | ||
run: | | ||
docker compose -f docker-compose-1.yml --env-file=.env.docker up -d | ||
chmod +x /home/runner/work/node-express-graphql-template/node-express-graphql-template/.github/workflows/test_workflows/keploy.sh | ||
/home/runner/work/node-express-graphql-template/node-express-graphql-template/.github/workflows/test_workflows/keploy.sh | ||
env: | ||
KEPLOY_API_KEY: ${{ secrets.KEPLOY_API_KEY }} | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage/lcov.info | ||
verbose: true | ||
Comment on lines
+52
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Coverage data upload configuration. The
Analysis chainCoverage data upload configuration. Ensure that the specified coverage file path and token usage are correct and secure. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the coverage file path and token security.
# Test: Check the existence of the specified coverage file and validate the token usage. Expect: Correct file path and secure token handling.
ls ./coverage/lcov.info
Length of output: 93 Script: #!/bin/bash
# Description: Search for references to `lcov.info` in the keploy.yml workflow file to verify its generation and handling.
# Search for `lcov.info` references in the workflow file
rg 'lcov.info' .github/workflows/keploy.yml
Length of output: 79 Script: #!/bin/bash
# Description: Search for steps in the keploy.yml workflow file that run tests or generate coverage reports.
# Search for steps that run tests or generate coverage reports
rg -i 'test|coverage' .github/workflows/keploy.yml
Length of output: 421 Script: #!/bin/bash
# Description: Display the contents of the `keploy.sh` script to verify if it runs tests and generates the coverage report.
# Find the `keploy.sh` script
fd keploy.sh
# Display the contents of the `keploy.sh` script
cat $(fd keploy.sh)
Length of output: 36 Script: #!/bin/bash
# Description: Search for the `keploy.sh` script in the entire repository and display its path if found.
# Search for the `keploy.sh` script in the entire repository
fd keploy.sh
Length of output: 14 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
curl --silent -O -L https://keploy.io/ent/install.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure secure handling of downloaded files. Using + curl --silent -O -L https://keploy.io/ent/install.sh | shasum -a 256 -c expected_checksum_file
|
||
|
||
|
||
sudo docker compose --env-file .env.docker build | ||
curl --silent -o keployE --location "https://keploy-enterprise.s3.us-west-2.amazonaws.com/releases/latest/enterprise_linux_amd64" | ||
sudo chmod a+x keployE && sudo mkdir -p /usr/local/bin && sudo mv keployE /usr/local/bin | ||
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential security risk with broad permissions. Setting broad permissions with - sudo chmod a+x keployE && sudo mkdir -p /usr/local/bin && sudo mv keployE /usr/local/bin
+ sudo chmod u+x keployE && sudo mv keployE /usr/local/bin
|
||
|
||
|
||
# Build the project locally | ||
echo "Project built successfully" | ||
|
||
echo $(pwd) | ||
|
||
|
||
sudo -E env PATH="$PATH" /usr/local/bin/keployE test -c "sudo docker compose --env-file .env.docker up" --containerName "node-express-graphql-template-app-1" --delay 90 --apiTimeout 30 --generateGithubActions=false | ||
echo "Keploy started in test mode" | ||
|
||
all_passed=true | ||
|
||
# Loop through test sets | ||
for i in {0..1} | ||
do | ||
# Define the report file for each test set | ||
report_file="./keploy/reports/test-run-0/test-set-$i-report.yaml" | ||
|
||
# Extract the test status | ||
test_status=$(grep 'status:' "$report_file" | head -n 1 | awk '{print $2}') | ||
|
||
# Print the status for debugging | ||
echo "Test status for test-set-$i: $test_status" | ||
|
||
# Check if any test set did not pass | ||
if [ "$test_status" != "PASSED" ]; then | ||
all_passed=false | ||
echo "Test-set-$i did not pass." | ||
break # Exit the loop early as all tests need to pass | ||
fi | ||
done | ||
|
||
# Check the overall test status and exit accordingly | ||
if [ "$all_passed" = true ]; then | ||
docker cp node-express-graphql-template-app-1:$(pwd)/.nyc_output $(pwd)/.nyc_output | ||
npx nyc report | ||
echo "All tests passed" | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
FROM node:20 | ||
ARG ENVIRONMENT_NAME | ||
ARG BUILD_NAME | ||
ARG APP_PATH | ||
ARG PLATFORM | ||
|
||
RUN mkdir -p /app-build | ||
ADD . /app-build | ||
WORKDIR /app-build | ||
# RUN mkdir -p /app-build | ||
# ADD . /app-build | ||
# WORKDIR /app-build | ||
RUN mkdir -p ${APP_PATH} | ||
ADD . ${APP_PATH} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
- ADD . ${APP_PATH}
+ COPY . ${APP_PATH}
- ADD scripts/migrate-and-run.sh ${APP_PATH}/
+ COPY scripts/migrate-and-run.sh ${APP_PATH}/
- ADD package.json ${APP_PATH}/
+ COPY package.json ${APP_PATH}/
- ADD . ./
+ COPY . ./ Also applies to: 31-31, 32-32, 33-33 ToolsHadolint
|
||
WORKDIR ${APP_PATH} | ||
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn --frozen-lockfile | ||
RUN yarn | ||
RUN yarn build:$BUILD_NAME | ||
|
@@ -13,16 +18,25 @@ RUN yarn build:$BUILD_NAME | |
FROM node:20-alpine | ||
ARG ENVIRONMENT_NAME | ||
ARG BUILD_NAME | ||
ARG APP_PATH | ||
ARG PLATFORM | ||
|
||
RUN mkdir -p /dist | ||
WORKDIR ${APP_PATH} | ||
RUN mkdir -p ${APP_PATH}/dist | ||
RUN apk add yarn | ||
RUN yarn global add [email protected] | ||
RUN yarn add shelljs dotenv pg [email protected] | ||
ADD scripts/migrate-and-run.sh / | ||
ADD package.json / | ||
ADD . / | ||
COPY --from=0 /app-build/dist ./dist | ||
|
||
RUN yarn global add sequelize-cli@latest [email protected] | ||
RUN yarn add shelljs dotenv pg sequelize | ||
RUN apk add --no-cache dumb-init | ||
ADD scripts/migrate-and-run.sh ${APP_PATH}/ | ||
ADD package.json ${APP_PATH}/ | ||
ADD . ./ | ||
COPY --from=0 ${APP_PATH}/dist ${APP_PATH}/dist | ||
ADD https://keploy-enterprise.s3.us-west-2.amazonaws.com/releases/latest/assets/freeze_time_$PLATFORM.so /lib/keploy/freeze_time_$PLATFORM.so | ||
RUN chmod +x /lib/keploy/freeze_time_$PLATFORM.so | ||
ENV LD_PRELOAD=/lib/keploy/freeze_time_$PLATFORM.so | ||
ENTRYPOINT ["dumb-init", "--"] | ||
STOPSIGNAL SIGINT | ||
|
||
CMD ["sh", "./migrate-and-run.sh"] | ||
EXPOSE 9000 | ||
EXPOSE 9000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3' | ||
networks: | ||
node-express-graphql-template_default: {} | ||
services: | ||
db_postgres: | ||
networks: | ||
- node-express-graphql-template_default | ||
image: postgres | ||
ports: | ||
- 5432:5432 | ||
restart: always | ||
env_file: | ||
- ./.env.docker | ||
redis: | ||
networks: | ||
- node-express-graphql-template_default | ||
image: 'redis:alpine' | ||
depends_on: | ||
wait-for-db: | ||
condition: service_completed_successfully | ||
ports: | ||
- '6379:6379' | ||
command: ['redis-server', '--bind', 'redis', '--port', '6379'] | ||
wait-for-db: | ||
networks: | ||
- node-express-graphql-template_default | ||
image: atkrad/wait4x | ||
depends_on: | ||
- db_postgres | ||
command: tcp db_postgres:${POSTGRES_PORT} -t 30s -i 250ms |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
version: '3' | ||
networks: | ||
node-express-graphql-template_node-express-graphql-template_default: | ||
external: true | ||
services: | ||
db_postgres: | ||
image: postgres | ||
ports: | ||
- 5432:5432 | ||
restart: always | ||
env_file: | ||
- .env.docker | ||
redis: | ||
image: 'redis:alpine' | ||
ports: | ||
- '6379:6379' | ||
command: ['redis-server', '--bind', 'redis', '--port', '6379'] | ||
app: | ||
networks: | ||
- node-express-graphql-template_node-express-graphql-template_default | ||
build: | ||
context: . | ||
args: | ||
ENVIRONMENT_NAME: .docker | ||
BUILD_NAME: docker | ||
PLATFORM: amd64 | ||
APP_PATH: ${APP_PATH} | ||
restart: always | ||
depends_on: | ||
- db_postgres | ||
- redis | ||
ports: | ||
- 9000:9000 | ||
environment: | ||
ENABLE_DEDUP: "false" | ||
env_file: | ||
- ./.env.docker | ||
volumes: | ||
- ${APP_PATH}/dedupData.yaml:${APP_PATH}/dedupData.yaml | ||
stop_grace_period: 50s |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||
#!/bin/bash -x -i -e | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect shebang usage in script. The shebang should specify only one parameter. Consider modifying it to ensure compatibility across different operating systems. - #!/bin/bash -x -i -e
+ #!/bin/bash
+ set -x -i -e Committable suggestion
Suggested change
ToolsShellcheck
|
||||||||||
|
||||||||||
# Command to be executed | ||||||||||
alias keploy="docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v $(pwd):$(pwd) -w $(pwd) -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v /Users/apple/.keploy:/root/.keploy --rm docker.io/keploy/enterprise" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue with alias expansion. The alias for - alias keploy="docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v $(pwd):$(pwd) -w $(pwd) -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v /Users/apple/.keploy:/root/.keploy --rm docker.io/keploy/enterprise"
+ keploy() {
+ docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v $(pwd):$(pwd) -w $(pwd) -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v /Users/apple/.keploy:/root/.keploy --rm docker.io/keploy/enterprise "$@"
+ } Committable suggestion
Suggested change
ToolsShellcheck
|
||||||||||
|
||||||||||
# Number of times to run the command | ||||||||||
ITERATIONS=10 | ||||||||||
|
||||||||||
# Loop to execute the command | ||||||||||
for (( i=1; i<=$ITERATIONS; i++ )) | ||||||||||
do | ||||||||||
echo "Running iteration $i" | ||||||||||
keploy test -c 'docker compose --env-file .env.docker up' --containerName "fast-api-app" --delay 30 --freezeTime --testsets='test-set-1' | ||||||||||
echo "Iteration $i complete" | ||||||||||
echo "----------------------------------------" | ||||||||||
done | ||||||||||
|
||||||||||
echo "Script execution complete" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
path: "" | ||
appId: 0 | ||
appName: "" | ||
command: "" | ||
port: 0 | ||
proxyPort: 16789 | ||
dnsPort: 26789 | ||
debug: false | ||
disableANSI: false | ||
disableTele: false | ||
inDocker: false | ||
generateGithubActions: true | ||
containerName: "" | ||
networkName: "" | ||
buildDelay: 30 | ||
test: | ||
selectedTests: {} | ||
globalNoise: | ||
global: | ||
body: | ||
data.signIn.token: [] | ||
data.signUp.token: [] | ||
header: | ||
Etag: [] | ||
Vary: [] | ||
test-sets: {} | ||
delay: 5 | ||
apiTimeout: 5 | ||
coverage: false | ||
goCoverage: false | ||
coverageReportPath: "" | ||
ignoreOrdering: true | ||
mongoPassword: "default@123" | ||
language: "" | ||
removeUnusedMocks: false | ||
basePath: "" | ||
mocking: true | ||
dedup: true | ||
disableMockUpload: false | ||
freezeTime: false | ||
record: | ||
recordTimer: 0s | ||
filters: [] | ||
configPath: "" | ||
bypassRules: [] | ||
cmdType: "native" | ||
enableTesting: false | ||
fallbackOnMiss: false | ||
keployContainer: "keploy-v2" | ||
keployNetwork: "keploy-network" | ||
|
||
# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*/mocks.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
testset: | ||
pre_script: "" | ||
post_script: "" | ||
template: {} | ||
mocks: | ||
- daa16f86fded81299cb178aec234e127a08ad8a9174ce8b4e8f8ee23d7eebf0d.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secure handling of Docker Compose installation.
Downloading and installing Docker Compose from GitHub. Verify the checksum of the downloaded binary to ensure its integrity.
+ curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64" -o $HOME/.docker/cli-plugins/docker-compose | shasum -a 256 -c expected_checksum_file