Skip to content

chore: Update dev/test environment #6

chore: Update dev/test environment

chore: Update dev/test environment #6

# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Test localization
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]
jobs:
localization:
strategy:
matrix:
os: [ubuntu-latest, windows-latest] #, macos-latest
locale: [
# 'fr_FR.UTF-8', # Uses comma as decimal separator
# 'de_DE.UTF-8', # Uses comma as decimal, dot as thousands
'ru_RU.UTF-8' # Uses comma as decimal, space as thousands
]
python-version: ['3.12']
name: "Py${{ matrix.python-version }}|${{ matrix.locale }}»${{ matrix.os }}"
runs-on: ${{ matrix.os }}
env:
PYTHONPATH: ${{ github.workspace }}
# Force Python to use locale's number formatting
LC_NUMERIC: ${{ matrix.locale }}
LC_MONETARY: ${{ matrix.locale }}
LANG: ${{ matrix.locale }}
LC_ALL: ${{ matrix.locale }}
PYTHONIOENCODING: utf-8
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-quality: "ga"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set Linux locale to ${{ matrix.locale }}
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y locales
sudo locale-gen ${{ matrix.locale }}
sudo update-locale LANG=${{ matrix.locale }} LC_NUMERIC=${{ matrix.locale }} LC_MONETARY=${{ matrix.locale }}
locale -a
locale
- name: Set macOS locale to ${{ matrix.locale }}
if: runner.os == 'macOS'
run: |
sudo languagesetup -langspec $(echo ${{ matrix.locale }} | cut -d. -f1)
locale -a
locale
- name: Set Windows locale to ${{ matrix.locale }}
if: runner.os == 'Windows'
shell: pwsh
run: |
$locale = "${{ matrix.locale }}".Split('.')[0]
Set-WinSystemLocale $locale
Set-WinUserLanguageList $locale -Force
# Ensure proper number formatting
Set-Culture $locale
[System.Threading.Thread]::CurrentThread.CurrentCulture = [System.Globalization.CultureInfo]::GetCultureInfo($locale)
[System.Threading.Thread]::CurrentThread.CurrentUICulture = [System.Globalization.CultureInfo]::GetCultureInfo($locale)
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Test indicators
env:
LC_NUMERIC: ${{ matrix.locale }}
LC_MONETARY: ${{ matrix.locale }}
LANG: ${{ matrix.locale }}
LC_ALL: ${{ matrix.locale }}
PYTHONIOENCODING: utf-8
run: |
python -c "import locale; print(f'Locale: {locale.getlocale()}')"
python -c "import locale; print(f'Currency: {locale.currency(1234.56)}')"
python -c "import locale; print(f'Number: {locale.format_string(\"%.2f\", 1234.56)}')"
pytest -m "localization" -vr A tests --junitxml=test-results.xml
- name: Post test summary
uses: test-summary/action@v2
if: always()
with:
paths: test-results.xml