Skip to content

Commit

Permalink
ref: replace extendio.i18n with li18ngo (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Oct 9, 2024
1 parent 6ae7817 commit 5399703
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 80 deletions.
54 changes: 40 additions & 14 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Pixa Continuous Integration

on:
push:

Expand All @@ -7,43 +8,68 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.22
go-version: 1.23
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v3
with:
version: v1.56.2
version: v1.60.3
args: --verbose

test:
strategy:
matrix:
go-version: [1.22]
go-version: [1.23]
platform: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.platform }}

env:
COVER_DIR: ${{ github.workspace }}/coverage
COVER_FILE: coverage.out
COVER_OUT_PATH: ${{ github.workspace }}/coverage/coverage.out
COVER_HTML_PATH: ${{ github.workspace }}/coverage/coverage.html
GINKGO_REPORT: ginkgo.report

steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

- name: Install ginkgo
run: go install github.com/onsi/ginkgo/v2/[email protected]

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- run: go test -v -coverprofile=coverage.out ./...
- name: Ensure coverage directory exists
run: |
mkdir -p ${{ github.workspace }}/coverage
- name: Run tests and generate coverage profile with Ginkgo
run: |
ginkgo run -r -json-report {{env.GINKGO_REPORT}} -coverpkg=./... -coverprofile=coverage.out
- uses: shogo82148/actions-goveralls@v1
- name: Apply coverage exclusions
run: |
${{ github.workspace }}/scripts/apply-coverage-exclusions.sh
- name: Check coverage directory contents
run: |
echo "Contents of ${{ github.workspace }}/coverage:"
ls -la ${{ github.workspace }}/coverage
- name: Generate HTML coverage report
run: |
go tool cover -html=coverage.out -o ${{ github.workspace }}/coverage/coverage.html
- name: Upload coverage to Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github
11 changes: 5 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ linters-settings:
- performance
- style
govet:
check-shadowing: true
shadow: true
disable:
- fieldalignment # too strict

nolintlint:
require-explanation: true
require-explanation: false
require-specific: true

linters:
disable-all: true
enable:
Expand All @@ -29,22 +28,22 @@ linters:
# it can be re-enabled.
# https://github.com/OpenPeeDeeP/depguard#example-configs
# - depguard
- copyloopvar
- dogsled
# - dupl
- errcheck
- exportloopref
- exhaustive
- goconst
- gocritic
- gofmt
- goimports
- gomnd
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- mnd
- nolintlint
- nakedret
- prealloc
Expand All @@ -70,4 +69,4 @@ issues:

run:
issues-exit-code: 1
timeout: 5m
timeout: "5m"
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"cmocks",
"cobrass",
"configurator",
"copyloopvar",
"cubiest",
"deadcode",
"deepcopy",
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/snivilised/pixa

go 1.22
go 1.23.0

require (
github.com/charmbracelet/bubbletea v1.1.1
Expand All @@ -11,6 +11,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/samber/lo v1.47.0
github.com/snivilised/extendio v0.7.0
github.com/snivilised/li18ngo v0.1.4
github.com/snivilised/lorax v0.5.2
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.18.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ github.com/snivilised/cobrass v0.4.5 h1:NeU/NwuOuJzotqa4JwnqGqbV1fs1SjB6GF53sXFO
github.com/snivilised/cobrass v0.4.5/go.mod h1:hGVu/zjWVG3tRKo3P0tjelm5S44vMTa/w29ygnvi+lY=
github.com/snivilised/extendio v0.7.0 h1:MY6w9qCK5wVEvP2WpMT5ywJwpDJe97WHDGuwrsTLpek=
github.com/snivilised/extendio v0.7.0/go.mod h1:l8MwJOy9ojMQYJrSKRbQS3WfDylevnRtBp/zwAmFEKc=
github.com/snivilised/li18ngo v0.1.4 h1:y6EECoVFpmkud2yDEeBnMnebPmSvdrEZ/LAq1PoPctE=
github.com/snivilised/li18ngo v0.1.4/go.mod h1:Or3qUhpR6AM1X51i82RtyCvORWy2/hrxY9lg1i1gFTE=
github.com/snivilised/lorax v0.5.2 h1:iReIJl63tydiPSSD0YzsNQFX1CctmvMkYx0aSxoZJKo=
github.com/snivilised/lorax v0.5.2/go.mod h1:7H1JPgSn4h4p8NSqfl64raacYefdm/FiFkfcZ51PVHY=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
Expand Down
14 changes: 7 additions & 7 deletions src/app/cfg/config-runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/snivilised/cobrass/src/assistant/configuration"
ci18n "github.com/snivilised/cobrass/src/assistant/i18n"
"github.com/snivilised/extendio/collections"
xi18n "github.com/snivilised/extendio/i18n"
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/li18ngo"
"github.com/snivilised/pixa/src/app/proxy/common"
"github.com/spf13/viper"
"golang.org/x/text/language"
Expand Down Expand Up @@ -216,18 +216,18 @@ func (c *configRunner) handleLangSetting(config configuration.ViperConfig) {
return parsedTag
},
func() language.Tag {
return xi18n.DefaultLanguage.Get()
return li18ngo.DefaultLanguage
},
)

