Skip to content
Open
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
11 changes: 6 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"presets": [
"presets": [
"@babel/preset-env",
"@babel/preset-flow"
],
],
"plugins": [
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-proposal-class-properties",
"@babel/transform-runtime"
]
}
"@babel/transform-runtime",
"babel-plugin-istanbul"
]
}
4 changes: 3 additions & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ ACCESS_TOKEN_SECRET=4cd7234152590dcfe77e1b6fc52e84f4d30c06fddadd0dd2fb42cbc51fa1
NODE_ENV=production
ENVIRONMENT_NAME=docker
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PORT=6379
APP_PATH=/Users/apple/repos/node-express-graphql-template
# ENABLE_DEDUP=true
16 changes: 16 additions & 0 deletions .env.keploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DB_URI=postgres://reporting_dashboard_role:reportingdashboard123@localhost:5432/reporting_dashboard_dev
POSTGRES_HOST=0.0.0.0
POSTGRES_DB=reporting_dashboard_dev
POSTGRES_USER=reporting_dashboard_role
POSTGRES_PASSWORD=reportingdashboard123
NODE_ENV=local
ACCESS_TOKEN_SECRET=4cd7234152590dcfe77e1b6fc52e84f4d30c06fddadd0dd2fb42cbc51fa14b1bb195bbe9d72c9599ba0c6b556f9bd1607a8478be87e5a91b697c74032e0ae7af
REDIS_HOST=localhost
REDIS_PORT=6379
BUILD_NAME=docker
POSTGRES_PORT=5432
NODE_ENV=production
ENVIRONMENT_NAME=keploy
APP_PATH=/home/runner/work/node-express-graphql-template/node-express-graphql-template
ENABLE_DEDUP=false
PLATFORM=amd64
9 changes: 8 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ POSTGRES_PASSWORD=reportingdashboard123
NODE_ENV=local
ACCESS_TOKEN_SECRET=4cd7234152590dcfe77e1b6fc52e84f4d30c06fddadd0dd2fb42cbc51fa14b1bb195bbe9d72c9599ba0c6b556f9bd1607a8478be87e5a91b697c74032e0ae7af
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PORT=6379
BUILD_NAME=docker
POSTGRES_PORT=5432
NODE_ENV=production
ENVIRONMENT_NAME=local
APP_PATH=/Users/apple/repos/node-express-graphql-template
ENABLE_DEDUP=false
PLATFORM=arm64
52 changes: 52 additions & 0 deletions .github/workflows/keploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Keploy

on:
pull_request:
push:

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 16
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Print all environment variables for debugging
run: printenv

- name: Install dependencies
run: yarn install

- name: Install nyc
run: yarn add nyc@15.1.0 --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: |
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:
GITHUB_TOKEN: 'Kca1IAlh+GKnXPaceA=='

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
verbose: true
47 changes: 47 additions & 0 deletions .github/workflows/test_workflows/keploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
curl --silent -O -L https://keploy.io/ent/install.sh


sudo docker compose -f keploy-docker-compose.yml --env-file .env.keploy build
export KEPLOY_API_KEY=Iba1IAlh+GKnXPzYeA==
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


# Build the project locally
echo "Project built successfully"


sudo -E env PATH="$PATH" /usr/local/bin/keployE test -c "sudo docker compose -f keploy-docker-compose.yml --env-file .env.keploy up" --containerName "custom_app" --delay 30 --apiTimeout 300 --generateGithubActions=false --coverage=true
echo "Keploy started in test mode"

all_passed=true

# Loop through test sets
for i in {0..0}
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 custom_app:$(pwd)/.nyc_output $(pwd)/.nyc_output
npx nyc report
echo "All tests passed"
exit 0
else
exit 1
fi
45 changes: 32 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
FROM node:14
ARG ENVIRONMENT_NAME
ARG BUILD_NAME
RUN mkdir -p /app-build
ADD . /app-build
WORKDIR /app-build
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn --frozen-lockfile
ARG APP_PATH
ARG PLATFORM
ENV APP_PATH=${APP_PATH:-/default/path}
RUN mkdir -p ${APP_PATH}
ADD . ${APP_PATH}
WORKDIR ${APP_PATH}
RUN --mount=type=cache,target=/root/.yarn
RUN yarn
RUN pwd
RUN yarn build:$BUILD_NAME


