Skip to content

Commit 46ef382

Browse files
authored
feat: add github action pr builds for building project, and running tests on linux and windows (#204)
* feat: add github action pr builds for building project, and running tests on linux and windows * feat: update and ensure linux ci cd test build only run on dotnet 7 framework only * feat: add sensible timeouts for github action builds and add automatic upgrades for github actions * feat: use a safe implementation of falling back to char separator for PhoneNumberOfflineGeocoder.cs
1 parent 9aa1b19 commit 46ef382

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
version: 2
77
updates:
8+
# Maintain dependencies for GitHub Actions
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
13+
open-pull-requests-limit: 2
814
- package-ecosystem: "nuget"
915
directory: "/csharp/PhoneNumbers"
1016
schedule:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: build_and_run_unit_tests_linux
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build_and_run_unit_tests_linux:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 20
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v3
18+
with:
19+
dotnet-version: 8.x
20+
- name: Add zip files required for running tests
21+
run: |
22+
(cd resources/geocoding; zip -r ../../resources/geocoding.zip *)
23+
(cd resources/test/geocoding; zip -r ../../../resources/test/testgeocoding.zip *)
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
working-directory: ./csharp
27+
- name: Build solution
28+
run: dotnet build --no-restore
29+
working-directory: ./csharp
30+
- name: Test solution targeting dotnet7.0 only
31+
run: dotnet test --no-build --verbosity normal -p:TargetFrameworks=net7.0
32+
working-directory: ./csharp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: build_and_run_unit_tests_windows
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build_and_run_unit_tests_windows:
12+
runs-on: windows-latest
13+
timeout-minutes: 20
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v3
18+
with:
19+
dotnet-version: 8.x
20+
- name: Add zip files required for running tests
21+
run: |
22+
Compress-Archive -Path "resources\geocoding\*" -DestinationPath "resources\geocoding.zip"
23+
Compress-Archive -Path "resources\test\geocoding\*" -DestinationPath "resources\test\testgeocoding.zip"
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
working-directory: ./csharp
27+
- name: Build solution
28+
run: dotnet build --no-restore
29+
working-directory: ./csharp
30+
- name: Test solution
31+
run: dotnet test --no-build --verbosity normal
32+
working-directory: ./csharp

csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ private static SortedDictionary<int, HashSet<string>> LoadFileNamesFromZip(Strea
148148
}
149149

150150
var name = entry.FullName.Split('.')[0].Split('\\');
151+
// fallback to directory separator char if we are unable to use the original implementation of splitting the path
152+
if (name.Length < 2)
153+
{
154+
name = entry.FullName.Split('.')[0].Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
155+
}
151156
int country;
152157
try
153158
{

0 commit comments

Comments
 (0)