diff --git a/.github/workflows/cockroach.yml b/.github/workflows/cockroach.yml index a6087cac3..6466785b3 100644 --- a/.github/workflows/cockroach.yml +++ b/.github/workflows/cockroach.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Start CockroachDB run: docker run -d -p 26257:26257 cockroachdb/cockroach:latest-v${{ matrix.version }} start-single-node --insecure - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b433912a1..500bc8eb4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -49,7 +49,7 @@ jobs: run: rm -rf /opt/hostedtoolcache - name: Start CockroachDB run: docker run -d -p 26257:26257 cockroachdb/cockroach:latest start-single-node --insecure - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/.github/workflows/exasol.yml b/.github/workflows/exasol.yml index d10db9d22..1f33fd39a 100644 --- a/.github/workflows/exasol.yml +++ b/.github/workflows/exasol.yml @@ -20,7 +20,7 @@ jobs: ports: [ 8563 ] options: --privileged steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/exasol.sh - name: Setup Perl diff --git a/.github/workflows/firebird.yml b/.github/workflows/firebird.yml index 36a5541a4..de7c120ed 100644 --- a/.github/workflows/firebird.yml +++ b/.github/workflows/firebird.yml @@ -29,7 +29,7 @@ jobs: ISC_PASSWORD: nix FIREBIRD_DATABASE: sqitchtest.db steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/firebird.sh - name: Setup Perl diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 14cb78ac6..03a7beecf 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -39,7 +39,7 @@ jobs: ports: [ 3306 ] options: --health-cmd="healthcheck.sh --innodb_initialized || mysqladmin ping --protocol=tcp" --health-interval=5s --health-timeout=2s --health-retries=3 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/mysql.sh - name: Setup Perl diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index 186501eb3..ea8487ace 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -40,7 +40,7 @@ jobs: --health-timeout 10s --health-retries 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/oracle.sh - name: Setup Perl diff --git a/.github/workflows/os.yml b/.github/workflows/os.yml index 6293bb68e..14c70842b 100644 --- a/.github/workflows/os.yml +++ b/.github/workflows/os.yml @@ -14,27 +14,39 @@ jobs: include: - { icon: 🐧, os: ubuntu, name: Linux } - { icon: 🍎, os: macos, name: macOS } - - { icon: πŸͺŸ, os: windows, name: Windows } + # - { icon: πŸͺŸ, os: windows, name: Windows } name: ${{ matrix.icon }} ${{ matrix.name }} runs-on: ${{ matrix.os }}-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 with: { perl-version: latest } - run: perl -V + - if: runner.os == 'Linux' + name: Install Apt Packages + run: sudo apt-get install -qq gettext language-pack-fr language-pack-en aspell-en + - if: runner.os == 'macOS' + name: Install Brew Packages + run: brew install gettext aspell + - if: runner.os == 'Windows' + name: Install Chocolatey Packages + run: choco install poedit - name: Cache CPAN Modules uses: actions/cache@v3 with: path: local key: perl-${{ steps.perl.outputs.perl-hash }} - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends ExtUtils::MakeMaker List::MoreUtils::XS - # Remove Locale::TextDomain if https://github.com/gflohr/libintl-perl/issues/7 fixed and released. - - if: ${{ matrix.os == 'windows' }} - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 Locale::TextDomain@1.31 + - if: runner.os == 'Windows' + run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile - - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage + - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage Dist::Zilla::LocaleTextDomain + - name: Compile Languages + run: | + dzil authordeps | xargs cpm install --verbose --show-build-log-on-failure --no-test + dzil msg-compile - name: prove env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" } run: prove -lrj4 diff --git a/.github/workflows/perl.yml b/.github/workflows/perl.yml index 22ddac38e..b94da4890 100644 --- a/.github/workflows/perl.yml +++ b/.github/workflows/perl.yml @@ -11,7 +11,7 @@ jobs: Perl: strategy: matrix: - os: [[🐧, ubuntu], [🍎, macos], [πŸͺŸ, windows]] + os: [[🐧, ubuntu], [🍎, macos]] #, [πŸͺŸ, windows]] perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12' ] exclude: - { os: [πŸͺŸ, windows], perl: '5.12' } # https://github.com/shogo82148/actions-setup-perl/issues/876 @@ -19,22 +19,34 @@ jobs: name: πŸ§… Perl ${{ matrix.perl }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }} runs-on: ${{ matrix.os[1] }}-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 with: { perl-version: "${{ matrix.perl }}" } - run: perl -V + - if: runner.os == 'Linux' + name: Install Apt Packages + run: sudo apt-get install -qq gettext language-pack-fr language-pack-en aspell-en + - if: runner.os == 'macOS' + name: Install Brew Packages + run: brew install gettext aspell + - if: runner.os == 'Windows' + name: Install Chocolatey Packages + run: choco install poedit - name: Cache CPAN Modules uses: actions/cache@v3 with: path: local key: perl-${{ steps.perl.outputs.perl-hash }} - # Remove Locale::TextDomain if https://github.com/gflohr/libintl-perl/issues/7 fixed and released. - - if: ${{ matrix.os[1] == 'windows' }} - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 Locale::TextDomain@1.31 + - if: runner.os == 'Windows' + run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile - - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage + - run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage Dist::Zilla::LocaleTextDomain + - name: Compile Languages + run: | + dzil authordeps | xargs cpm install --verbose --show-build-log-on-failure --no-test + dzil msg-compile - name: prove env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" } run: prove -lrj4 diff --git a/.github/workflows/pg.yml b/.github/workflows/pg.yml index c97c11ba7..39a81739f 100644 --- a/.github/workflows/pg.yml +++ b/.github/workflows/pg.yml @@ -15,7 +15,7 @@ jobs: name: 🐘 Postgres ${{ matrix.pg }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f5a1c1a0..f27f3336c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/.github/workflows/snowflake.yml b/.github/workflows/snowflake.yml index 7dc089c56..45ddd26cc 100644 --- a/.github/workflows/snowflake.yml +++ b/.github/workflows/snowflake.yml @@ -11,7 +11,7 @@ jobs: name: ❄️ Snowflake runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/snowflake.sh - name: Setup Perl diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index 4c0b758d1..12e1f4c16 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -16,7 +16,7 @@ jobs: name: πŸ’‘ SQLite ${{ matrix.sqlite }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/.github/workflows/vertica.yml b/.github/workflows/vertica.yml index b524bbd3c..5b734dfbd 100644 --- a/.github/workflows/vertica.yml +++ b/.github/workflows/vertica.yml @@ -27,7 +27,7 @@ jobs: image: ${{ matrix.image }}:${{ matrix.version }} ports: [ 5433 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Clients run: .github/ubuntu/vertica.sh - name: Setup Perl diff --git a/.github/workflows/yugabyte.yml b/.github/workflows/yugabyte.yml index 9524be9c2..34c886e38 100644 --- a/.github/workflows/yugabyte.yml +++ b/.github/workflows/yugabyte.yml @@ -34,7 +34,7 @@ jobs: uses: jameshartig/yugabyte-db-action@master with: yb_image_tag: "${{ matrix.tag }}" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Perl id: perl uses: shogo82148/actions-setup-perl@v1 diff --git a/Changes b/Changes index a3fa86e31..a0a5e75c6 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,9 @@ Revision history for Perl extension App::Sqitch (#795)! - Fixed Oracle and Firebird test failures due to incorrect use of `chmod`. Thanks to Slaven ReziΔ‡ for the report and the fix (#807)! + - Updated the locale configuration to fix issues in more recent versions + of Perl, and added tests to ensure that the sqitch CLI executes and + properly emits localized messages. 1.4.0 2023-08-01T23:37:30Z - Fixed Snowflake warehouse and role setup to properly quote identifiers diff --git a/bin/sqitch b/bin/sqitch index e14a01115..89c77f22d 100755 --- a/bin/sqitch +++ b/bin/sqitch @@ -1,15 +1,6 @@ #!perl -w -CAS # VERSION -use POSIX qw(setlocale); -BEGIN { - if ($^O eq 'MSWin32') { - require Win32::Locale; - setlocale POSIX::LC_ALL, Win32::Locale::get_locale(); - } else { - setlocale POSIX::LC_ALL, ''; - } -} +use locale; use App::Sqitch; - exit App::Sqitch->go; diff --git a/dist.ini b/dist.ini index 262efdd65..890ef97c2 100644 --- a/dist.ini +++ b/dist.ini @@ -2,7 +2,7 @@ name = App-Sqitch license = MIT copyright_holder = "iovation Inc., David E. Wheeler" copyright_year = 2012-2023 -version = v1.4.1-dev +version = v1.4.1 [GatherDir] exclude_filename = dist/cpanfile diff --git a/t/sqitch b/t/sqitch index 350e7fc0a..cf9171dca 100755 --- a/t/sqitch +++ b/t/sqitch @@ -1,14 +1,6 @@ #!/usr/bin/env perl -CAS -use POSIX qw(setlocale); -BEGIN { - if ($^O eq 'MSWin32') { - require Win32::Locale; - setlocale POSIX::LC_ALL, Win32::Locale::get_locale(); - } else { - setlocale POSIX::LC_ALL, ''; - } -} +use locale; use FindBin; use lib "$FindBin::Bin/../lib"; use App::Sqitch; diff --git a/xt/release/cli-locale.t b/xt/release/cli-locale.t new file mode 100644 index 000000000..22f06a809 --- /dev/null +++ b/xt/release/cli-locale.t @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use Test::More tests => 3; +use File::Spec; +use Capture::Tiny qw(:all); + +# Run `dzil msg-compile` first! +# LANG=de_DE.UTF-8 perl -Ilib -CAS -I. bin/sqitch help +my @cli = (qw(-Ilib -CAS -I.), File::Spec->catfile(qw(bin sqitch))); + +# Each locale must be installed on the local system. Adding a new lang? Also add +# the relevant language-pack-XX package to os.yml and perl.yml. +for my $tc ( + { lang => '', err => q{"nonesuch" is not a valid command} }, + { lang => 'en_US', err => q{"nonesuch" is not a valid command} }, + { lang => 'fr_FR', err => q{"nonesuch" n'est pas une commande valide} }, +) { + subtest $tc->{lang} || 'default' => sub { + local $ENV{LC_ALL} = "$tc->{lang}.UTF-8" if $tc->{lang}; + + # Test successful run. + my ($stdout, $stderr, $exit) = capture { system $^X, @cli, 'help' }; + is $exit >> 8, 0, 'Should have exited normally'; + like $stdout, qr/\AUsage\b/, 'Should have usage statement in STDOUT'; + is $stderr, '', 'Should have no STDERR'; + + # Test localized error. + ($stdout, $stderr, $exit) = capture { system $^X, @cli, 'nonesuch' }; + is $exit >> 8, 2, 'Should have exit val 2'; + is $stdout, '', 'Should have no STDOUT'; + like $stderr, qr/\A\Q$tc->{err}/, + 'Should have localized error message in STDERR'; + }; +}