Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First workflow PoC #4

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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