Skip to content

Commit

Permalink
Merge pull request #4 from castmart/gha-ci-workflow
Browse files Browse the repository at this point in the history
First workflow PoC
  • Loading branch information
castmart authored Dec 18, 2023
2 parents d0dd011 + a874e1f commit 9d354fe
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Run-Library-Tests:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Execute tests
run: |
make test
- run: echo "🍏 This job's status is ${{ job.status }}."
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ publish-to-ossrh:
GPG_SIGNING_KEY=${GPG_SIGNING_KEY} \
JCOUNTRY_VERSION=${version} \
./gradlew publish

.PHONY: test
test:
./gradlew test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![CI](https://github.com/castmart/jcountry/actions/workflows/ci.yaml/badge.svg)](https://github.com/castmart/jcountry/actions/workflows/ci.yaml)

# JCountry

This project tries to replicate the same functionality as [pycountry](https://github.com/flyingcircusio/pycountry) by wrapping iso files and provide a programatic interface.
Expand Down
13 changes: 11 additions & 2 deletions lib/src/test/java/io/github/castmart/jcountry/JCountryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ void testJCountryReadTranslations() {
@Test
void testJCountryReadsTranslations() {
// More than 50% of work population is covered with these languages.
ArrayList<String> languages = new ArrayList<>(Arrays.asList("zh_CN", "zh_HK", "zh_TW", "es", "de", "bn", "bn_IN", "pt", "pt_BR", "ru", "ja", "hi", "ar", "pa", "fr", "tr", "ko"));
ArrayList<String> languages = new ArrayList<>(Arrays.asList("es", "de", "bn", "pt", "ru", "ja", "hi", "ar", "pa", "fr", "tr", "ko"));
CountryDB countryDB = new CountryDBImpl(true);

languages.forEach( it -> {
Optional<ResourceBundle> bundle = countryDB.getCountriesTranslations(new Locale(it));
if (bundle.isEmpty())
System.out.println("Empty bundle for "+it);
else
System.out.println("Processing "+it);
assertTrue(!bundle.isEmpty());
});
}
Expand Down Expand Up @@ -109,18 +113,23 @@ void testJCountryLanguagesDBReadTranslations() {
@Test
void testJCountryLanguagesReadsTranslations() {
// More than 50% of work population is covered with these languages.
ArrayList<String> languages = new ArrayList<>(Arrays.asList("zh_CN", "zh_HK", "zh_TW", "es", "de", "bn", "pt", "pt_BR", "ru", "ja", "hi", "ar", "pa", "fr", "tr", "ko"));
ArrayList<String> languages = new ArrayList<>(Arrays.asList("es", "de", "bn", "pt", "ru", "ja", "hi", "ar", "pa", "fr", "tr", "ko"));
LanguageDB languageDB = new LanguageDBImpl(true);

languages.forEach( it -> {
Optional<ResourceBundle> bundle = languageDB.getLanguagesTranslations(new Locale(it));
if (bundle.isEmpty())
System.out.println("Empty bundle for "+it);
else
System.out.println("Processing "+it);
assertTrue(!bundle.isEmpty(), it + " translation");
});
}

@Test
void getTranslatedLanguageName() {
LanguageDB languageDB = new LanguageDBImpl(true);
JCountry.getInstance().getLanguageDB();
var dbByAlpha2 = languageDB.getLanguagesMapByAlpha2();

Optional<ResourceBundle> bundle = languageDB.getLanguagesTranslations(Locale.GERMAN);
Expand Down

0 comments on commit 9d354fe

Please sign in to comment.