From 314ed1256ddd345ad6d802e6a41a274d1ed3a5b1 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Thu, 27 Apr 2023 10:12:16 +0900 Subject: [PATCH 1/4] Add 4-release.yaml Signed-off-by: Yasumasa Suenaga --- .github/workflows/4-release.yaml | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/4-release.yaml diff --git a/.github/workflows/4-release.yaml b/.github/workflows/4-release.yaml new file mode 100644 index 000000000..b4eaa34d1 --- /dev/null +++ b/.github/workflows/4-release.yaml @@ -0,0 +1,43 @@ +name: Publish container image to GitHub Packages + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + publish-container-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.3.0 + with: + flavor: latest=true + tags: type=raw,value=${{ github.ref_name }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v4.0.0 + with: + context: "{{defaultContext}}:src" + file: CarbonAware.WebApi/src/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + provenance: false From 5caa3841efeb6e60598bb464edfd1f5c387be035 Mon Sep 17 00:00:00 2001 From: Dan Benitah Date: Tue, 11 Jul 2023 07:38:14 +0100 Subject: [PATCH 2/4] Devops/clean up workflows (#361) * cleaning workflows Signed-off-by: Dan Benitah * pull request should on trigger for pull request event - removing on push for PRs Signed-off-by: Dan Benitah * syntax Signed-off-by: Dan Benitah * syntax Signed-off-by: Dan Benitah * moving markdown linting and disabling 2.a-deploy Signed-off-by: Dan Benitah * adding some jobs dependencies so packaging does not run if code does not build etc... Signed-off-by: Dan Benitah * moving code analysis into the build step and clean up Signed-off-by: Dan Benitah --------- Signed-off-by: Dan Benitah Co-authored-by: danuw --- .github/workflows/{stale.yml => 0-stale.yml} | 2 +- .github/workflows/1-pr.yaml | 247 ++++++++++++++++++ .github/workflows/2-pre-release.yaml | 2 +- .github/workflows/2.a-deploy.yaml | 42 +++ .github/workflows/build-cli-dotnet.yaml | 34 --- .github/workflows/build-packages.yaml | 56 ---- .github/workflows/build-webapi.yaml | 125 --------- .github/workflows/codeQL-analysis.yaml | 81 ------ .github/workflows/dev_carbon-aware-api.yml | 2 +- .github/workflows/linting.yaml | 35 --- .github/workflows/run-sdkCLI-githubaction.yml | 48 ++-- 11 files changed, 316 insertions(+), 358 deletions(-) rename .github/workflows/{stale.yml => 0-stale.yml} (97%) create mode 100644 .github/workflows/1-pr.yaml create mode 100644 .github/workflows/2.a-deploy.yaml delete mode 100644 .github/workflows/build-cli-dotnet.yaml delete mode 100644 .github/workflows/build-packages.yaml delete mode 100644 .github/workflows/build-webapi.yaml delete mode 100644 .github/workflows/codeQL-analysis.yaml delete mode 100644 .github/workflows/linting.yaml diff --git a/.github/workflows/stale.yml b/.github/workflows/0-stale.yml similarity index 97% rename from .github/workflows/stale.yml rename to .github/workflows/0-stale.yml index 8d284a327..e06fa67b1 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/0-stale.yml @@ -3,7 +3,7 @@ # You can adjust the behavior by modifying this file. # For more information, see: # https://github.com/actions/stale -name: Mark stale issues and pull requests +name: 0-Mark stale issues and pull requests on: schedule: diff --git a/.github/workflows/1-pr.yaml b/.github/workflows/1-pr.yaml new file mode 100644 index 000000000..c6d8f9f44 --- /dev/null +++ b/.github/workflows/1-pr.yaml @@ -0,0 +1,247 @@ +name: 1-PR checks +on: + pull_request: + branches: [ dev, main ] + workflow_dispatch: + +env: + # web app + DOCKERFILE_PATH: "CarbonAware.WebApi/src/Dockerfile" + HEALTH_ENDPOINT: "0.0.0.0:8080/health" + DLL_FILE_PATH: "./bin/Release/net6.0/CarbonAware.WebApi.dll" + DOTNET_SRC_DIR: "./src" + # console app packages + DOTNET_SOLUTION: "src/GSF.CarbonAware/src/GSF.CarbonAware.csproj" + OUTPUT_DIR: "packages" + CONSOLE_APP: "samples/lib-integration/ConsoleApp/ConsoleApp.csproj" + CREATE_PKGS: "scripts/package/create_packages.ps1" + ADD_PKGS: "scripts/package/add_packages.ps1" + + +jobs: + sln-build-and-test: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + defaults: + run: + working-directory: ./src + steps: + + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Unit Tests + run: dotnet test --no-build --verbosity normal + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + #- name: Autobuild + # uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + webapp-container-dotnet-build: + needs: sln-build-and-test + 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 ./wwwroot/api/v1/swagger.yaml --yaml ${{ env.DLL_FILE_PATH }} v1 + working-directory: ./src/CarbonAware.WebApi/src + + - name: Upload swagger artifact + uses: actions/upload-artifact@v1 + with: + name: pr-swagger.yaml + path: src/CarbonAware.WebApi/src/wwwroot/api/v1/swagger.yaml + + webapp-container-validation: + needs: sln-build-and-test + 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} + + api-comparison: + needs: webapp-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 ./wwwroot/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/wwwroot/api/v1/swagger.yaml + - uses: actions/download-artifact@v3 + with: + name: pr-swagger.yaml + path: ./src/CarbonAware.WebApi/src/wwwroot/api/v1/pr-swagger.yaml + - name: API Diff Comparison + run: | + diff ./wwwroot/api/v1/pr-swagger.yaml ./wwwroot/api/v1/swagger.yaml && echo "No API Changes detected" || echo "::warning:: API Changed" + + dotnet-pack: + needs: sln-build-and-test + runs-on: ubuntu-latest + steps: + - name: Checkout + 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: Create packages + shell: pwsh + run: ${{ env.CREATE_PKGS }} ${{ env.DOTNET_SOLUTION }} ${{ env.OUTPUT_DIR }} + + - name: Restore current packages for ConsoleApp + run: dotnet restore ${{ env.CONSOLE_APP }} + + - name: Add packages to ConsoleApp + shell: pwsh + run: ${{ env.ADD_PKGS }} ${{ env.CONSOLE_APP}} ${{ env.OUTPUT_DIR }} + + - name: Cat ConsoleApp project file + run: cat ${{ env.CONSOLE_APP }} + + - name: Restore packages for ConsoleApp + run: dotnet restore ${{ env.CONSOLE_APP }} + + - name: Build ConsoleApp + run: dotnet build ${{ env.CONSOLE_APP }} + + # Non-blocking job that checks .md file locations and also lints them + markdown-linting: + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v2 + + # See the script for details about exceptions to this check + - name: Markdown files should be located in docs folder + continue-on-error: true + run: "scripts/markdown/check-markdown-files.sh" + + - name: markdownlint-cli2-action + uses: DavidAnson/markdownlint-cli2-action@v9 + continue-on-error: true + with: + command: config + globs: | + ./custom.markdownlint.jsonc + {"*[^.github]/**,*"}.md \ No newline at end of file diff --git a/.github/workflows/2-pre-release.yaml b/.github/workflows/2-pre-release.yaml index b04b85ec1..11f07d5f0 100644 --- a/.github/workflows/2-pre-release.yaml +++ b/.github/workflows/2-pre-release.yaml @@ -1,4 +1,4 @@ -name: Publish container image to GitHub Packages +name: 2-Publish container image to GitHub Packages on: push: diff --git a/.github/workflows/2.a-deploy.yaml b/.github/workflows/2.a-deploy.yaml new file mode 100644 index 000000000..28068412d --- /dev/null +++ b/.github/workflows/2.a-deploy.yaml @@ -0,0 +1,42 @@ +# # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# # More GitHub Actions for Azure: https://github.com/Azure/actions + +# name: 2.a-Deploy Container to Azure Web App - carbon-aware-api + +# # Check what scenario we are in +# # If push to dev, deploy latest pre image + +# # TODO: +# # - add how to get the latest pre package +# # - test? +# # - deploy (existing code to use new image instead of what would have come from build step) + +# on: +# push: +# branches: +# - dev +# workflow_dispatch: + +# jobs: +# deploy: +# runs-on: ubuntu-latest +# permissions: +# packages: read +# environment: +# name: 'Production' +# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + +# steps: +# - name: Download artifact from build job +# uses: actions/download-artifact@v2 +# with: +# name: CarbonAwareApi + +# - name: Deploy to Azure Web App +# id: deploy-to-webapp +# uses: azure/webapps-deploy@v2 +# with: +# app-name: 'carbon-aware-api' +# slot-name: 'Production' +# publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D9BE266F4F034E79818711107BC7DDC5 }} +# package: . \ No newline at end of file diff --git a/.github/workflows/build-cli-dotnet.yaml b/.github/workflows/build-cli-dotnet.yaml deleted file mode 100644 index 86e667aba..000000000 --- a/.github/workflows/build-cli-dotnet.yaml +++ /dev/null @@ -1,34 +0,0 @@ -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 \ No newline at end of file diff --git a/.github/workflows/build-packages.yaml b/.github/workflows/build-packages.yaml deleted file mode 100644 index 8d195e05f..000000000 --- a/.github/workflows/build-packages.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: Build and Install GSF Packages on Sample ConsoleApp - -on: - push: - branches: [ dev, main ] - pull_request: - branches: [ dev, main ] - paths: - - 'src/**' - - '.github/workflows/**' - - 'samples/lib-integration/ConsoleApp/**' - - 'scripts/package/**' - -env: - DOTNET_SOLUTION: "src/GSF.CarbonAware/src/GSF.CarbonAware.csproj" - OUTPUT_DIR: "packages" - CONSOLE_APP: "samples/lib-integration/ConsoleApp/ConsoleApp.csproj" - CREATE_PKGS: "scripts/package/create_packages.ps1" - ADD_PKGS: "scripts/package/add_packages.ps1" - -jobs: - dotnet-pack: - runs-on: ubuntu-latest - steps: - - name: Checkout - 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: Create packages - shell: pwsh - run: ${{ env.CREATE_PKGS }} ${{ env.DOTNET_SOLUTION }} ${{ env.OUTPUT_DIR }} - - - name: Restore current packages for ConsoleApp - run: dotnet restore ${{ env.CONSOLE_APP }} - - - name: Add packages to ConsoleApp - shell: pwsh - run: ${{ env.ADD_PKGS }} ${{ env.CONSOLE_APP}} ${{ env.OUTPUT_DIR }} - - - name: Cat ConsoleApp project file - run: cat ${{ env.CONSOLE_APP }} - - - name: Restore packages for ConsoleApp - run: dotnet restore ${{ env.CONSOLE_APP }} - - - name: Build ConsoleApp - run: dotnet build ${{ env.CONSOLE_APP }} - - - name: Run ConsoleApp - run: dotnet run --project ${{ env.CONSOLE_APP }} - diff --git a/.github/workflows/build-webapi.yaml b/.github/workflows/build-webapi.yaml deleted file mode 100644 index 2171b6b1d..000000000 --- a/.github/workflows/build-webapi.yaml +++ /dev/null @@ -1,125 +0,0 @@ -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" - 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 ./wwwroot/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/wwwroot/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} - -# 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 ./wwwroot/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/wwwroot/api/v1/swagger.yaml -# - uses: actions/download-artifact@v3 -# with: -# name: pr-swagger.yaml -# path: ./src/CarbonAware.WebApi/src/wwwroot/api/v1/pr-swagger.yaml -# - name: API Diff Comparison -# run: | -# diff ./wwwroot/api/v1/pr-swagger.yaml ./wwwroot/api/v1/swagger.yaml && echo "No API Changes detected" || echo "::warning:: API Changed" diff --git a/.github/workflows/codeQL-analysis.yaml b/.github/workflows/codeQL-analysis.yaml deleted file mode 100644 index 7624b0f52..000000000 --- a/.github/workflows/codeQL-analysis.yaml +++ /dev/null @@ -1,81 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "Code Security Scan with CodeQL" - -on: - push: - pull_request: - # The branches below must be a subset of the branches above - branches: [ dev, main ] - schedule: - - cron: '42 23 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0' - - - name: Restore dependencies - run: dotnet restore - working-directory: './src/' - - name: Build - run: dotnet build --no-restore - working-directory: './src/' - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - #- name: Autobuild - # uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/dev_carbon-aware-api.yml b/.github/workflows/dev_carbon-aware-api.yml index 9eb8aba88..fc3dc2494 100644 --- a/.github/workflows/dev_carbon-aware-api.yml +++ b/.github/workflows/dev_carbon-aware-api.yml @@ -1,7 +1,7 @@ # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy # More GitHub Actions for Azure: https://github.com/Azure/actions -name: Build and deploy ASP.Net Core app to Azure Web App - carbon-aware-api +name: 2.a-Build and deploy ASP.Net Core app to Azure Web App - carbon-aware-api on: push: diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml deleted file mode 100644 index dbf6e651a..000000000 --- a/.github/workflows/linting.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: "Linting" - -on: - push: - paths: - - './**' - - '.github/workflows/**' - pull_request: - branches: [ dev, main ] - paths: - - './**' - -jobs: - # Non-blocking job that checks .md file locations and also lints them - markdown: - runs-on: ubuntu-latest - steps: - - name: Check out the code - uses: actions/checkout@v2 - - # See the script for details about exceptions to this check - - name: Markdown files should be located in docs folder - continue-on-error: true - run: "scripts/markdown/check-markdown-files.sh" - - - name: markdownlint-cli2-action - uses: DavidAnson/markdownlint-cli2-action@v9 - continue-on-error: true - with: - command: config - globs: | - ./custom.markdownlint.jsonc - {"*[^.github]/**,*"}.md - - diff --git a/.github/workflows/run-sdkCLI-githubaction.yml b/.github/workflows/run-sdkCLI-githubaction.yml index 76d4687fc..8cf1d34a8 100644 --- a/.github/workflows/run-sdkCLI-githubaction.yml +++ b/.github/workflows/run-sdkCLI-githubaction.yml @@ -1,28 +1,28 @@ -name: using CarboneAware Github action in sample pipeline +# name: using CarboneAware Github action in sample pipeline -on: - push: - paths: - - 'src/**' - - '.github/workflows/**' - pull_request: - branches: [ dev, main ] - paths: - - 'src/**' +# on: +# push: +# paths: +# - 'src/**' +# - '.github/workflows/**' +# pull_request: +# branches: [ dev, main ] +# paths: +# - 'src/**' -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: CarboneAWare metrics - id: carboneaware-metrics - uses: Green-Software-Foundation/carbon-aware-sdk@sdkCLI-githubaction # here "sdkCLI-githubaction" is the name of the branch - with: - location: westeurope,francecentral,westus - #config: /carbon-aware.json - #fromTime: - #toTime: +# jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - name: CarboneAWare metrics +# id: carboneaware-metrics +# uses: Green-Software-Foundation/carbon-aware-sdk@sdkCLI-githubaction # here "sdkCLI-githubaction" is the name of the branch +# with: +# location: westeurope,francecentral,westus +# #config: /carbon-aware.json +# #fromTime: +# #toTime: - - name: Deplpoy Workload to Selected Region - run: echo deploying ML Training Job to Region "${{ steps.carboneaware-metrics.outputs.LowestEmissionsLocation}}" +# - name: Deplpoy Workload to Selected Region +# run: echo deploying ML Training Job to Region "${{ steps.carboneaware-metrics.outputs.LowestEmissionsLocation}}" From 06c5577397815f2e867a349da7c74be06a9423d1 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Tue, 11 Jul 2023 15:40:10 +0900 Subject: [PATCH 3/4] Skip deploy workflows in forked repos (#347) * Skip deploy workflows in forked repos Signed-off-by: Yasumasa Suenaga * Add vars Signed-off-by: Yasumasa Suenaga --------- Signed-off-by: Yasumasa Suenaga --- .github/workflows/2-pre-release.yaml | 1 + .github/workflows/dev_carbon-aware-api.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/2-pre-release.yaml b/.github/workflows/2-pre-release.yaml index 11f07d5f0..ddd6afe72 100644 --- a/.github/workflows/2-pre-release.yaml +++ b/.github/workflows/2-pre-release.yaml @@ -18,6 +18,7 @@ concurrency: jobs: publish-container-image: + if: github.repository == 'Green-Software-Foundation/carbon-aware-sdk' || vars.ENABLE_PRERELEASE_WORKFLOW == 'true' runs-on: ubuntu-latest permissions: packages: write diff --git a/.github/workflows/dev_carbon-aware-api.yml b/.github/workflows/dev_carbon-aware-api.yml index fc3dc2494..643d58b8d 100644 --- a/.github/workflows/dev_carbon-aware-api.yml +++ b/.github/workflows/dev_carbon-aware-api.yml @@ -11,6 +11,7 @@ on: jobs: build: + if: github.repository == 'Green-Software-Foundation/carbon-aware-sdk' || vars.ENABLE_WEBAPP_WORKFLOW == 'true' runs-on: windows-latest steps: From ad440050bae16e311f1eae13552373f30553d433 Mon Sep 17 00:00:00 2001 From: Vaughan Knight Date: Tue, 25 Jul 2023 17:18:24 +1000 Subject: [PATCH 4/4] 1.1.0 CHANGELOG Updates (#371) * 1.1.0 CHANGELOG Updates 1.1.0 CHANGELOG Updates, updated for release. * Minor update Minor update * Update CHANGELOG.md - Fix typos. - Add clarification for HTTP 500 bugfix. - Add clarification for required signoff. Signed-off-by: Szymon Duchniewicz * DCO Remediation Commit for Vaughan Knight I, Vaughan Knight , hereby add my Signed-off-by to this commit: d6c4e813e89c5aad9081b9064e48642044f7a117 I, Vaughan Knight , hereby add my Signed-off-by to this commit: e6c4735d6369becedfe51d6a57fe3edf8288452b Signed-off-by: Vaughan Knight --------- Signed-off-by: Szymon Duchniewicz Signed-off-by: Vaughan Knight Co-authored-by: Szymon Duchniewicz --- CHANGELOG.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 643f01474..802f5c2ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Carbon Aware SDK will be documented in this file. -## [Unreleased] +## [1.1.0] - 2023-18-07 ### Added @@ -12,13 +12,20 @@ All notable changes to the Carbon Aware SDK will be documented in this file. ### Fixed - Fixed generated test data that had time bomb bug that was in test data, which caused integration tests to fail. This is now automatically generated each time. +- Fixed some bugs that related to underlying data source errors surfacing as HTTP 500 errors from the API. These should now be more consistent. +- Fixed an issue where UTF-8 passwords were encoded as ASCII for WattTime API, causing integration failure. +- Fixes some bugs in unit tests with uncaught scenarios, or faulty tests. ### Changed +- No previous API's were changed. +- Configuration has changed. Refer to upgrading from 1.0.0 to 1.1.0 below. +- Time is now always in UTC. Previously the API may have returned local time depending on underlying API. + #### API - `/locations` - Show the list of configured named locations that can be used in the API. -- `/api/v1/swagger.yaml` - Provide OpenAPI document. +- `/api/v1/swagger.yaml` - Provides OpenAPI document now at public endpoint when deployed. #### API Deployment @@ -26,12 +33,54 @@ All notable changes to the Carbon Aware SDK will be documented in this file. #### SDK -- Funcationality for forecast and historical data have been seperated into seperate interfaces. This impacts configuration, see upgrading from 1.0.0 to 1.1.0 for more information -- Additional tests +- SDK was abstracted to provide a library for DLL import usage, which now allows users to use the SDK in their projects directly without the need to deploy an API. This is useful in scenarios where the API can not be centralised. Note - we still highly recommend centralising for management of the API and audit capabilities with observability. +- Functionality for forecast and historical data have been seperated into seperate interfaces. This impacts configuration, see upgrading from 1.0.0 to 1.1.0 for more information. +- Additional tests across the SDK have been added. +- Aggregation tier in the SDK was removed, this should not impact users of the SDK, but may impact maintainers who were actively contributing. + + +#### Other + +- All contributors need to signoff commits for contribution using `git commit -s`. +- Added PR release workflow improvements for the project management of the CA SDK project team. +- Updated the project to prune stale PR's and issues to help with the management of the CA SDK project. + ### Upgrading from 1.0.0 to 1.1.0 -- Configuration changes are required due to historical and forecast configuration now being decoupled. Refer to ___ for a guide. +- Configuration changes are required due to historical and forecast configuration now being decoupled. Refer to - [Configuration](docs/configuration.md) for a guide. The following is provided as an example of the new data source configuration format. +```json +{ + "DataSources": { + "EmissionsDataSource": "Json", + "ForecastDataSource": "WattTime", + "Configurations": { + "WattTime": { + "Type": "WattTime", + "Username": "username", + "Password": "password", + "BaseURL": "https://api2.watttime.org/v2/", + "Proxy": { + "useProxy": true, + "url": "http://10.10.10.1", + "username": "proxyUsername", + "password": "proxyPassword" + } + }, + "ElectricityMaps": { + "Type": "ElectricityMaps", + "APITokenHeader": "auth-token", + "APIToken": "myAwesomeToken", + "BaseURL": "https://api.electricitymap.org/v3/" + }, + "Json": { + "Type": "Json", + "DataFileLocation": "test-data-azure-emissions.json" + } + } + } +} +``` ## [1.0.0] - 2022-10-01