Skip to content

Commit

Permalink
ci: add lint workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing committed Apr 28, 2024
1 parent 2a999c0 commit cf054b8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# GitHub Actions workflow to lint the locale files.
name: "Lint"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
merge_group:

concurrency:
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
cancel-in-progress: "${{ github.event.action != 'merge_group' }}"

permissions:
contents: read

jobs:
lint:
name: "Lint"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
fetch-depth: 0
submodules: true

- name: "Setup Go stable"
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5
with:
go-version: "stable"
cache: true
check-latest: true

- name: "Download dependencies"
run: go mod download

- name: "Verify dependencies"
run: go mod verify

- name: "Build"
run: go build -v ./...

- name: "Test"
run: go test -race -v ./...

- name: "Lint"
run: |
go build -trimpath ./cmd/lang-lint
./lang-lint
17 changes: 17 additions & 0 deletions cmd/lang-lint/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"os"

"hypera.dev/axolotl-lang/v2"
)

func main() {
if err := lang.LoadLocales(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

fmt.Println("Locales loaded successfully", lang.Bundle().LanguageTags())
}
4 changes: 4 additions & 0 deletions lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func LoadLocales() error {
return nil
}

func Bundle() *i18n.Bundle {
return bundle
}

func GetLocalizer(locale discordgo.Locale) (*Localizer, bool) {
if l, ok := locales[locale]; ok {
return l, true
Expand Down

0 comments on commit cf054b8

Please sign in to comment.