FROM node:14-alpine
ARG ENVIRONMENT_NAME
ARG BUILD_NAME
RUN mkdir -p /dist
RUN apk add yarn
RUN yarn global add sequelize-cli@6.2.0
ARG APP_PATH
ARG PLATFORM
ENV APP_PATH=${APP_PATH:-/default/path}
RUN yarn global add sequelize-cli@6.2.0 nyc@15.1.0
RUN yarn add shelljs bull dotenv pg sequelize@6.6.5
ADD scripts/migrate-and-run.sh /
ADD package.json /
ADD . /
COPY --from=0 /app-build/dist ./dist
RUN apk add --no-cache dumb-init
ADD scripts/migrate-and-run.sh ${APP_PATH}/
ADD package.json ${APP_PATH}/
ADD . ${APP_PATH}/
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


CMD ["sh", "./migrate-and-run.sh"]
EXPOSE 9000
# Set working directory
WORKDIR ${APP_PATH}
ENTRYPOINT ["dumb-init", "--"]

# RUN echo "hi"
STOPSIGNAL SIGINT

# Set entrypoint and command
CMD [ "sh","./scripts/migrate-and-run.sh"]

# Expose port 9000
EXPOSE 9000
21 changes: 19 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,39 @@ services:
restart: always
env_file:
- .env.docker
networks:
- keploy-network

redis:
image: 'redis:alpine'
ports:
- '6379:6379'
command: ['redis-server', '--bind', 'redis', '--port', '6379']
networks:
- keploy-network

app:
container_name: custom_app
build:
context: .
args:
ENVIRONMENT_NAME: .docker
BUILD_NAME: docker
restart: always
APP_PATH: ${APP_PATH}
depends_on:
- db_postgres
- redis
ports:
- 9000:9000
env_file:
- ./.env.docker
- .env.docker
networks:
- keploy-network
volumes:
- /Users/apple/repos/node-express-graphql-template/dedupData.yaml:${APP_PATH}/dedupData.yaml
stop_grace_period: 50s # Increase the stop grace period to 50 seconds


networks:
keploy-network:
external: true
24 changes: 24 additions & 0 deletions keploy-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'
services:
app:
container_name: custom_app
build:
context: .
args:
BUILD_NAME: keploy
APP_PATH: ${APP_PATH}
PLATFORM: ${PLATFORM}
ports:
- 9000:9000
env_file:
- .env.${ENVIRONMENT_NAME}
networks:
- keploy-network
volumes:
- /Users/apple/repos/node-express-graphql-template/dedupData.yaml:${APP_PATH}/dedupData.yaml
stop_grace_period: 50s # Increase the stop grace period to 50 seconds


networks:
keploy-network:
external: true
91 changes: 91 additions & 0 deletions keploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
path: ''
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: 30
coverage: true
goCoverage: false
coverageReportPath: ''
ignoreOrdering: true
mongoPassword: default@123
language: ''
removeUnusedMocks: false
dedup: true
freezeTime: true
record:
recordTimer: 0s
filters: []
configPath: ''
bypassRules: []
cmdType: native
enableTesting: false
fallbackOnMiss: false
keployContainer: keploy-v2
keployNetwork: keploy-network

# Example on using tests
#tests:
# filters:
# - path: "/user/app"
# urlMethods: ["GET"]
# headers: {
# "^asdf*": "^test"
# }
# host: "dc.services.visualstudio.com"
#Example on using stubs
#stubs:
# filters:
# - path: "/user/app"
# port: 8080
# - port: 8081
# - host: "dc.services.visualstudio.com"
# - port: 8081
# host: "dc.services.visualstudio.com"
# path: "/user/app"
#
#Example on using globalNoise
#globalNoise:
# global:
# body: {
# # to ignore some values for a field,
# # pass regex patterns to the corresponding array value
# "url": ["https?://\S+", "http://\S+"],
# }
# header: {
# # to ignore the entire field, pass an empty array
# "Date": [],
# }
# # to ignore fields or the corresponding values for a specific test-set,
# # pass the test-set-name as a key to the "test-sets" object and
# # populate the corresponding "body" and "header" objects
# test-sets:
# test-set-1:
# body: {
# # ignore all the values for the "url" field
# "url": []
# }
# header: {
# # we can also pass the exact value to ignore for a field
# "User-Agent": ["PostmanRuntime/7.34.0"]
# }
Loading