Skip to content

Commit

Permalink
Add base Github wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
rosle committed Jan 31, 2022
1 parent 7f805a6 commit ddac64e
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 119 deletions.
3 changes: 3 additions & 0 deletions .template/addons/github/.github/wiki/CI-CD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The project relies entirely on [Github Actions](https://github.com/features/actions) for CI/CD via multiple workflows located under the [`.github/workflows/`](.github/workflows) directory.

Please check out the [`.github/workflows/README.md`](.github/workflows/README.md) file for further instructions.
32 changes: 32 additions & 0 deletions .template/addons/github/.github/wiki/Getting-Started.md.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### Prerequisites

- Ruby version: <%= RUBY_VERSION %>
<%- if WEB_VARIANT -%>
- Node version: <%= NODE_VERSION %>
<%- end -%>

### Docker

- Install [Docker for Mac](https://docs.docker.com/docker-for-mac/install/)

- Setup and boot the Docker containers:

```sh
./bin/envsetup.sh
```

### Development

- Setup the databases:

- Postgres:

```sh
rake db:setup
```

- Run the Rails app

```sh
./bin/dev
```
1 change: 1 addition & 0 deletions .template/addons/github/.github/wiki/Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> *Insert information about your project here!*
74 changes: 74 additions & 0 deletions .template/addons/github/.github/wiki/Testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
### Docker-based tests on the CI server

Add the following build settings to run the tests in the Docker environment via Docker Compose (configuration in `docker-compose.test.yml`):

- Configure the environment variable `BRANCH_TAG` to tag Docker images per branch, e.g:

```sh
# a unique `BRANCH_TAG` value to tag the Docker image
# e.g $SEMAPHORE_BRANCH_ID or using the
# or using nimblehq/[email protected] Github action
export BRANCH_TAG= # unique value for tagging Docker image
```

Each branch needs to have its own Docker image to avoid build settings disparities and leverage Docker image caching.

> BRANCH_TAG must not contain special characters (`/`) to be valid. So using $BRANCH_NAME will not work e.g. chore/setup-docker.
An alternative is to use a unique identifier such as PR_ID or BRANCH_ID on the CI server.

- Pull the latest version the Docker image for the branch:

```sh
docker pull $DOCKER_IMAGE:$BRANCH_TAG || true
```

On each build, the CI environment does not contain yet a cached version of the image. Therefore, it is required to pull
it first to leverage the `cache_from` settings of Docker Compose which avoids rebuilding the whole Docker image on subsequent test builds.

- Build the Docker image:

```sh
./bin/docker-prepare && docker compose -f docker-compose.test.yml build
```

Upon the first build, the whole Docker image is built from the ground up and tagged using `$BRANCH_TAG`.

- Push the latest version of the Docker image for this branch:

```sh
docker push $DOCKER_IMAGE:$BRANCH_TAG
```

- Setup the test database:

```sh
docker compose -f docker-compose.test.yml run test bin/bundle exec rake db:test:prepare
```

### Test

- Run all tests:

```sh
# Docker way
docker compose -f docker-compose.test.yml run test

# Non-Docker way
rspec
```

- Run a specific test:

```sh
# Docker way
docker compose -f docker-compose.test.yml run test bin/bundle exec rspec [rspec-params]

# Non-Docker way
rspec [rspec-params]
```

### Automated Code Review Setup
- Add a bot (i.e. `team-nimblehq`) to this repository or to the organization. The bot requires permission level “Write” to be able to set a PR’s status.

- Create a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
from bot account with `public_repo` scope, and set it as `DANGER_GITHUB_API_TOKEN` secret on the CI Environment Settings.
1 change: 1 addition & 0 deletions .template/addons/github/.github/wiki/_Footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Developed by [Nimble](https://nimblehq.co/)**
12 changes: 12 additions & 0 deletions .template/addons/github/.github/wiki/_Sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Table of Contents

- [[Home]]
- [[Getting Started]]

## Infrastructure

- [[CI/CD|CI CD]]

## Operations

- [[Testing]]
Empty file.
12 changes: 12 additions & 0 deletions .template/spec/addons/base/github/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@
expect(file('.github/workflows/test_production_build.yml')).to exist
expect(file('.github/workflows/test.yml')).to exist
end

it 'creates Github wiki' do
expect(file('.github/wiki/_Sidebar.md')).to exist
expect(file('.github/wiki/_Footer.md')).to exist

expect(file('.github/wiki/Home.md')).to exist
expect(file('.github/wiki/Getting-Started.md')).to exist
expect(file('.github/wiki/CI-CD.md')).to exist
expect(file('.github/wiki/Testing.md')).to exist

expect(file('.github/wiki/assets/images/.keep')).to exist
end
end
120 changes: 2 additions & 118 deletions README.md.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,122 +4,6 @@

> *App introduction goes here ...*

## Project Setup
## Documentation

### Prerequisites

- Ruby version: <%= RUBY_VERSION %>
<%- if WEB_VARIANT -%>
- Node version: <%= NODE_VERSION %>
<%- end -%>

### Docker

- Install [Docker for Mac](https://docs.docker.com/docker-for-mac/install/)

- Setup and boot the Docker containers:

```sh
./bin/envsetup.sh
```

### Development

- Setup the databases:

- Postgres:

```sh
rake db:setup
```

- Run the Rails app

```sh
./bin/dev
```

## Tests

### Docker-based tests on the CI server

Add the following build settings to run the tests in the Docker environment via Docker Compose (configuration in `docker-compose.test.yml`):

- Configure the environment variable `BRANCH_TAG` to tag Docker images per branch, e.g:

```sh
# a unique `BRANCH_TAG` value to tag the Docker image
# e.g $SEMAPHORE_BRANCH_ID or using the
# or using nimblehq/[email protected] Github action
export BRANCH_TAG= # unique value for tagging Docker image
```

Each branch needs to have its own Docker image to avoid build settings disparities and leverage Docker image caching.

> BRANCH_TAG must not contain special characters (`/`) to be valid. So using $BRANCH_NAME will not work e.g. chore/setup-docker.
An alternative is to use a unique identifier such as PR_ID or BRANCH_ID on the CI server.

- Pull the latest version the Docker image for the branch:

```sh
docker pull $DOCKER_IMAGE:$BRANCH_TAG || true
```

On each build, the CI environment does not contain yet a cached version of the image. Therefore, it is required to pull
it first to leverage the `cache_from` settings of Docker Compose which avoids rebuilding the whole Docker image on subsequent test builds.

- Build the Docker image:

```sh
./bin/docker-prepare && docker compose -f docker-compose.test.yml build
```

Upon the first build, the whole Docker image is built from the ground up and tagged using `$BRANCH_TAG`.

- Push the latest version of the Docker image for this branch:

```sh
docker push $DOCKER_IMAGE:$BRANCH_TAG
```

- Setup the test database:

```sh
docker compose -f docker-compose.test.yml run test bin/bundle exec rake db:test:prepare
```

#### Semaphore CI 2.0

To setup the semaphore CI 2.0 for the project, please follow [this guideline](.semaphore/README.md)

#### Github actions & Heroku Deployment

To setup Github actions for the project, please follow [this guideline](.github/workflows/README.md)

### Test

- Run all tests:

```sh
# Docker way
docker compose -f docker-compose.test.yml run test

# Non-Docker way
rspec
```

- Run a specific test:

```sh
# Docker way
docker compose -f docker-compose.test.yml run test bin/bundle exec rspec [rspec-params]

# Non-Docker way
rspec [rspec-params]
```

### Automated Code Review Setup
- Add a bot (i.e. `team-nimblehq`) to this repository or to the organization. The bot requires permission level “Write” to be able to set a PR’s status.

- Create a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
from bot account with `public_repo` scope, and set it as `DANGER_GITHUB_API_TOKEN` secret on the CI Environment Settings.
Please check out full documentation on the [wiki](link to github wiki goes here).
2 changes: 1 addition & 1 deletion template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
DEFAULT_ADDONS = {
docker: 'Docker',
heroku: 'Heroku',
github: 'Github along with Github Action'
github: 'Github along with Github Action and Wiki'
}.freeze

if WEB_VARIANT
Expand Down

0 comments on commit ddac64e

Please sign in to comment.