Skip to content

Commit

Permalink
Merge pull request #404 from tiwatsuka/dev
Browse files Browse the repository at this point in the history
Upgrade to .NET 8.0
  • Loading branch information
vaughanknight authored Mar 5, 2024
2 parents 5fa6862 + defca6f commit 4b1f614
Show file tree
Hide file tree
Showing 50 changed files with 90 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0
FROM mcr.microsoft.com/dotnet/sdk:8.0

RUN apt-get update

Expand Down
34 changes: 19 additions & 15 deletions .github/workflows/1-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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"
DLL_FILE_PATH: "./bin/Release/net8.0/CarbonAware.WebApi.dll"
DOTNET_SRC_DIR: "./src"
# console app packages
DOTNET_SOLUTION: "src/GSF.CarbonAware/src/GSF.CarbonAware.csproj"
Expand Down Expand Up @@ -40,9 +40,9 @@ jobs:

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down Expand Up @@ -86,14 +86,14 @@ jobs:
needs: sln-build-and-test
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:6.0
image: mcr.microsoft.com/dotnet/sdk:8.0
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
Expand Down Expand Up @@ -123,6 +123,8 @@ jobs:

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

- name: Upload swagger artifact
Expand All @@ -144,7 +146,7 @@ jobs:

- name: Docker Run Container
run: |
docker run -d --name runnable-container -p 8080:80 ca-api
docker run -d --name runnable-container -p 8080:8080 ca-api
docker container ls
- name: Docker WGET Health Endpoint
Expand All @@ -164,10 +166,10 @@ jobs:
uses: actions/checkout@v3
with:
ref: dev
- name: Setup .NET Core SDK 6
uses: actions/setup-dotnet@v2
- name: Setup .NET Core SDK 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
include-prerelease: false
- name: Install dependencies
run: dotnet restore
Expand All @@ -179,6 +181,8 @@ jobs:
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
env:
DOTNET_ROLL_FORWARD: LatestMajor
- name: Upload dev artifact
uses: actions/upload-artifact@v1
with:
Expand All @@ -199,10 +203,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

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

- name: Create packages
Expand Down Expand Up @@ -244,4 +248,4 @@ jobs:
command: config
globs: |
./custom.markdownlint.jsonc
{"*[^.github]/**,*"}.md
{"*[^.github]/**,*"}.md
2 changes: 1 addition & 1 deletion .github/workflows/dev_carbon-aware-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
include-prerelease: true