err := xi18n.Use(func(uo *xi18n.UseOptions) {
err := li18ngo.Use(func(uo *li18ngo.UseOptions) {
uo.Tag = tag
uo.From = xi18n.LoadFrom{
Sources: xi18n.TranslationFiles{
c.sourceID: xi18n.TranslationSource{
uo.From = li18ngo.LoadFrom{
Sources: li18ngo.TranslationFiles{
c.sourceID: li18ngo.TranslationSource{
Name: c.applicationName,
},
ci18n.CobrassSourceID: xi18n.TranslationSource{
ci18n.CobrassSourceID: li18ngo.TranslationSource{
Name: "cobrass",
},
},
Expand Down
7 changes: 6 additions & 1 deletion src/app/cfg/config-runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/snivilised/cobrass/src/assistant/mocks"
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/li18ngo"
"github.com/snivilised/pixa/src/app/cfg"
"github.com/snivilised/pixa/src/app/proxy/common"
"github.com/snivilised/pixa/src/internal/helpers"
Expand Down Expand Up @@ -58,7 +59,7 @@ type runnerTE struct {
assert func(entry *runnerTE, runner common.ConfigRunner, err error)
}

var _ = Describe("ConfigRunner", func() {
var _ = Describe("ConfigRunner", Ordered, func() {
var (
repo string
configPath string
Expand All @@ -67,6 +68,10 @@ var _ = Describe("ConfigRunner", func() {
mock *mocks.MockViperConfig
)

BeforeAll(func() {
Expect(li18ngo.Use()).To(Succeed())
})

BeforeEach(func() {
viper.Reset()
vfs = storage.UseMemFS()
Expand Down
22 changes: 11 additions & 11 deletions src/app/command/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"github.com/snivilised/cobrass/src/assistant"
"github.com/snivilised/cobrass/src/assistant/configuration"
ci18n "github.com/snivilised/cobrass/src/assistant/i18n"
xi18n "github.com/snivilised/extendio/i18n"
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/extendio/xfs/utils"
"github.com/snivilised/li18ngo"
"github.com/snivilised/pixa/src/app/cfg"
"github.com/snivilised/pixa/src/app/plog"
"github.com/snivilised/pixa/src/app/proxy"
Expand Down Expand Up @@ -51,7 +51,7 @@ func validatePositionalArgs(cmd *cobra.Command, args []string) error {
directory := utils.ResolvePath(args[0])

if !utils.Exists(directory) {
return xi18n.NewPathNotFoundError("shrink directory", directory)
return li18ngo.NewPathNotFoundError("shrink directory", directory)
}

return nil
Expand Down Expand Up @@ -125,8 +125,8 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command {
b.Container = assistant.NewCobraContainer(
&cobra.Command{
Use: "main",
Short: xi18n.Text(locale.RootCmdShortDescTemplData{}),
Long: xi18n.Text(locale.RootCmdLongDescTemplData{}),
Short: li18ngo.Text(locale.RootCmdShortDescTemplData{}),
Long: li18ngo.Text(locale.RootCmdLongDescTemplData{}),
Version: fmt.Sprintf("'%v'", Version),
RunE: func(_ *cobra.Command, args []string) error {
inputs := b.getRootInputs()
Expand Down Expand Up @@ -178,7 +178,7 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command {

func (b *Bootstrap) configure() {
if err := b.OptionsInfo.Runner.Run(); err != nil {
msg := xi18n.Text(locale.UsingConfigFileTemplData{
msg := li18ngo.Text(locale.UsingConfigFileTemplData{
ConfigFileName: b.OptionsInfo.Config.Viper.ConfigFileUsed(),
})

Expand All @@ -202,18 +202,18 @@ func handleLangSetting(config configuration.ViperConfig) {
return parsedTag
},
func() language.Tag {
return xi18n.DefaultLanguage.Get()
return li18ngo.DefaultLanguage
},
)

err := xi18n.Use(func(uo *xi18n.UseOptions) {
err := li18ngo.Use(func(uo *li18ngo.UseOptions) {
uo.Tag = tag
uo.From = xi18n.LoadFrom{
Sources: xi18n.TranslationFiles{
common.Definitions.Pixa.SourceID: xi18n.TranslationSource{
uo.From = li18ngo.LoadFrom{
Sources: li18ngo.TranslationFiles{
common.Definitions.Pixa.SourceID: li18ngo.TranslationSource{
Name: common.Definitions.Pixa.AppName,
},
ci18n.CobrassSourceID: xi18n.TranslationSource{
ci18n.CobrassSourceID: li18ngo.TranslationSource{
Name: "cobrass",
},
},
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/app/command/magick-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
. "github.com/onsi/gomega" //nolint:revive // foo

"github.com/snivilised/cobrass/src/assistant/configuration"
xi18n "github.com/snivilised/extendio/i18n"
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/li18ngo"
"github.com/snivilised/pixa/src/app/command"
"github.com/snivilised/pixa/src/app/proxy/common"
"github.com/snivilised/pixa/src/internal/helpers"
Expand All @@ -28,7 +28,7 @@ var _ = Describe("MagickCmd", Ordered, func() {
})

BeforeEach(func() {
xi18n.ResetTx()
Expect(li18ngo.Use()).To(Succeed())
vfs, _ = helpers.SetupTest(
"nasa-scientist-index.xml", configPath, l10nPath, helpers.Silent,
)
Expand Down
2 changes: 2 additions & 0 deletions src/app/command/root-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "github.com/onsi/gomega" //nolint:revive // foo

"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/li18ngo"
"github.com/snivilised/pixa/src/app/command"
"github.com/snivilised/pixa/src/app/proxy/common"
"github.com/snivilised/pixa/src/internal/helpers"
Expand All @@ -28,6 +29,7 @@ var _ = Describe("RootCmd", Ordered, func() {
)

BeforeAll(func() {
Expect(li18ngo.Use()).To(Succeed())
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
configPath = helpers.Path(repo, "test/data/configuration")
Expand Down
Loading

0 comments on commit 5399703

Please sign in to comment.