Skip to content

Commit

Permalink
Merge pull request #315 from MentorMate/feat/github-workflow-testing
Browse files Browse the repository at this point in the history
Example Applications Into Mono Repository
  • Loading branch information
Yavorss authored Feb 9, 2024
2 parents 8a04a78 + 24111ec commit 8272146
Show file tree
Hide file tree
Showing 1,845 changed files with 66,560 additions and 13,328 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/test-example-applications.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Testing Example Applications

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
project: ["express-pg-auth0", "express-pg-jwt", "nest-mongo-auth0", "nest-mongo-jwt", "nest-pg-auth0", "nest-pg-jwt"]
max-parallel: 1

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
ports: ["5432:5432"]

mongo:
image: mongo:latest
ports: ["27017:27017"]
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: pass@ord

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm ci
working-directory: ${{ matrix.project }}

- name: Create .env.test file
run: |
mv .env.example .env.test
sed -i 's/NODE_ENV=.*/NODE_ENV=test/g' .env.test
sed -i 's/PORT=.*/PORT=3000/g' .env.test
sed -i 's/ERROR_LOGGING=.*/ERROR_LOGGING=false/g' .env.test
sed -i 's/REQUEST_LOGGING=.*/REQUEST_LOGGING=false/g' .env.test
sed -i 's/SWAGGER=.*/SWAGGER=false/g' .env.test
sed -i 's/PGHOST=.*/PGHOST=localhost/g' .env.test
sed -i 's/PGPORT=.*/PGPORT=5432/g' .env.test
sed -i 's/PGUSER=.*/PGUSER=postgres/g' .env.test
sed -i 's/PGPASSWORD=.*/PGPASSWORD=postgres/g' .env.test
sed -i 's/PGDATABASE=.*/PGDATABASE=test/g' .env.test
sed -i 's/MONGO_PROTOCOL=.*/MONGO_PROTOCOL=mongodb/g' .env.test
sed -i 's/MONGO_HOST=.*/MONGO_HOST=localhost/g' .env.test
sed -i 's/MONGO_PORT=.*/MONGO_PORT=27017/g' .env.test
sed -i 's/MONGO_USER=.*/MONGO_USER=root/g' .env.test
sed -i 's/MONGO_PASSWORD=.*/MONGO_PASSWORD=pass@ord/g' .env.test
sed -i 's/MONGO_DATABASE_NAME=.*/MONGO_DATABASE_NAME=example-app/g' .env.test
working-directory: ${{ matrix.project }}

- name: Run tests
run: npm run test
working-directory: ${{ matrix.project }}

- name: Run end-to-end tests
run: npm run test:e2e
working-directory: ${{ matrix.project }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ build
.vscode
.eslintcache
.prettiercache
.env
.env.test
2 changes: 0 additions & 2 deletions assets/express/example-app/jest.setup.ts

This file was deleted.

2 changes: 0 additions & 2 deletions assets/express/example-app/test/jest.setup.ts

This file was deleted.

2 changes: 0 additions & 2 deletions assets/nest/example-app-pg/jest.setup.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions express-pg-auth0/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Node
NODE_ENV=development

# HTTP
PORT=3000

# Logging
ERROR_LOGGING=true
REQUEST_LOGGING=true

# Swagger
SWAGGER=true

# Knex
DEBUG=knex:query

# PostgreSQL
PGHOST=localhost
PGPORT=5432
PGUSER=user
PGPASSWORD=password
PGDATABASE=default

# AUTH0
AUTH0_ISSUER_URL=https://mock.auth0.com/api/v2/
AUTH0_CLIENT_ID=CLIENT_ID
AUTH0_AUDIENCE=AUDIENCE
AUTH0_CLIENT_SECRET=CLIENT_SECRET

File renamed without changes.
21 changes: 21 additions & 0 deletions express-pg-auth0/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
commonjs: false,
es2021: true,
node: true,
jest: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:security/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions express-pg-auth0/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- tsc --noEmit
npx --no -- lint-staged
npx --no -- ls-lint
npm run lint:dockerfile
npm run license:check
npm run test:cov
npm run test:e2e:cov
scripts/detect-secrets.sh

# Enable branch naming validation by uncommenting the lines below and adjust valid_branch_regex to your preference
# # Enforce branch naming conventions
# LC_ALL=C

# # Git branch will return an empty line before the initial commit
# git_branch=$(git branch)

# if [ -z "$git_branch" ]; then
# echo "Initial commit, no branch name linting"
# exit 0
# fi

# # INSERT A REGEX PATTERN ACCORDING TO YOUR PROJECT BRANCH NAMING CONVENTION.
# branch_regex="^(chore|feat|fix|docs|style|refactor|test|revert|ci)\/[a-z0-9._-]+$"

# # Get the branch name
# branch="$(git rev-parse --abbrev-ref HEAD)"

# # UPDATE THE EXAMPLES TO MATCH YOUR PROJECT BRANCH NAMING CONVENTION.
# error_message="Branch name validation failed. Branch name must adhere to: /$branch_regex/.
# You should rename your branch to a valid name and try again. Here are some examples of valid branch names:

# feat/my-feature
# test/my-feature
# fix/that-bug
# chore/my-task
# docs/update-readme
# refactor/do-thing-differently
# ci/update-build-script
# "


# # Use grep to do the matching, as `if [[ ]]` is not available in `sh`
# match=$(echo $branch | grep -E "$branch_regex") || echo ""

# # Check if the match is a non-empty string
# if [ -z "$match" ]; then
# echo "$error_message"
# exit 1
# fi
File renamed without changes.
12 changes: 12 additions & 0 deletions express-pg-auth0/.lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"*.{js,cjs,mjs,ts}": [
"prettier --write",
"eslint --fix"
],
"*.md": [
"prettier --write",
"markdownlint --fix"
],
"*.sh": "shellcheck -x",
"package.json": "sort-package-json"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
116 changes: 116 additions & 0 deletions express-pg-auth0/.secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"version": "1.4.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2024-01-20T21:29:38Z"
}
File renamed without changes.
Loading

0 comments on commit 8272146

Please sign in to comment.