Skip to content

Commit

Permalink
Merge pull request #113 from Green-Software-Foundation/dev
Browse files Browse the repository at this point in the history
Release 1.0 PR to Main for Official Release.  Thank you to all involved.  This is only the beginning of a more sustainable future! 💚
  • Loading branch information
vaughanknight authored Oct 13, 2022
2 parents ada4c8c + 5eff3dc commit 3310d86
Show file tree
Hide file tree
Showing 267 changed files with 18,538 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0

RUN apt-get update

RUN apt-get install -y iputils-ping procps

RUN echo Installing Code Generator CLI

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs build-essential default-jre
RUN npm install @openapitools/openapi-generator-cli -g

RUN echo Done!

33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Dev Container",
"dockerFile": "Dockerfile",
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
// "settings": {
// "terminal.integrated.shell.linux": "/bin/bash",
// "lldb.executable": "/usr/bin/lldb"
// },

// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
// "appPort": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Comment out the next line to run as root
// "remoteUser": "vscode",

// Uncomment the line below to mount your local usersecrets into the devcontainer from a Windows OS
// "mounts": [ "source=${localEnv:APPDATA}/Microsoft/UserSecrets,target=/root/.microsoft/usersecrets,type=bind" ],

// Uncomment the line below to mount your local usersecrets into the devcontainer from a Mac/Linux OS
// "mounts": [ "source=${localEnv:HOME}/.microsoft/usersecrets,target=/root/.microsoft/usersecrets,type=bind" ],

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-dotnettools.csharp"
]
}
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# Setting build up so that license changes and CODEOWNERS changes
# require admin approval.

