Skip to content
Merged
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
24 changes: 13 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# purpose: run Continuous Integration (build, unit test, lint, scan)
# variables: [ SONAR_HOST_URL, SONAR_ORG, SONAR_PROJECT_KEY ]
# secrets: [ SONAR_TOKEN ]
# variables: [SONAR_HOST_URL, SONAR_ORG, SONAR_PROJECT_KEY]
# secrets: [SONAR_TOKEN]

name: CI

on:
push:
branches: ["main"]
branches:
- main
pull_request:
branches: ["main"]
branches:
- main
workflow_dispatch: {}

concurrency:
Expand All @@ -31,17 +33,17 @@ jobs:
uses: actions/checkout@v4
with:
repository: devpro/github-workflow-parts
ref: feature/sonar-login-deprecation
ref: main
path: workflow-parts
- name: Start MongoDB
uses: ./workflow-parts/mongodb/start
- name: Initialize database
- name: Initialize database (indexes, tenants & users)
run: |
mongosh mongodb://localhost:27017/terraform_backend_dev scripts/mongo-create-index.js
sudo apt-get -y install apache2-utils
./scripts/mongo-create-user.sh admin admin123 dummy
mongosh mongodb://localhost:27017/terraform_backend_dev scripts/add-user.js
./scripts/tfbeadm create-indexes
./scripts/tfbeadm create-user admin admin123 dummy
shell: bash
env:
MONGODB_URI: mongodb://localhost:27017/terraform_backend_dev
- name: Build, lint & test
uses: ./workflow-parts/dotnet/build-lint-test
with:
Expand All @@ -62,7 +64,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: devpro/github-workflow-parts
ref: feature/sonar-login-deprecation
ref: main
path: workflow-parts
- name: Create and scan container image
uses: ./workflow-parts/docker/build-scan
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pages

on:
push:
branches:
- main
workflow_dispatch: {}

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: ~/.cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
8 changes: 4 additions & 4 deletions .github/workflows/pkg.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# purpose: run Continuous Delivery / Packaging (package)
# variables: []
# secrets: [ DOCKERHUB_USERNAME, DOCKERHUB_TOKEN ]
# secrets: [DOCKERHUB_USERNAME, DOCKERHUB_TOKEN]

name: PKG

on:
push:
branches: ["main"]
# tags: [ 'v*.*.*' ]
branches:
- main
workflow_dispatch: {}

jobs:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,3 @@ appsettings.Development.json
.terraform/
.terraform.lock.hcl
errored.tfstate

# temp script files
scripts/add-user.js
5 changes: 5 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ref. https://github.com/DavidAnson/markdownlint
default: true
MD013:
line_length: 240
MD046: false
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ref. https://yamllint.readthedocs.io/en/stable/configuration.html
extends: default
rules:
document-start: disable
line-length:
level: warning
max: 120
truthy: disable
tags:
disable: true
79 changes: 27 additions & 52 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Project development guide
# Contribution guide

## Design
## Application codebase

The application is entirely based on open-source, cross-platform (Linux/Windows), highly performant, free, object-oriented technologies: .NET / C#.

### Projects
### .NET projects

Project name | Technology | Project type
---------------------------|------------|---------------------------
Expand All @@ -15,7 +13,7 @@ Project name | Technology | Project type
`Infrastructure.MongoDb` | .NET 8 | Library
`WebApi` | ASP.NET 8 | Web application (REST API)

### Packages (NuGet)
### .NET packages (NuGet)

Name | Description
-------------------------|-----------------------------
Expand All @@ -24,60 +22,33 @@ Name | Description
`Swashbuckle.AspNetCore` | OpenAPI / Swagger generation
`System.Text.Json` | JSON support

### Documentation

* [OpenTofu](https://opentofu.org/)
* [MongoDB](https://www.mongodb.com/)
* [Terraform](https://www.terraform.io)
* [HTTP backend](https://developer.hashicorp.com/terraform/language/backend/http)
* [Remote state backend](https://github.com/hashicorp/terraform/tree/main/internal/backend/remote-state).

### References of other implementations

* [GitLab](https://gitlab.com/gitlab-org/manage/import/gitlab/-/blob/master/doc/user/infrastructure/terraform_state.md)
* [lib/api/terraform/state.rb](https://gitlab.com/gitlab-org/manage/import/gitlab/-/blob/master/lib/api/terraform/state.rb)
* HTTP
* [akshay/terraform-http-backend-pass](https://git.coop/akshay/terraform-http-backend-pass)
* [bhoriuchi/terraform-backend-http](https://github.com/bhoriuchi/terraform-backend-http)
* git
* [plumber-cd/terraform-backend-git](https://github.com/plumber-cd/terraform-backend-git)

## Automation
### Terraform specifications

### Build (CI/CD pipelines)
- [HTTP backend](https://developer.hashicorp.com/terraform/language/backend/http)
- [Remote state backend](https://github.com/hashicorp/terraform/tree/main/internal/backend/remote-state)

GitHub Actions are triggered to automate the integration and delivery of the application:
### Other community implementations

- [CI](.github/workflows/ci.yaml)
- [PKG](.github/workflows/pkg.yaml)

GitHub project has been configured, in **General** / **Security** / **Secrets and Variables** / **Actions**:

- DOCKERHUB_TOKEN
- DOCKERHUB_USERNAME
- SONAR_HOST_URL
- SONAR_ORG
- SONAR_PROJECT_KEY
- SONAR_TOKEN
- [GitLab](https://gitlab.com/gitlab-org/manage/import/gitlab/-/blob/master/doc/user/infrastructure/terraform_state.md)
- [lib/api/terraform/state.rb](https://gitlab.com/gitlab-org/manage/import/gitlab/-/blob/master/lib/api/terraform/state.rb)
- HTTP
- [akshay/terraform-http-backend-pass](https://git.coop/akshay/terraform-http-backend-pass)
- [bhoriuchi/terraform-backend-http](https://github.com/bhoriuchi/terraform-backend-http)
- [nimbolus/terraform-backend](https://github.com/nimbolus/terraform-backend)
- git
- [plumber-cd/terraform-backend-git](https://github.com/plumber-cd/terraform-backend-git)

## Procedures

### Run locally the application

Create/have a MongoDB database (example with a local container but you can provision a cluster in MongoDB Atlas):
Run MongoDB in a database and add the indexes and test tenant/user:

```bash
# creates a container
docker run --name mongodb -d -p 27017:27017 mongo:8.0
# (optional) adds indexes for optimal performances
docker run --rm --link mongodb \
-v "$(pwd)/scripts":/home/scripts mongo:8.0 \
bash -c "mongosh mongodb://mongodb:27017/terraform_backend_dev /home/scripts/mongo-create-index.js"
# creates one user
./scripts/mongo-create-user.sh admin admin123 dummy
docker run --rm --link mongodb \
-v "$(pwd)/scripts":/home/scripts mongo:8.0 \
bash -c "mongosh mongodb://mongodb:27017/terraform_backend_dev /home/scripts/add-user.js"
MONGODB_CONTAINERNAME=mongodb
./scripts/tfbeadm create-indexes
./scripts/tfbeadm create-user admin admin123 dummy
```

Run the web API (example with the command line but an IDE like Visual Studio or Rider would be nice to be able to debug):
Expand All @@ -88,8 +59,12 @@ dotnet run --project src/WebApi

Open Swagger in a browser: [localhost:5293/swagger](http://localhost:5293/swagger).

## Backlog
## Documentation codebase

The documentation is a static website built with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/).

### New features
Run locally with:

* Store only one version of the state in tf_state and save the others in tf_state_revision
```bash
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material
```
Loading