Skip to content

Commit

Permalink
merge: branch dev into coverage-100.
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Sep 23, 2023
2 parents 796b25d + 490df02 commit af8b53d
Show file tree
Hide file tree
Showing 13 changed files with 823 additions and 402 deletions.
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-18",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": ". ${NVM_DIR}/nvm.sh && nvm install --lts",

"postStartCommand": "yarn install",

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"esbenp.prettier-vscode",
"ms-vscode.makefile-tools"
]
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
194 changes: 194 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Contributing to IEF <!-- omit from toc -->

First off, thanks for taking the time to contribute! 🎉

The following document is a rule set of guidelines for contributing.

## Table of Contents <!-- omit from toc -->

- [Code Contributions](#code-contributions)
- [Step 1: Clone](#step-1-clone)
- [Step 2: Branch](#step-2-branch)
- [Step 3: Commit](#step-3-commit)
- [Step 4: Sync](#step-4-sync)
- [Step 5: Push](#step-5-push)
- [Step 6: Pull Request](#step-6-pull-request)
- [Commit message guidelines](#commit-message-guidelines)
- [Coding guidelines](#coding-guidelines)
- [Code structuring patterns](#code-structuring-patterns)
- [Object Oriented Programming](#object-oriented-programming)
- [Functional Programming](#functional-programming)
- [Naming patterns](#naming-patterns)
- [Documentation](#documentation)
- [Writing tests](#writing-tests)

## Code Contributions

#### Step 1: Clone

Clone the project on [GitHub]([email protected]:Green-Software-Foundation/ief.git)

```bash
$ git clone [email protected]:Green-Software-Foundation/ief.git
$ cd ief
```

For developing new features and bug fixes, the development branch should be pulled and built upon.

#### Step 2: Branch

Create new branch from main (`staging` or `master`), which will contain your new feature, fix or change.

```bash
$ git checkout -b <topic-branch-name>
```

#### Step 3: Commit

Make sure git knows your name and email address:

```bash
$ git config --global user.name "Example User"
$ git config --global user.email "[email protected]"
```

Commiting multiple files with changes on multiple resources is not allowed.
Commit message should clearly describe on which resource changes are made.

Add and commit:

```bash
$ git add my/changed/files
$ git commit
```

Commit your changes in logical chunks. Please do not push all changes in one commit.

> Run `yarn fix` before commiting for not having conflict with CI linter.
Please adhere to these [Commit message guidelines](#commit-message-guidelines)
or your code is unlikely be merged into the main project.

#### Step 4: Sync

Use git pull/merge to synchronize your work with the main repository.

```bash
$ git pull origin dev
```

#### Step 5: Push

Push your topic branch:

```bash
$ git push origin <topic-branch-name>
```

#### Step 6: Pull Request

Open a Pull Request with a clear title and description according to [template](.github/PULL_REQUEST_TEMPLATE.md).

Pull request should pass all CI which are defined, should have at least one approve. It should adher to the specification for getting approved.

CI included lint checks, running tests, and etc.

## Commit message guidelines

The commit message should describe what changed and why.

1. The first line should:
* contain a short description of the change
* be 60 characters or less
* be prefixed with the name of the changed subsystem
* be entirely in lowercase with the exception of proper nouns, acronyms, and the words that refer to code,
like function/variable names

Examples:

```
util: add getInitializedModel method to models.
deps: add express package to dependencies.
service: refactor get user.
```
2. Keep the second line blank.

3. Wrap all other lines at 72 columns:
* describe each line in logical chunks
* start each line with: space hyphen space ( - ...)
* be entirely in lowercase with the exception of proper nouns, acronyms, and the words that refer to code,
like function/variable names

Examples:

```
- remove deprecated logger
- refactor some method
- add JSDoc on existing function
```
## Coding guidelines
#### Code structuring patterns
Avoid having functions which are responsible to do multiple things at the same time. Make sure one function/method does one thing, and does it well.
###### Object Oriented Programming
While following `Object Oriented Programming` paradigm, it's important to follow [SOLID](https://en.wikipedia.org/wiki/SOLID) principles.
###### Functional Programming
When designing module of the application in `Functional Programming` paradigm, the key to follow [basic](https://dev.to/jamesrweb/principles-of-functional-programming-4b7c) principles.
#### Naming patterns
Make sure your `class/function/variable` describes exactly what it does. Avoid using shortened words like txt, arr while doing naming decision. As a naming pattern `camel case` should be used.
```ts
❌ const a = "<MOCK_VALUE_HERE>"
✅ const mockValue = "<MOCK_VALUE_HERE>"
❌ const a = (txt: string) => console.log(txt)
✅ const logMessage = (message: string) => console.log(message)
```

#### Documentation

Every logical unit (`Class, function, method`) should be covered with appropriate documentation. For documenting such, multi-line comment style is used.

```ts
const a = (message: string) => console.log(message)

/**
* Logs given `message` to console.
**/
const logMessage = (message: string) => console.log(message)
```

For documenting variable, expression, single line comments can be used after declaration.

```ts
class MockClass {
// this is a mock field
private mockField: string = "mock-field"
private mockField: string = "mock-field" // Single line documenting style is used.
}
```

#### Writing tests

One test file should be responsible for one module. `describe` blocks should be used for module and function/method description. First `describe` should follow `resource/module: ` pattern. Second describe title should follow `method(): ` pattern. Test units can use either `test` or `it`, title should exactly describe behaviour and input argument. Make sure each test case covers one branch.

See example:
```ts
describe('util/args: ', () => {
describe('parseProcessArgument(): ', () => {
it('logs help message if property present in env.', () => {
...
})
})
})
```

*[⬅️ back to the root](/README.md#ief)*
139 changes: 139 additions & 0 deletions examples/impls/accenture.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: accenture
description: https://github.com/Green-Software-Foundation/sci-guide/blob/dev/use-case-submissions/nttdatta-On-Premise-Web-system.md
tags:
kind: web
complexity: moderate
category: on-premise
initialize:
models:
- name: sci-e # a model that sums e components
kind: builtin
verbose: false
path: ''
- name: sci-o # a model that given e, i and m calculates a carbon value (e * i) + m
kind: builtin
verbose: false
path: ''
- name: sci # a model that sums sci-o + sci-m
kind: builtin
verbose: false
path: ''
- name: sci-accenture # a model that sums sci-o + sci-m
kind: builtin
verbose: false
path: ''
graph:
children:
vms:
pipeline:
- sci-e
- sci-o
- sci
- sci-accenture
config:
sci-o:
grid-ci: 350.861
children:
vm1:
observations:
- timestamp: 2023-07-06T00:00
grid-ci: 350.861
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 15
ram-util: 75
e-cpu: 4.26 #kwh/month
embodied-carbon: 763.33 #gCO2e
vm2:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 12
ram-util: 72
e-cpu: 4.26 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm3:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 10
ram-util: 65
e-cpu: 4.21 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm4:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 9
ram-util: 70
e-cpu: 4.21 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm5:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 9
ram-util: 70
e-cpu: 4.21 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm6:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 8
ram-util: 65
e-cpu: 3.29 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm7:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 7
ram-util: 72
e-cpu: 3.29 # kwh/month
embodied-carbon: 763.33 #gCO2e
vm8:
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 6
ram-util: 70
e-cpu: 3.29 # kwh/month
embodied-carbon: 763.33 #gCO2e
db:
pipeline:
- sci-e # sums e components
- sci-o # calculates carbon for this obervation (energy * grid-ci) + embodied.
- sci # calculates sci by dividing carbon by `r`
- sci-accenture # multiplies sci value by 1.05 to account for the "app-gateway"
config:
sci-o:
grid-ci: 350.861
sci:
time: '' # signal to convert /s -> /hr
factor: 89000 # factor to convert per time to per f.unit
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 4
ram-util: 40
e-cpu: 2.68 # kwh/month
embodied-carbon: 763.33 #gCO2e
monitoring:
pipeline:
- sci-e # sums e components
- sci-o # calculates carbon for this obervation (energy * grid-ci) + embodied.
- sci # calculates sci by dividing carbon by `r`
- sci-accenture # multiplies sci value by 1.05 to account for the "app-gateway"
config:
sci-o:
grid-ci: 350.861
sci:
time: '' # signal to convert /s -> /hr
factor: 89000 # factor to convert per time to per f.unit
observations:
- timestamp: 2023-07-06T00:00
duration: 2419200 # seconds in a month (7 days * 4 weeks)
cpu-util: 4
ram-util: 40
e-cpu: 4.62 # kwh/month
embodied-carbon: 763.33 #gCO2e
Loading

0 comments on commit af8b53d

Please sign in to comment.