* @vaughanknight
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: contact
attributes:
label: Contact Details
description: How can we get in touch with you if we need more info?
placeholder: ex. [email protected]
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: dropdown
id: client
attributes:
label: client
description: What client of the Carbon Aware SDK are you running?
options:
- WebAPI (Default)
- CLI
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow the [Way We Work](https://github.com/Green-Software-Foundation/standards_wg/blob/main/the_way_we_work.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Green Software Foundation Membership Enquiries
url: https://greensoftware.foundation/join-us/
about: Join the Green Software Foundation
- name: Carbon Aware SDK Project Proposal
url: https://greensoftware.foundation/projects/carbon-aware-sdk
about: GSF Page on Carbon Aware SDK
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/contribution-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Feature Contribution
description: Contribute a Feature
title: "[Feature Contribution]: "
labels: ["feature", "triage"]
assignees:
- vaughanknight
body:
- type: markdown
attributes:
value: |
Thank you for wanting to contribute to the Carbon Aware SDK! Please fill out this Issue Template with your feature contribution.
- type: textarea
id: feature-desc
attributes:
label: What happened?
description: Please Describe the need for the feature
placeholder: User stories, feature specifications, contribution benefits.
value: "Feature XYZ will perform function ABC and enable development for project 123."
validations:
required: true
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow the [Way We Work](https://github.com/Green-Software-Foundation/standards_wg/blob/main/the_way_we_work.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
- type: checkboxes
id: commitment
attributes:
label: Feature Commitment
description: By submitting this issue, you commit to contributing the feature outlined here.
options:
- label: I commit to contributing this feature as a PR and working with the GSF to merge this feature into the Carbon Aware SDK.
required: true

20 changes: 20 additions & 0 deletions .github/codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
codecov:
require_ci_to_pass: no

coverage:
precision: 2
round: down
range: "70...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,files"
behavior: default
require_changes: no
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Issue Number: (Link to Github Issue or Azure Dev Ops Task/Story)

## Summary
One sentence summary of PR

## Changes

- List of comprehensive changes

## Checklist

- [ ] Local Tests Passing?
- [ ] CICD and Pipeline Tests Passing?
- [ ] Added any new Tests?
- [ ] Documentation Updates Made?
- [ ] Are there any API Changes? If yes, please describe below.
- [ ] This is not a breaking change. If it is, please describe it below.

## Are there API Changes?
If yes, what are the expected API Changes? Please link to an API-Comparison workflow with the API Diff.

## Is this a breaking change?
If yes, what workflow does this break?

## Anything else?
Other comments, collaborators, etc.
This PR Closes Issue #
34 changes: 34 additions & 0 deletions .github/workflows/build-cli-dotnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: BUILD CLI in DOTNET

on:
push:
paths:
- 'src/**'
- '.github/workflows/**'
pull_request:
branches: [ dev, main ]
paths:
- 'src/**'

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src
steps:

- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Unit Tests
run: dotnet test --no-build --verbosity normal
130 changes: 130 additions & 0 deletions .github/workflows/build-webapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Docker Web API Build

on:
push:
branches: [ dev, main ]
pull_request:
branches: [ dev, main ]
paths:
- 'src/**'
- '.github/workflows/**'

env:
DOCKERFILE_PATH: "CarbonAware.WebApi/src/Dockerfile"
HEALTH_ENDPOINT: "0.0.0.0:8080/health"
DATA_ENDPOINT: "0.0.0.0:8080/emissions/bylocation?location=eastus"
DLL_FILE_PATH: "./bin/Release/net6.0/CarbonAware.WebApi.dll"
DOTNET_SRC_DIR: "./src"

jobs:
container-dotnet-build:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:6.0
steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK 6
uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
include-prerelease: false

- name: Install dependencies
run: dotnet restore
working-directory: ${{ env.DOTNET_SRC_DIR }}

- name: Install tools
run: dotnet tool restore
working-directory: ${{ env.DOTNET_SRC_DIR }}/CarbonAware.WebApi/src

- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ${{ env.DOTNET_SRC_DIR }}

- name: Unit Test + Code Coverage
run: dotnet test --filter TestCategory=Unit --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=json
working-directory: ${{ env.DOTNET_SRC_DIR }}

- name: Integration Test + Code Coverage
run: dotnet test --filter TestCategory=Integration --no-restore --verbosity normal /p:CollectCoverage=true /p:MergeWith=\"./coverage.json\" /p:CoverletOutputFormat=\"json,opencover\"
working-directory: ${{ env.DOTNET_SRC_DIR }}

- name: Codecov
uses: codecov/codecov-action@v2
with:
directory: ${{ env.DOTNET_SRC_DIR }}

- name: Generate Open API
run: dotnet tool run swagger tofile --output ./api/v1/swagger.yaml --yaml ${{ env.DLL_FILE_PATH }} v1
working-directory: ./src/CarbonAware.WebApi/src

- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: pr-swagger.yaml
path: src/CarbonAware.WebApi/src/api/v1/swagger.yaml

container-validation:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Docker Target Final
run: docker build . -f ${DOCKERFILE_PATH} -t ca-api
working-directory: ./src

- name: Docker Run Container
run: |
docker run -d --name runnable-container -p 8080:80 ca-api
docker container ls
- name: Docker WGET Health Endpoint
run: |
wget -t 5 --waitretry=5 ${HEALTH_ENDPOINT}
- name: Docker WGET Data Endpoint
run: |
wget -t 5 --waitretry=5 ${DATA_ENDPOINT}
api-comparison:
needs: container-dotnet-build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/CarbonAware.WebApi/src
container:
image: mcr.microsoft.com/dotnet/sdk
steps:
- name: Checkout Dev Branch
uses: actions/checkout@v3
with:
ref: dev
- name: Setup .NET Core SDK 6
uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
include-prerelease: false
- name: Install dependencies
run: dotnet restore
working-directory: ${{ env.DOTNET_SRC_DIR }}
- name: Install tools
run: dotnet tool restore
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ${{ env.DOTNET_SRC_DIR }}
- name: Generate Open API
run: dotnet tool run swagger tofile --output ./api/v1/swagger.yaml --yaml ${{ env.DLL_FILE_PATH }} v1
- name: Upload dev artifact
uses: actions/upload-artifact@v1
with:
name: dev-swagger.yaml
path: src/CarbonAware.WebApi/src/api/v1/swagger.yaml
- uses: actions/download-artifact@v3
with:
name: pr-swagger.yaml
path: ./src/CarbonAware.WebApi/src/api/v1/pr-swagger.yaml
- name: API Diff Comparison
run: |
diff ./api/v1/pr-swagger.yaml ./api/v1/swagger.yaml && echo "No API Changes detected" || echo "::warning:: API Changed"
Loading

0 comments on commit 3310d86

Please sign in to comment.