diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 002090cc..dd2c3b07 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,12 @@ version: 2 updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 2 - package-ecosystem: "nuget" directory: "/csharp/PhoneNumbers" schedule: diff --git a/.github/workflows/build_and_run_unit_tests_linux.yml b/.github/workflows/build_and_run_unit_tests_linux.yml new file mode 100644 index 00000000..1ee29749 --- /dev/null +++ b/.github/workflows/build_and_run_unit_tests_linux.yml @@ -0,0 +1,32 @@ +name: build_and_run_unit_tests_linux + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build_and_run_unit_tests_linux: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.x + - name: Add zip files required for running tests + run: | + (cd resources/geocoding; zip -r ../../resources/geocoding.zip *) + (cd resources/test/geocoding; zip -r ../../../resources/test/testgeocoding.zip *) + - name: Restore dependencies + run: dotnet restore + working-directory: ./csharp + - name: Build solution + run: dotnet build --no-restore + working-directory: ./csharp + - name: Test solution targeting dotnet7.0 only + run: dotnet test --no-build --verbosity normal -p:TargetFrameworks=net7.0 + working-directory: ./csharp diff --git a/.github/workflows/build_and_run_unit_tests_windows.yml b/.github/workflows/build_and_run_unit_tests_windows.yml new file mode 100644 index 00000000..950d26d4 --- /dev/null +++ b/.github/workflows/build_and_run_unit_tests_windows.yml @@ -0,0 +1,32 @@ +name: build_and_run_unit_tests_windows + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build_and_run_unit_tests_windows: + runs-on: windows-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.x + - name: Add zip files required for running tests + run: | + Compress-Archive -Path "resources\geocoding\*" -DestinationPath "resources\geocoding.zip" + Compress-Archive -Path "resources\test\geocoding\*" -DestinationPath "resources\test\testgeocoding.zip" + - name: Restore dependencies + run: dotnet restore + working-directory: ./csharp + - name: Build solution + run: dotnet build --no-restore + working-directory: ./csharp + - name: Test solution + run: dotnet test --no-build --verbosity normal + working-directory: ./csharp diff --git a/csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs b/csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs index ed34dec5..2e302417 100644 --- a/csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs +++ b/csharp/PhoneNumbers/PhoneNumberOfflineGeocoder.cs @@ -144,6 +144,11 @@ private static SortedDictionary> LoadFileNamesFromZip(Strea } var name = entry.FullName.Split('.')[0].Split('\\'); + // fallback to directory separator char if we are unable to use the original implementation of splitting the path + if (name.Length < 2) + { + name = entry.FullName.Split('.')[0].Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + } int country; try {