- name: Build with dotnet
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildCLI",
"program": "${workspaceFolder}/src/CarbonAware.CLI/src/bin/Debug/net6.0/caw.dll",
"program": "${workspaceFolder}/src/CarbonAware.CLI/src/bin/Debug/net8.0/caw.dll",
"args": [
"emissions",
"--location", "${input:caw_location}"
Expand All @@ -27,7 +27,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildWebApi",
"program": "${workspaceFolder}/src/CarbonAware.WebApi/src/bin/Debug/net6.0/CarbonAware.WebApi.dll",
"program": "${workspaceFolder}/src/CarbonAware.WebApi/src/bin/Debug/net8.0/CarbonAware.WebApi.dll",
"args": [],
"cwd": "${workspaceFolder}/src/CarbonAware.WebApi/src/",
"stopAtEntry": false,
Expand Down
4 changes: 2 additions & 2 deletions casdk-docs/docs/overview/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ using environment variables, you'd do this:
#### Local project settings

For local-only settings you can use environment variables,
[the Secret Manager tool](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows#secret-manager)
[the Secret Manager tool](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=windows#secret-manager)
, or an untracked Development appsettings file to override the default project
settings.

Expand All @@ -145,7 +145,7 @@ remove the first line of (invalid) comments. Then update any settings according
to your preferences.

> Wherever possible, the projects leverage the
> [default .NET configuration](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#default-application-configuration-sources)
> [default .NET configuration](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0#default-application-configuration-sources)
> expectations. Thus, they can be configured using any file matching the format:
> `appsettings.<ENV>.json`. Where `<ENV>` is the value of the
> `ASPNETCORE_ENVIRONMENT` environment variable. By convention projects tend to
Expand Down
2 changes: 1 addition & 1 deletion casdk-docs/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ generated libraries for your language of choice!

Prerequisites:

- .NET Core 6.0
- .NET Core 8.0
- Alternatively:
- Docker
- VSCode (it is recommended to work in a Dev Container)
Expand Down
8 changes: 4 additions & 4 deletions casdk-docs/docs/tutorial-basics/carbon-aware-webapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ CarbonAware.LocationSources.LocationSource: Warning: New key swedencentral_1 gen
## Error Handling

The WebAPI leveraged the
[.Net controller filter pipeline](https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-6.0)
[.Net controller filter pipeline](https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-8.0)
to ensure that all requests respond with a consistent JSON schema.

![.Net controller filter pipeline image](https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters/_static/filter-pipeline-2.png?view=aspnetcore-6.0)
![.Net controller filter pipeline image](https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters/_static/filter-pipeline-2.png?view=aspnetcore-8.0)

Controllers are responsible for managing the "Success" responses. If an error
occurs in the WebAPI code and an unhandled exception is thrown, the
Expand All @@ -470,7 +470,7 @@ caught and handled by the WebAPI code, the controller will continue to manage
the response.

The .Net framework will automatically respond to validation errors with a
[ValidationProblemDetails](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-6.0)
[ValidationProblemDetails](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-8.0)
object. Using the Exception Filter class enables the WebAPI to consistently
respond with the `ValidationProblemDetails` error schema in all error cases and
take advantage of error handling automatically provided by the framework.
Expand All @@ -489,7 +489,7 @@ specification
cd CarbonAware.WebApi/src
dotnet tool restore
dotnet build --configuration Release --no-restore
dotnet tool run swagger tofile --output ./wwwroot/api/v1/swagger.yaml --yaml bin/Release/net6.0/CarbonAware.WebApi.dll v1
dotnet tool run swagger tofile --output ./wwwroot/api/v1/swagger.yaml --yaml bin/Release/net8.0/CarbonAware.WebApi.dll v1
```
1. The `CarbonAware.WebApi/src/wwwroot/api/v1/swagger.yaml` file contains the supported
OpenApi specification.
Expand Down
8 changes: 4 additions & 4 deletions casdk-docs/docs/tutorial-basics/containerization.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ carbon_aware v1 6293e2528bf2 About an hour ago 230MB
## Run WebApi Image

1. Run the image using `docker run` with host port 8000 mapped to the WebApi
port 80 and configure environment variable settings for
port 8080 and configure environment variable settings for
[WattTime](https://www.watttime.org) provider.

```sh
docker run --rm -p 8000:80 \
docker run --rm -p 8000:8080 \
> -e DataSources__EmissionsDataSource="WattTime" \
> -e DataSources__ForecastDataSource="WattTime" \
> -e DataSources__Configurations__WattTime__Type="WattTime" \
Expand All @@ -40,7 +40,7 @@ carbon_aware v1 6293e2528bf2 About an hour ago 230MB
or the [ElectricityMaps](https://www.electricitymaps.com) provider

```sh
docker run --rm -p 8000:80 \
docker run --rm -p 8000:8080 \
> -e DataSources__EmissionsDataSource="ElectricityMaps" \
> -e DataSources__ForecastDataSource="ElectricityMaps" \
> -e DataSources__Configurations__ElectricityMaps__Type="ElectricityMaps" \
Expand All @@ -52,7 +52,7 @@ carbon_aware v1 6293e2528bf2 About an hour ago 230MB
or the [ElectricityMapsFree](https://www.co2signal.com/) provider

```sh
docker run --rm -p 8000:80 \
docker run --rm -p 8000:8080 \
> -e DataSources__EmissionsDataSource="ElectricityMapsFree" \
> -e DataSources__Configurations__ElectricityMapsFree__Type="ElectricityMapsFree" \
> -e DataSources__Configurations__ElectricityMapsFree__token="<YOUR_CO2SIGNAL_TOKEN>" \
Expand Down
6 changes: 3 additions & 3 deletions casdk-docs/docs/tutorial-extras/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ custom `EmissionsData` sets. The file should be located under the
`<user's repo>/src/data/data-sources/` directory that is part of the repository.
At build time, all the JSON files under `<user's repo>/src/data/data-sources/`
are copied over the destination directory
`<user's repo>/src/CarbonAware.WebApi/src/bin/[Debug|Publish]/net6.0/data-sources/json`
`<user's repo>/src/CarbonAware.WebApi/src/bin/[Debug|Publish]/net8.0/data-sources/json`
that is part of the `CarbonAware.WebApi` assembly. Also the file can be placed
where the assembly `CarbonAware.WebApi.dll` is located under `data-sources/json`
directory. For instance, if the application is installed under `/app`, copy the
Expand Down Expand Up @@ -427,7 +427,7 @@ By setting `LocationDataSourcesConfiguration` property with one or more location
data sources, it is possible to load different `Location` data sets in order to
have more than one location. For instance by setting two location regions, the
property would be set as follow using
[environment](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#naming-of-environment-variables)
[environment](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0#naming-of-environment-variables)
variables:

```sh
Expand Down Expand Up @@ -458,7 +458,7 @@ curl "http://${IP_HOST}:${PORT}/emissions/bylocations/best?location=${REGION}&ti
At build time, all the JSON files under
`<user's repo>/src/data/location-sources` are copied over the destination
directory
`<user's repo>/src/CarbonAware.WebApi/src/bin/[Debug|Publish]/net6.0/location-sources/json`
`<user's repo>/src/CarbonAware.WebApi/src/bin/[Debug|Publish]/net8.0/location-sources/json`
that is part of the `CarbonAware.WebApi` assembly. Also the file can be placed
where the assembly `CarbonAware.WebApi.dll` is located under
`location-sources/json` directory. For instance, if the application is installed
Expand Down
2 changes: 1 addition & 1 deletion casdk-docs/docs/tutorial-extras/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ project. When running in the dev container you will need:
- [Remote Containers extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

Alternatively you can run in your local environment using the
[.NET Core 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0).
[.NET Core 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).

## SDK Configuration

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.418",
"version": "8.0.201",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
{{- end }}
ports:
- name: http
containerPort: 80
containerPort: 8080
protocol: TCP
volumeMounts:
- name: appsettings
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ securityContext: {}

service:
type: ClusterIP
port: 80
port: 8080

ingress:
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion samples/lib-integration/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CarbonAware.CLI/src/CarbonAware.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>caw</AssemblyName>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>34d82203-20b1-4fcd-9bd4-3b247f13bad7</UserSecretsId>
Expand Down
6 changes: 3 additions & 3 deletions src/CarbonAware.CLI/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the base image as the .NET 6.0 SDK (this includes the runtime)
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build-env
# Set the base image as the .NET 8.0 SDK (this includes the runtime)
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build-env

# Copy everything and publish the release (publish implicitly restores and builds)
COPY ./src/ ./
Expand Down Expand Up @@ -27,7 +27,7 @@ LABEL com.github.actions.icon="sliders"
LABEL com.github.actions.color="purple"

# Relayer the .NET SDK, anew with the build output
FROM mcr.microsoft.com/dotnet/runtime:6.0
FROM mcr.microsoft.com/dotnet/runtime:8.0
COPY --from=build-env /out .
RUN apt-get update && apt-get install jq -y

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Loading

0 comments on commit 4b1f614

Please sign in to comment.