Skip to content

Commit fde0e1f

Browse files
authored
modernize CI to github actions (#10)
* remove Python dependency * simplify: gettext never returns NULL for non-NULL msgid * update to use GettextRuntime_jll * modernize CI to github actions * requires Julia 1.6
1 parent 8cbdb11 commit fde0e1f

10 files changed

Lines changed: 186 additions & 30 deletions

File tree

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "weekly"

.github/workflows/CI.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
# Run on master, tags, or any pull request
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Daily at 2 AM UTC (8 PM CST)
6+
push:
7+
branches: [master]
8+
tags: ["*"]
9+
pull_request:
10+
concurrency:
11+
# Skip intermediate builds: always.
12+
# Cancel intermediate builds: only if it is a pull request build.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
15+
jobs:
16+
test:
17+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
version:
23+
- "1.6" # LTS
24+
- "1" # Latest Release
25+
os:
26+
- ubuntu-latest
27+
- macOS-latest
28+
- windows-latest
29+
arch:
30+
- x64
31+
- x86
32+
exclude:
33+
# Test 32-bit only on Linux
34+
- os: macOS-latest
35+
arch: x86
36+
- os: windows-latest
37+
arch: x86
38+
include:
39+
# Add specific version used to run the reference tests.
40+
# Must be kept in sync with version check in `test/runtests.jl`,
41+
# and with the branch protection rules on the repository which
42+
# require this specific job to pass on all PRs
43+
# (see Settings > Branches > Branch protection rules).
44+
- os: ubuntu-latest
45+
version: 1.10.6
46+
arch: x64
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: julia-actions/setup-julia@v2
50+
with:
51+
version: ${{ matrix.version }}
52+
arch: ${{ matrix.arch }}
53+
- uses: actions/cache@v4
54+
env:
55+
cache-name: cache-artifacts
56+
with:
57+
path: ~/.julia/artifacts
58+
key: ${{ runner.os }}-${{ matrix.arch }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
59+
restore-keys: |
60+
${{ runner.os }}-${{ matrix.arch }}-test-${{ env.cache-name }}-
61+
${{ runner.os }}-${{ matrix.arch }}-test-
62+
${{ runner.os }}-${{ matrix.arch }}-
63+
${{ runner.os }}-
64+
- uses: julia-actions/julia-buildpkg@latest
65+
- run: |
66+
git config --global user.name Tester
67+
git config --global user.email te@st.er
68+
- uses: julia-actions/julia-runtest@latest
69+
- uses: julia-actions/julia-processcoverage@v1
70+
- uses: codecov/codecov-action@v5
71+
with:
72+
files: lcov.info
73+
token: ${{ secrets.CODECOV_TOKEN }}
74+
fail_ci_if_error: false

.github/workflows/CompatHelper.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *' # Everyday at midnight
5+
workflow_dispatch:
6+
jobs:
7+
CompatHelper:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Pkg.add("CompatHelper")
13+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
14+
- name: CompatHelper.main()
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
18+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.github/workflows/JuliaNightly.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: JuliaNightly
2+
# Nightly Scheduled Julia Nightly Run
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Daily at 2 AM UTC (8 PM CST)
6+
jobs:
7+
test:
8+
name: Julia Nightly - Ubuntu - x64
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: julia-actions/setup-julia@v2
13+
with:
14+
version: nightly
15+
arch: x64
16+
- uses: actions/cache@v4
17+
env:
18+
cache-name: julia-nightly-cache-artifacts
19+
with:
20+
path: ~/.julia/artifacts
21+
key: ${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
22+
restore-keys: |
23+
${{ env.cache-name }}-
24+
- uses: julia-actions/julia-buildpkg@latest
25+
- run: |
26+
git config --global user.name Tester
27+
git config --global user.email te@st.er
28+
- uses: julia-actions/julia-runtest@latest
29+
- uses: julia-actions/julia-processcoverage@v1
30+
- uses: codecov/codecov-action@v5
31+
with:
32+
files: lcov.info

.github/workflows/TagBot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
jobs:
8+
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: JuliaRegistries/TagBot@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name = "Gettext"
22
uuid = "a6aca261-61b0-5b33-a99a-e9c977ffa089"
3+
version = "0.1.0"
34

45
[deps]
5-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
6+
GettextRuntime_jll = "b0724c58-0f36-5564-988d-3bb0596ebc4a"
67

78
[compat]
8-
julia = "≥ 0.7.0"
9+
GettextRuntime_jll = "0.22.4"
10+
julia = "1.6"
911

1012
[extras]
1113
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Gettext.jl
2-
[![Build Status](https://travis-ci.org/Julia-i18n/Gettext.jl.svg)](https://travis-ci.org/Julia-i18n/Gettext.jl)
3-
[![Coverage Status](https://coveralls.io/repos/Julia-i18n/Gettext.jl/badge.svg?branch=master)](https://coveralls.io/r/Julia-i18n/Gettext.jl?branch=master)
2+
[![CI](https://github.com/Julia-i18n/Gettext.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/Julia-i18n/Gettext.jl/actions/workflows/CI.yml?query=branch%3Amaster)
3+
[![Codecov](https://codecov.io/Julia-i18n/Gettext.jl/branch/master/graph/badge.svg?token=WsGRSymBmZ)](https://codecov.io/gh/Julia-i18n/Gettext.jl)
44

55
An interface to the [gettext](http://www.gnu.org/software/gettext/manual/html_node/index.html) internationalization/translation interface.
66

7+
(This package calls the GNU `gettext` library directly from Julia, via the `Gettext_jll` package compiled for Julia
8+
by [Yggdrasil](https://github.com/JuliaPackaging/Yggdrasil); this is automatically installed for you by Julia's
9+
[package manager](https://github.com/JuliaLang/Pkg.jl). `gettext` is free/open-source software licensed under the
10+
[GNU LGPL](https://www.gnu.org/software/gettext/manual/html_node/GNU-LGPL.html).)
11+
712
## Installation
813

914
Within Julia, run `Pkg.update()` and then `Pkg.add("Gettext")`
@@ -44,7 +49,3 @@ When run, this gives
4449
$ LANGUAGE=fr julia daystr.jl
4550
1 jour
4651
3 jours
47-
48-
## Status
49-
50-
Currently this library relies on Python's built-in [gettext.py](https://github.com/python/cpython/blob/master/Lib/gettext.py) implementation via [PyCall](https://github.com/stevengj/PyCall.jl). In the future, it may make sense to port this code into a Julia-native version (see [issue #1](https://github.com/Julia-i18n/Gettext.jl/issues/1)).

src/Gettext.jl

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
module Gettext
22

3-
using PyCall
4-
5-
const gt = PyNULL()
3+
using GettextRuntime_jll
4+
5+
textdomain() = unsafe_string(ccall((:textdomain,libintl), Cstring, (Ptr{UInt8},), C_NULL))
6+
function textdomain(domain::AbstractString)
7+
# textdomain(domain) returns the domain as a string, but
8+
# you are required to not free the result. Might as well ignore it.
9+
ccall((:textdomain,libintl), Cstring, (Cstring,), domain)
10+
return domain
11+
end
612

7-
function __init__()
8-
copy!(gt, pyimport("gettext"))
13+
bindtextdomain(domain::AbstractString) = unsafe_string(ccall((:bindtextdomain,libintl), Cstring, (Cstring, Ptr{UInt8},), domain, C_NULL))
14+
function bindtextdomain(domain::AbstractString, dir_name::AbstractString)
15+
# bintextdomain(domain, dir_name) returns the dir_name as a string, but
16+
# you are required to not free the result. Might as well ignore it.
17+
@static if Sys.iswindows()
18+
ccall((:wbindtextdomain,libintl), Cwstring, (Cstring,Cwstring), domain, dir_name)
19+
else
20+
ccall((:bindtextdomain,libintl), Cstring, (Cstring,Cstring), domain, dir_name)
21+
end
22+
return dir_name
923
end
1024

11-
bindtextdomain(domain, localedir=nothing) = gt[:bindtextdomain](domain, localedir)
12-
textdomain(domain=nothing) = gt[:textdomain](domain)
25+
gettext(msgid::AbstractString) = unsafe_string(ccall((:gettext,libintl), Cstring, (Cstring,), msgid))
26+
dgettext(domain::AbstractString, msgid::AbstractString) = unsafe_string(ccall((:dgettext,libintl), Cstring, (Cstring, Cstring,), domain, msgid))
1327

14-
gettext(message) = gt[:gettext](message)
15-
dgettext(domain, message) = gt[:dgettext](domain, message)
16-
ngettext(singular, plural, n) = gt[:ngettext](singular, plural, n)
17-
dngettext(domain, singular, plural, n) = gt[:dngettext](domain, singular, plural, n)
28+
ngettext(msgid::AbstractString, msgid_plural::AbstractString, n::Integer) = unsafe_string(ccall((:ngettext,libintl), Cstring, (Cstring,Cstring,Culong), msgid, msgid_plural, n))
29+
dngettext(domain::AbstractString, msgid::AbstractString, msgid_plural::AbstractString, n::Integer) = unsafe_string(ccall((:dngettext,libintl), Cstring, (Cstring,Cstring,Cstring,Culong), domain, msgid, msgid_plural, n))
1830

1931
macro __str(s)
2032
gettext(s)
@@ -24,6 +36,6 @@ macro N__str(s)
2436
s
2537
end
2638

27-
export bindtextdomain, textdomain, gettext, lgettext, dgettext, dlgettext, ngettext, lngettext, dngettext, ldngettext, @__str, @N__str
39+
export bindtextdomain, textdomain, gettext, dgettext, ngettext, dngettext, @__str, @N__str
2840

2941
end # module

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ using Formatting
99
import Pkg
1010

1111
# Set up gettext
12-
trdir = realpath(joinpath(dirname(pathof(Gettext)), "..", "po"))
12+
trdir = joinpath(@__DIR__, "..", "po")
1313
@test isfile(joinpath(trdir, "fr", "LC_MESSAGES", "sample.mo"))
1414
bindtextdomain("sample", trdir)
1515
textdomain("sample")
16+
@test bindtextdomain("sample") == trdir
17+
@test textdomain() == "sample"
1618

1719
# Test basic macros
1820
@test _"Hello, world!" == "Bonjour le monde !"
1921
@test N_"Hello, world!" == "Hello, world!"
2022

23+
@test _"Unknown key" == "Unknown key"
24+
2125
# Test ngettext
2226
daystr(n) = format(ngettext("{1} day", "{1} days", n), n)
2327
@test daystr(1) == "1 jour"

0 commit comments

Comments
 (0)