Skip to content

Commit

Permalink
feat(workflow) setup step that generates all projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Yavor Stoychev authored and Yavor Stoychev committed Apr 16, 2024
1 parent 25925ca commit d1b475f
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 47 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/test-example-applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ name: Testing Example Applications
on: [push, pull_request]

jobs:
setup:
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: npm install
working-directory: node-cli

- name: Install Nest CLI
run: npm install -g @nestjs/cli

- name: Build
run: npm run build
working-directory: node-cli

- name: Run generate-projects script
run: bash generate-projects.sh
working-directory: node-cli

test:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -50,20 +78,20 @@ jobs:
sed -i 's/NODE_ENV=.*/NODE_ENV=test/g' .env.test
sed -i 's/PORT=.*/PORT=3000/g' .env.test
sed -i 's/HOST=.*/HOST=localhost/g' .env.test
sed -i 's/HOST=.*/HOST=0.0.0.0/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/PGHOST=.*/PGHOST=0.0.0.0/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=password/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_HOST=.*/MONGO_HOST=0.0.0.0/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=password/g' .env.test
Expand Down
2 changes: 1 addition & 1 deletion express-pg-auth0/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REQUEST_LOGGING=true
SWAGGER=true

# Knex
DEBUG=knex:query
DATABASE_LOG=knex:query

# PostgreSQL
PGHOST=localhost
Expand Down
2 changes: 1 addition & 1 deletion express-pg-auth0/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
14 changes: 8 additions & 6 deletions express-pg-auth0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Update `NODE_ENV` to `test`.
Make sure to provide a different database name from what you have in `.env`
as e2e tests wipe the database clean before they run.

You may want to disable query logging by removing `DEBUG=knex:query`.
You may want to disable query logging by removing `DATABASE_LOG=knex:query`.

### Setup docker-compose overrides

Expand All @@ -97,6 +97,7 @@ swaggerui:
- '3001:8080'
```
### Provision the services
In order to provision the services run:
Expand All @@ -113,6 +114,7 @@ docker-compose --profile tools up -d

To learn more about using profiles, checkout the [documentation](https://docs.docker.com/compose/profiles/).


### Run database migrations

```bash
Expand Down Expand Up @@ -181,10 +183,10 @@ npm run db:migrate:rollback
npm run db:migrate:rollback --all
```

To debug migrations set the `DEBUG` environment variable to `knex:query`, e.g.
To debug migrations set the `DATABASE_LOG` environment variable to `knex:query`, e.g.

```bash
DEBUG=knex:query npm run db:migrate:up
DATABASE_LOG=knex:query npm run db:migrate:up
```

## Working with Docker
Expand Down Expand Up @@ -225,6 +227,7 @@ API documentation.
If you're experiencing issues setting this up, checkout the troubleshooting
section at the bottom.


## Working with Licenses

Whenever a new `npm` module is added to the project we need to check its
Expand Down Expand Up @@ -267,12 +270,11 @@ npm run license:summary

### VS Code

Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DEBUG` at the top select
Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DATABASE_LOG` at the top select
`Run Script: Launch via NPM`. You should now be able to start debugging
by pressing `F5`.

## Troubleshooting

## Troubleshooting
### OpenAPI

If `docker-compose` fails with this message and you're on Apple M1:
Expand Down
2 changes: 1 addition & 1 deletion express-pg-jwt/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REQUEST_LOGGING=true
SWAGGER=true

# Knex
DEBUG=knex:query
DATABASE_LOG=knex:query

# PostgreSQL
PGHOST=localhost
Expand Down
2 changes: 1 addition & 1 deletion express-pg-jwt/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
14 changes: 8 additions & 6 deletions express-pg-jwt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Update `NODE_ENV` to `test`.
Make sure to provide a different database name from what you have in `.env`
as e2e tests wipe the database clean before they run.

You may want to disable query logging by removing `DEBUG=knex:query`.
You may want to disable query logging by removing `DATABASE_LOG=knex:query`.

### Setup docker-compose overrides

Expand All @@ -97,6 +97,7 @@ swaggerui:
- '3001:8080'
```
### Provision the services
In order to provision the services run:
Expand All @@ -113,6 +114,7 @@ docker-compose --profile tools up -d

