Skip to content
Draft
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
5 changes: 3 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"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/template/node-express-graphql-template
ENABLE_DEDUP=true
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Setup environment
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: wednesday-solutions/[email protected]
with:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Node Express GraphQL Template CI

on:
pull_request_target:
pull_request:
branches:
- develop
push:
Expand All @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -42,19 +42,21 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- uses: artiomtr/[email protected]

- uses: artiomtr/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
package-manager: yarn
threshold: ${{steps.threshold.outputs.prop}}
skip-step: all
annotations: failed-tests

- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/keploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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 18
uses: actions/setup-node@v2
with:
node-version: '18'

- 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: |
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
48 changes: 48 additions & 0 deletions .github/workflows/test_workflows/keploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
curl --silent -O -L https://keploy.io/ent/install.sh


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


# 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 30 --apiTimeout 30 --generateGithubActions=false
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 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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ typings/
# DS_Store
.DS_Store
report.json
reports/test-report.xml
reports/test-report.xml

# Keploy test reports
dedupData.yaml
duplicates.yaml
keploy/reports
docker-compose-tmp.yaml
43 changes: 30 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
FROM node:14
FROM node:18
ARG ENVIRONMENT_NAME
ARG BUILD_NAME
RUN mkdir -p /app-build
ADD . /app-build
WORKDIR /app-build
ARG APP_PATH
ARG PLATFORM
ENV NODE_OPTIONS=--openssl-legacy-provider

# RUN mkdir -p /app-build
# ADD . /app-build
# WORKDIR /app-build
RUN mkdir -p ${APP_PATH}
ADD . ${APP_PATH}
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


FROM node:14-alpine
FROM node:18-alpine
ARG ENVIRONMENT_NAME
ARG BUILD_NAME
RUN mkdir -p /dist
ARG APP_PATH
ARG PLATFORM
ENV NODE_OPTIONS=--openssl-legacy-provider

WORKDIR ${APP_PATH}
RUN mkdir -p ${APP_PATH}/dist
RUN apk add yarn
RUN yarn global add [email protected]
RUN yarn global add [email protected] [email protected]
RUN yarn add shelljs bull dotenv pg [email protected]
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 . ./
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
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ services:
args:
ENVIRONMENT_NAME: .docker
BUILD_NAME: docker
PLATFORM: arm64
APP_PATH: ${APP_PATH}
restart: always
depends_on:
- db_postgres
- redis
ports:
- 9000:9000
environment:
ENABLE_DEDUP: "true"
env_file:
- ./.env.docker
volumes:
- ${APP_PATH}/dedupData.yaml:${APP_PATH}.dedupData.yaml
stop_grace_period: 50s
52 changes: 52 additions & 0 deletions keploy.yml
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.
1 change: 1 addition & 0 deletions keploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*/mocks.yaml
6 changes: 6 additions & 0 deletions keploy/test-set-0/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
testset:
pre_script: ""
post_script: ""
template: {}
mocks:
- daa16f86fded81299cb178aec234e127a08ad8a9174ce8b4e8f8ee23d7eebf0d.yaml
Loading