diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..66469055e3fc47e01805eeebc86af4a2c2df4177 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,414 @@ +# image: node:18 +# +variables: + GIT_DEPTH: 0 + DEPLOY_PID: "649" + # Value must be the deploy project id + DEPLOYMENT_TRIGGER_TOKEN: "glptt-c4145ab70634cdbb509d4eafec72c51df82bd290" + # Value must be the deployment project pipeline trigger token, found/created at PROJECT > SETTINGS > CI/CD > Pipeline triggers + # Best to place this variable in Project >> Settings >> CI/CD >> Variables + SSH_CLONE_URL: 'git@code.vereign.com:gaiax/ocm/ocm-engine.git' + # Value must be the project ssh clone url + RUNNER_TAG: 'amd64-docker' + # Value must be the runner label/tag for the runner which will execute these jobs + PIPELINE_TRIGGERED: "no" + # Needed for pipeline automation + +### +### ADD HELPERS +#### + +include: + - project: 'helpers/ci-helpers' + file: + - 'builds.yml' + - 'registries.yml' + - project: 'gaiax/helpers/mono-helpers' + file: + - 'builds/registries.yml' + - 'builds/builds.yml' + - 'projects/chart-trigger.yml' + - 'projects/notifiers.yml' + - 'deployments/triggers.yml' + + +stages: + # - helm-branch-check + - lint + - test + - build + - release + - docker + - registries + - helm + - deploy-test + - deploy-stage + - deploy-prod + +.distributed: + cache: + - key: + files: + - yarn.lock + paths: + - '.yarn-cache/' + before_script: + - yarn install --cache-folder .yarn-cache --prefer-offline --frozen-lockfile + +## +### Lint microservices +## + +# +lint-agent: + image: node:18 + extends: .distributed + tags: + - amd64-docker + stage: lint + rules: + - if: '$PIPELINE_TRIGGERED != "yes"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + script: + - yarn nx run agent:lint --parallel=3 + +# lint-engine: +# image: node:18 +# extends: .distributed +# tags: +# - amd64-docker +# rules: +# - if: '$PIPELINE_TRIGGERED != "yes"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' +# stage: lint +# script: +# - yarn nx run agent:lint --parallel=3 + +## +### Test microservices +## + +test-agent: + image: node:18 + extends: .distributed + tags: + - amd64-docker + rules: + - if: '$PIPELINE_TRIGGERED != "yes"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + stage: test + script: + - yarn nx run agent:test --configuration=ci --parallel=3 + +# test-engine: +# image: node:18 +# extends: .distributed +# tags: +# - amd64-docker +# rules: +# - if: '$PIPELINE_TRIGGERED != "yes"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' +# stage: test +# script: +# - yarn nx run agent:test --configuration=ci --parallel=3 + +## +### Bare microservice build +## + +build-agent: + image: node:18 + extends: .distributed + rules: + - if: '$PIPELINE_TRIGGERED != "yes"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + tags: + - amd64-docker + stage: build + script: + # parallel is a CPU core count + - yarn nx run agent:build:production --parallel=3 + - ls -la + artifacts: + paths: + - ./dist + expire_in: 1 day + +# build-engine: +# image: node:18 +# extends: .distributed +# rules: +# - if: '$PIPELINE_TRIGGERED != "yes"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' +# tags: +# - amd64-docker +# stage: build +# script: +# # parallel is a CPU core count +# - yarn nx run agent:build:production --parallel=3 + +## +### Docker build microservices +## + +docker-build-agent: + extends: .docker-build-agent + stage: docker + rules: + - if: '$PIPELINE_TRIGGERED == "no"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + +# docker-build-engine: +# extends: .docker-build-engine +# stage: docker +# rules: +# - if: '$PIPELINE_TRIGGERED == "no"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' + +## +### Push to registries +## + +google-image-agent: + extends: .agent-cloud + stage: registries + rules: + - if: '$CI_COMMIT_TAG == null && $PIPELINE_TRIGGERED == "no"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + +# google-image-engine: +# extends: .engine-cloud +# stage: registries +# rules: +# - if: '$CI_COMMIT_TAG == null && $PIPELINE_TRIGGERED == "no"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' + +## +### Configure helm +## + +agent: + extends: .chart-trigger-agent + stage: helm + rules: + - if: '$CI_COMMIT_TAG == null && $PIPELINE_TRIGGERED == "no"' + changes: + - apps/agent/* + - apps/agent/deployment/* + - apps/agent/src/* + - apps/agent/src/app/* + - if: '$CI_COMMIT_TAG' + +# engine: +# extends: .chart-trigger-engine +# stage: helm +# rules: +# - if: '$CI_COMMIT_TAG == null && $PIPELINE_TRIGGERED == "no"' +# changes: +# - apps/engine/* +# - apps/engine/deployment/* +# - apps/engine/src/* +# - apps/engine/src/app/* +# - if: '$CI_COMMIT_TAG' + +## +### Deploy automatically on Test Environment +## + +agent-test ocm: + stage: deploy-test + extends: .test-agent-ocm-one + rules: + - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "agent"' + when: manual + +agent-test ocm-two: + stage: deploy-test + extends: .test-agent-ocm-two + rules: + - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "agent"' + when: manual + +# engine-test ocm: +# stage: deploy-test +# extends: .test-engine-ocm-one +# rules: +# - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "engine"' +# when: manual + +# engine-test ocm-two: +# stage: deploy-test +# extends: .test-engine-ocm-two +# rules: +# - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "engine"' +# when: manual + +## +### Deploy on prod +## + +agent-prod ocm: + stage: deploy-prod + extends: .prod-agent-ocm-one + rules: + - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "agent"' + when: manual + +agent-prod ocm-two: + stage: deploy-prod + extends: .prod-agent-ocm-two + rules: + - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "agent"' + when: manual + +# engine-prod ocm: +# stage: deploy-prod +# extends: .prod-engine-ocm-one +# rules: +# - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "engine"' +# when: manual + +# engine-prod ocm-two: +# stage: deploy-prod +# extends: .prod-engine-ocm-two +# rules: +# - if: '$PIPELINE_TRIGGERED == "yes" && $APP == "engine"' +# when: manual + + +## +### Deploy manual on Stage Environment +## + +# deploy agent stage: +# stage: deploy-stage +# only: +# refs: +# - master +# - tags +# changes: +# - apps/agent/* +# tags: +# - amd64-docker +# script: +# - echo "create docker file under agent/deployment/ci" +# when: manual + +# deploy engine stage: +# stage: deploy-stage +# only: +# refs: +# - master +# - tags +# changes: +# - apps/engine/* +# tags: +# - amd64-docker +# script: +# - echo "create docker file under agent/deployment/ci" +# when: manual + +# ## +# ### Deploy manual on Prod Environment +# ## + +# deploy agent prod: +# stage: deploy-prod +# only: +# refs: +# - tags +# changes: +# - apps/engine/* +# tags: +# - amd64-docker +# script: +# - echo "create docker file under agent/deployment/ci" +# when: manual + +# deploy engine prod: +# stage: deploy-prod +# only: +# refs: +# - tags +# changes: +# - apps/engine/* +# tags: +# - amd64-docker +# script: +# - echo "create docker file under agent/deployment/ci" +# when: manual + +## +### Commit Linters and Changelog steps +## + +commit lint: + image: node:18 + extends: .distributed + stage: lint + tags: + - amd64-docker + script: + - echo "${CI_MERGE_REQUEST_TITLE}" | npx commitlint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main' + +changelog: + extends: .distributed + stage: release + tags: + - amd64-docker + script: + - npx semantic-release + only: + - main diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md new file mode 100644 index 0000000000000000000000000000000000000000..aafdacd2773b7b0c6b8634e189182119e6e6fcdc --- /dev/null +++ b/.gitlab/issue_templates/Bug.md @@ -0,0 +1,26 @@ +### Summary + +<!-- Summarize the bug encountered concisely. --> + +### Steps to reproduce + +<!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. --> + +### What is the current *bug* behavior? + +<!-- Describe what actually happens. --> + +### What is the expected *correct* behavior? + +<!-- Describe what you should see instead. --> + +### Relevant logs and/or screenshots + +<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code + as it's tough to read otherwise. --> + +### Possible fixes + +<!-- If you can, link to the line of code that might be responsible for the problem. --> + +/label ~"type::bug" diff --git a/.gitlab/issue_templates/Default.md b/.gitlab/issue_templates/Default.md new file mode 100644 index 0000000000000000000000000000000000000000..abf5a462bc94a33512d92b0da2fb3e16d83f764e --- /dev/null +++ b/.gitlab/issue_templates/Default.md @@ -0,0 +1,6 @@ +### Problem to solve + +<!-- What is the user problem you are trying to solve with this issue? --> +### Proposal + +<!-- Use this section to explain the feature and how it will work. It can be helpful to add technical details, design proposals, and links to related epics or issues. --> diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md new file mode 100644 index 0000000000000000000000000000000000000000..ff187cc5345e2c428c8f01de68a601c685199eec --- /dev/null +++ b/.gitlab/merge_request_templates/Default.md @@ -0,0 +1,26 @@ +## Description + +[Provide a description of the changes in this merge request. What was the problem you were trying to solve? How did you solve it?] + +## Related issues + +[If there are any related issues, please mention them here with links.] + +## Testing + +[Describe any testing you've done on this code. What tests have you run, and what were the results?] + +## Checklist + +- [ ] I have updated the documentation (if necessary) +- [ ] I have added unit tests for new functionality (if applicable) +- [ ] My code follows the style guidelines of this project +- [ ] I have tested this code on my local machine before submitting this MR + +## Reviewers + +[Tag any reviewers that you want to review this merge request here.] + +## Additional Notes + +[Add any additional notes or comments you have about this merge request.] diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000000000000000000000000000000000000..dd8768e83c1f9d59d9d0d5503d5ab0200745bdd6 --- /dev/null +++ b/.releaserc @@ -0,0 +1,27 @@ +{ + "branches": ["main"], + "plugins": [ + [ + "@semantic-release/commit-analyzer", { + "preset": "conventionalcommits", + } + ], + [ + "@semantic-release/release-notes-generator", { + "preset": "conventionalcommits", + } + ], + [ + "@semantic-release/changelog", + { + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines." + } + ], + [ + "@semantic-release/git", + { + "message": "chore: Release ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} diff --git a/apps/.gitkeep b/apps/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/apps/agent/deployment/Dockerfile b/apps/agent/deployment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7898a50c40d9e3bd7f51559f638265d776530ad7 --- /dev/null +++ b/apps/agent/deployment/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:alpine +EXPOSE 80 +COPY ./dist . \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000000000000000000000000000000000..28fe5c5bf9299c98bf7eda81f658984e9d6a1129 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']}