To learn more about using profiles, checkout the [documentation](https://docs.docker.com/compose/profiles/).


### Run database migrations

```bash
Expand Down Expand Up @@ -181,10 +183,10 @@ npm run db:migrate:rollback
npm run db:migrate:rollback --all
```

To debug migrations set the `DEBUG` environment variable to `knex:query`, e.g.
To debug migrations set the `DATABASE_LOG` environment variable to `knex:query`, e.g.

```bash
DEBUG=knex:query npm run db:migrate:up
DATABASE_LOG=knex:query npm run db:migrate:up
```

## Working with Docker
Expand Down Expand Up @@ -225,6 +227,7 @@ API documentation.
If you're experiencing issues setting this up, checkout the troubleshooting
section at the bottom.


## Working with Licenses

Whenever a new `npm` module is added to the project we need to check its
Expand Down Expand Up @@ -267,12 +270,11 @@ npm run license:summary

### VS Code

Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DEBUG` at the top select
Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DATABASE_LOG` at the top select
`Run Script: Launch via NPM`. You should now be able to start debugging
by pressing `F5`.

## Troubleshooting

## Troubleshooting
### OpenAPI

If `docker-compose` fails with this message and you're on Apple M1:
Expand Down
2 changes: 1 addition & 1 deletion nest-mongo-auth0/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
3 changes: 2 additions & 1 deletion nest-mongo-auth0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Create a `docker-compose.override.yml` file using the example:
cp docker-compose.override.example.yml docker-compose.override.yml
```


Open the `docker-compose.override.yml` file to adjust the database volume path.

### Provision the services
Expand Down Expand Up @@ -212,7 +213,7 @@ npm run license:summary

### VS Code

Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DEBUG` at the top select
Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DATABASE_LOG` at the top select
`Run Script: Launch via NPM`. You should now be able to start debugging
by pressing `F5`.

2 changes: 1 addition & 1 deletion nest-mongo-jwt/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
17 changes: 12 additions & 5 deletions nest-mongo-jwt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Update `NODE_ENV` to `test`.
Make sure to provide a different database name from what you have in `.env`
as e2e tests wipe the database clean before they run.


### Setup docker-compose overrides

Create a `docker-compose.override.yml` file using the example:
Expand All @@ -82,6 +83,7 @@ Create a `docker-compose.override.yml` file using the example:
cp docker-compose.override.example.yml docker-compose.override.yml
```


Open the `docker-compose.override.yml` file to adjust the database volume path.

### Provision the services
Expand All @@ -92,23 +94,25 @@ In order to provision the services run:
docker-compose up -d
```


**Note:**
Make sure to change your database host variable in `.env` and `.env.test` files
to your docker database service name that is in `docker-compose.yml` (e.g. `db`)

### Dev Containers

You can work inside a Docker container instead of your host if you like.

**How to use (VS Code):**

- Make sure you have installed [Dev Containers Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
- Open the project's folder in VS Code
- Hit `Ctrl`/`Cmd` + `Shift` + `P` -> Dev Containers: Open Folder in Container

For more information on Dev Containers and [supported editors](https://containers.dev/supporting)
you can check the [documentation](https://containers.dev/).


## Running the app

```bash
Expand Down Expand Up @@ -147,6 +151,7 @@ npm run test:e2e
npm run test:e2e:cov
```


## Working with Docker

```bash
Expand All @@ -157,6 +162,7 @@ npm run image:build
npm run image:run
```


## Working with OpenAPI

Swagger Document is being generated when the application is started.
Expand Down Expand Up @@ -207,6 +213,7 @@ npm run license:summary

### VS Code

Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DEBUG` at the top select
Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DATABASE_LOG` at the top select
`Run Script: Launch via NPM`. You should now be able to start debugging
by pressing `F5`.

2 changes: 1 addition & 1 deletion nest-pg-auth0/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REQUEST_LOGGING=true
SWAGGER=true

# Knex
DEBUG=knex:query
DATABASE_LOG=knex:query

# PostgreSQL
PGHOST=localhost
Expand Down
2 changes: 1 addition & 1 deletion nest-pg-auth0/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
8 changes: 4 additions & 4 deletions nest-pg-auth0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Update `NODE_ENV` to `test`.
Make sure to provide a different database name from what you have in `.env`
as e2e tests wipe the database clean before they run.

You may want to disable query logging by removing `DEBUG=knex:query`.
You may want to disable query logging by removing `DATABASE_LOG=knex:query`.

### Setup docker-compose overrides

Expand Down Expand Up @@ -176,10 +176,10 @@ npm run db:migrate:rollback
npm run db:migrate:rollback --all
```

To debug migrations set the `DEBUG` environment variable to `knex:query`, e.g.
To debug migrations set the `DATABASE_LOG` environment variable to `knex:query`, e.g.

```bash
DEBUG=knex:query npm run db:migrate:up
DATABASE_LOG=knex:query npm run db:migrate:up
```

## Working with Docker
Expand Down Expand Up @@ -243,7 +243,7 @@ npm run license:summary

### VS Code

Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DEBUG` at the top select
Go to the Debug menu (CTRL+SHIFT+D). From `RUN AND DATABASE_LOG` at the top select
`Run Script: Launch via NPM`. You should now be able to start debugging
by pressing `F5`.

2 changes: 1 addition & 1 deletion nest-pg-jwt/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REQUEST_LOGGING=true
SWAGGER=true

# Knex
DEBUG=knex:query
DATABASE_LOG=knex:query

# PostgreSQL
PGHOST=localhost
Expand Down
2 changes: 1 addition & 1 deletion nest-pg-jwt/.github/workflows/coverage-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_ENV: test
DEBUG: ''
DATABASE_LOG: ''
PORT: 3000
HOST: localhost
PGHOST: localhost
Expand Down
Loading

0 comments on commit d1b475f

Please sign in to comment.