Skip to content

Commit

Permalink
feat: Move lib into subdir, init CICD [HOOK FAIL OK]
Browse files Browse the repository at this point in the history
  • Loading branch information
batleforc committed Aug 23, 2024
1 parent 35b37d5 commit c63147a
Show file tree
Hide file tree
Showing 51 changed files with 685 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
resolver = '2'
members = [
'apps/back',
'libs/markdown_header',
'libs/tool_tracing',
'libs/markdown_struct',
'libs/back/markdown_header',
'libs/back/tool_tracing',
'libs/back/markdown_struct',
]

[profile.release]
Expand Down
6 changes: 3 additions & 3 deletions apps/back/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ default-run = "server"

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
markdown_header = { path = "../../libs/markdown_header" }
markdown_struct = { path = "../../libs/markdown_struct" }
tool_tracing = { path = "../../libs/tool_tracing" }
markdown_header = { path = "../../libs/back/markdown_header" }
markdown_struct = { path = "../../libs/back/markdown_struct" }
tool_tracing = { path = "../../libs/back/tool_tracing" }
serde = "1.0"
serde_json = "1.0"
serde_yaml = "0.9"
Expand Down
23 changes: 23 additions & 0 deletions cicd/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions cicd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: cicd
description: Tekton pipeline for CI/CD

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
55 changes: 55 additions & 0 deletions cicd/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Monofolio CICD

## Goal

- Create a "beta" version of the Monofolio website that is automatically deployed and is a ref to the `main` branch of the repository.
- Create a "production" version of the Monofolio website that is automatically deployed and is a ref to a `tag` in the repository.
- Make sure that the "production" version is tested in depth

### Deploy flow

- Build the Frontend if the folder related to the Frontend has changed.
- apps/front
- libs/front/*
- Build the Backend if the folder related to the Backend has changed.
- apps/back
- libs/back/*
- Push the images to a conteneur registry.
- Deploy the images to a Kubernetes cluster.

### Test flow

- Run Code Coverage tests on the Backend
- Run E2E tests on the Frontend
- Run Lighthouse tests on the Frontend
- Run Security tests on both the Backend and the Frontend

### Deployment flow

- Write code in a new branch
- Create a Pull Request
- PR is tested by Github Actions then the Test flow is executed.
- If both the Test flow and the PR checks pass, the PR is merged into the `main` branch.
- The Release flow is executed and the `beta` version is deployed.
- If the `beta` version is stable, a new tag is created and the `production` version is deployed.

```mermaid
flowchart TD;
subgraph "Development flow"
A([Write code in a new branch]) --> B[Create a Pull Request];
end
subgraph "Test flow"
B --> C[PR is tested by Github Actions];
C -- If Github Action is ok --> D[Run the Test flow];
D -- If test nok --> E[PR is locked with information];
end
subgraph "Release flow"
D -- If test ok --> F[PR is merged into the `main` branch];
F -- If Front changed --> G[Build the Frontend];
F -- If Back changed --> H[Build the Backend];
G --> I[Push the images to a conteneur registry];
H --> I;
I --> J[Deploy the helm chart];
end
```
File renamed without changes.
56 changes: 56 additions & 0 deletions cicd/templates/task/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: build-image
spec:
description: |
This task builds selected image.
workspaces:
- name: shared-data
description: |
This workspace contains the cloned repo files, so they can be read by the
next task.
- name: dockerconfig
description: |
This workspace contains the docker config.json file, so it can be used by
the next task.
params:
- name: registrydns
type: string
description: The registry dns name.
default: docker.io
- name: buildctl_tcp
type: string
description: The buildctl tcp address.
default: tcp://buildkitd.buildkit.svc.cluster.local:1234
- name: repo-branch
type: string
description: The git repo branch to clone from.
default: main
- name: path-dockerfile
type: string
description: The folder where the dockerfile are.
default: .
- name: context-dockerfile
type: string
description: The context where the dockerfile are.
default: .
- name: DOCKERFILE
type: string
description: The dockerfile to build.
default: Dockerfile
- name: IMAGE
type: string
description: The image name to build (repo/imagename).
steps:
- image: '{{ .Values.task.buildImage.baseImage }}'
name: build-all
env:
- name: DOCKER_CONFIG
value: $(workspaces.dockerconfig.path)
workingDir: $(workspaces.shared-data.path)
script: |
#!/usr/bin/env ash
buildctl --addr $(params.buildctl_tcp) build --progress=plain --frontend dockerfile.v0 --local context=$(params.context-dockerfile) --local dockerfile=$(params.path-dockerfile) --opt filename=$(params.DOCKERFILE) --output type=image,name=$(params.registrydns)/$(params.IMAGE):$(params.repo-branch),push=true
# https://tekton.dev/docs/pipelines/tasks/#specifying-workspaces
Loading

0 comments on commit c63147a

Please sign in to comment.