Skip to content

Commit

Permalink
Test package fix
Browse files Browse the repository at this point in the history
Signed-off-by: Bill DeRusha <[email protected]>
  • Loading branch information
bderusha committed Sep 1, 2023
1 parent 5e459d9 commit c5e0f4d
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/1-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
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"
DOTNET_SOLUTION: "src/CarbonAwareSDK.sln"
OUTPUT_DIR: "packages"
CONSOLE_APP: "samples/lib-integration/ConsoleApp/ConsoleApp.csproj"
CREATE_PKGS: "scripts/package/create_packages.ps1"
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/verify-azure-function-with-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,31 @@ jobs:
- name: Docker Target Final
run: |
docker build --no-cache . -f ${{ env.DOCKERFILE_PATH }} -t ${{ env.CONTAINER_IMAGE_NAME }}
docker rmi -f $(docker images -f "dangling=true" -q)
docker image prune -f
- name: Docker Run Container
run: docker run -d --name ${{ env.CONTAINER_RUNTIME_NAME }} -p 8080:80 ${{ env.CONTAINER_IMAGE_NAME }}
run: |
docker run -d --name ${{ env.CONTAINER_RUNTIME_NAME }} -p 8080:80 ${{ env.CONTAINER_IMAGE_NAME }}
timeout 30 bash -c -- 'while [ -z "$(docker ps -q)" ]; do echo "waiting for container to start" && sleep 5s; done'
docker ps
# Request fails with authentication error. Expected
- name: Get Average Carbon Intensity
run: |
set +e
ret_code=$(wget -S -t 5 --waitretry=5 "http://0.0.0.0:8080/api/GetAverageCarbonIntensity?startDate=2022-03-01T15:30:00Z&endDate=2022-03-01T18:30:00Z&location=eastus" 2>&1 | grep "HTTP/" | awk '{print $2}')
set -x
sleep 5s
curl -s -v "http://0.0.0.0:8080/api/GetAverageCarbonIntensity?startDate=2022-03-01T15:30:00Z&endDate=2022-03-01T18:30:00Z&location=eastus")
set -e
[ "401" == $ret_code ]
echo "Return Code: $ret_code"
[ "401" = "$ret_code" ]
# Request fails with authentication error. Expected
- name: Get Current Forecast
run: |
set +e
ret_code=$(wget -S -t 5 --waitretry=5 "http://0.0.0.0:8080/api/GetCurrentForecast" --header "Content-Type: application/json" --post-data '{"startDate":"2022-11-02T15:30:00Z","endDate":"2022-11-02T18:30:00Z","location":"eastus","duration":"15"}' 2>&1 | grep "HTTP/" | awk '{print $2}')
set -x
ret_code=$(curl -4 --retry-connrefused --retry 6 --retry-delay 10 -s -o /dev/null -w "%{response_code}" -X POST -H "Content-Type: application/json" -d '{"startDate":"2022-11-02T15:30:00Z","endDate":"2022-11-02T18:30:00Z","location":"eastus","duration":"15"}' "http://0.0.0.0:8080/api/GetCurrentForecast"
set -e
[ "401" == $ret_code ]
echo "Return Code: $ret_code"
[ "401" = "$ret_code" ]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ src/data/location-sources/custom-azure-zones.json

# exclude artifacts on java-client example
samples/java-client/target

# exclude artifacts from default package builder
/packages
24 changes: 12 additions & 12 deletions docs/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ showing how the package can be consumed.
- [Console App Sample](#console-app-sample)
- [Run the Sample Console App](#run-the-sample-console-app)

## Included Projects
## Included Packages

The current package include 7 projects from the SDK:
The current solution creates 5 packages from the SDK projects:

1. "GSF.CarbonAware"
2. "CarbonAware"
3. "CarbonAware.DataSources.ElectricityMapsFree"
4. "CarbonAware.DataSources.ElectricityMaps"
5. "CarbonAware.DataSources.Json"
6. "CarbonAware.DataSources.WattTime"
7. "CarbonAware.LocationSources"

These 7 projects enable users of the library to consume the current endpoints
exposed by the library. The package that needs to be added to a new C# project
is `GSF.CarbonAware`.
1. "CarbonAware"
2. "CarbonAware.LocationSources"
2. "CarbonAware.DataSources.ElectricityMapsFree"
3. "CarbonAware.DataSources.ElectricityMaps"
4. "CarbonAware.DataSources.Json"
5. "CarbonAware.DataSources.WattTime"

Adding the `GSF.CarbonAware` project to your C# projects gives you access to all
CarbonAware SDK interfaces.
Additionally, operators must add any data source packages they plan to use.

## Included Scripts

Expand Down
2 changes: 1 addition & 1 deletion samples/azure/azure-function/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY ["scripts/", "data/scripts/"]
COPY ["samples/", "data/samples/"]

WORKDIR /data
RUN pwsh -c scripts/package/create_packages.ps1 src/GSF.CarbonAware/src/GSF.CarbonAware.csproj /packages && \
RUN pwsh -c scripts/package/create_packages.ps1 src/CarbonAwareSDK.sln /packages && \
dotnet restore "samples/azure/azure-function/function.csproj" && \
pwsh -c scripts/package/add_packages.ps1 samples/azure/azure-function/function.csproj /packages && \
dotnet build "samples/azure/azure-function/function.csproj" -c Release -o /app/build
Expand Down
2 changes: 1 addition & 1 deletion scripts/package/create_packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if ([string]::IsNullOrEmpty($DOTNET_SOLUTION) -or [string]::IsNullOrEmpty($DEST_
$REVISION = $(git rev-parse HEAD)
$BRANCH = "dev"

New-Item -Path $DEST_PACKAGES -ItemType Directory
New-Item -Path $DEST_PACKAGES -ItemType Directory -Force | Out-Null

# Remove existing packages
Get-ChildItem -Path $path -Recurse -Include *.nupkg, *.snupkg | Remove-Item
Expand Down
8 changes: 8 additions & 0 deletions src/CarbonAware.CLI/src/CarbonAware.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
<ProjectReference Include="..\..\CarbonAware\src\CarbonAware.csproj" />
<ProjectReference Include="..\..\CarbonAware.LocationSources\src\CarbonAware.LocationSources.csproj" />
<ProjectReference Include="..\..\GSF.CarbonAware\src\GSF.CarbonAware.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.Json\src\CarbonAware.DataSources.Json.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.WattTime\src\CarbonAware.DataSources.WattTime.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMaps\src\CarbonAware.DataSources.ElectricityMaps.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMapsFree\src\CarbonAware.DataSources.ElectricityMapsFree.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/CarbonAware.WebApi/src/CarbonAware.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,6 +30,14 @@
<ItemGroup>
<ProjectReference Include="..\..\CarbonAware\src\CarbonAware.csproj" />
<ProjectReference Include="..\..\GSF.CarbonAware\src\GSF.CarbonAware.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.Json\src\CarbonAware.DataSources.Json.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.WattTime\src\CarbonAware.DataSources.WattTime.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMaps\src\CarbonAware.DataSources.ElectricityMaps.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMapsFree\src\CarbonAware.DataSources.ElectricityMapsFree.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 0 additions & 8 deletions src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@
<ProjectReference
Include="..\..\CarbonAware.LocationSources\src\CarbonAware.LocationSources.csproj"
PrivateAssets="all" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.Json\src\CarbonAware.DataSources.Json.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.WattTime\src\CarbonAware.DataSources.WattTime.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMaps\src\CarbonAware.DataSources.ElectricityMaps.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMapsFree\src\CarbonAware.DataSources.ElectricityMapsFree.csproj" />
<ProjectReference Include="..\..\CarbonAware\src\CarbonAware.csproj" PrivateAssets="all" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/GSF.CarbonAware/test/GSF.CarbonAware.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<ItemGroup>
<ProjectReference Include="..\..\CarbonAware\src\CarbonAware.csproj" />
<ProjectReference Include="..\src\GSF.CarbonAware.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.Json\src\CarbonAware.DataSources.Json.csproj" />
<ProjectReference
Include="..\..\CarbonAware.DataSources\CarbonAware.DataSources.WattTime\src\CarbonAware.DataSources.WattTime.csproj" />
</ItemGroup>

</Project>

0 comments on commit c5e0f4d

Please sign in to comment.