-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cleaning workflows Signed-off-by: Dan Benitah <[email protected]> * pull request should on trigger for pull request event - removing on push for PRs Signed-off-by: Dan Benitah <[email protected]> * syntax Signed-off-by: Dan Benitah <[email protected]> * syntax Signed-off-by: Dan Benitah <[email protected]> * moving markdown linting and disabling 2.a-deploy Signed-off-by: Dan Benitah <[email protected]> * adding some jobs dependencies so packaging does not run if code does not build etc... Signed-off-by: Dan Benitah <[email protected]> * moving code analysis into the build step and clean up Signed-off-by: Dan Benitah <[email protected]> --------- Signed-off-by: Dan Benitah <[email protected]> Co-authored-by: danuw <[email protected]>
- Loading branch information
Showing
11 changed files
with
316 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Publish container image to GitHub Packages | ||
name: 2-Publish container image to GitHub Packages | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: . |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.