-
Notifications
You must be signed in to change notification settings - Fork 36
More tests, workflows PR comment for feature test #405
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
Open
varunghat
wants to merge
19
commits into
phoible:master
Choose a base branch
from
varunghat:feat/more-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
14a0fe2
Added regression test for click-modifier, updated pixi.toml with task…
varunghat 66016df
Added regression test for special-cases and c-cedilla
varunghat 776e548
Excluded test-phonemes.R from ci, added output as pr comment
varunghat 21b0eb5
Fixed typo and test commands in workflows
varunghat d8d96b9
changed working directory of pr comment job
varunghat bb31120
Added comment about workflow change
varunghat 6add4c2
Added comment to test workflow
varunghat 9d695d8
Testing edit-last in gh pr comment
varunghat f455228
reverted edit-last in gh pr comment
varunghat 7a34af4
Added test to verify glottocode-isocode mapping matches glottolog
varunghat 1e6d451
Added test to check inventory-bibtex mapping, InventoryID duplicates
varunghat f8d0853
Moved feature test to beginning so we get pr comment even if other te…
varunghat 9e1a2e4
Moved workflow permissions to inside jobs
varunghat 42b863c
Split PR comment workflow to allow for PR from forked repos
varunghat 520b592
Removed write permissions from main.yml actions, removed stray whites…
varunghat 9af5531
Removed two unnecessary tests from click-modifier regression test
varunghat f1c78ca
Changed special-case regression test to only c-cedilla
varunghat 792ea5a
Renamed test file suffix from special-casess to c-cedilla
varunghat 9f8864d
Added check special_cases lookup returns exactly one row in add-featu…
varunghat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: comment feature test results | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["test data"] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| comment: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.event == 'pull_request' | ||
| steps: | ||
| - name: download feature test results | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: feature-test-results | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: comment on PR | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_REPO: ${{ github.repository }} | ||
| run: | | ||
| PR_NUMBER=$(cat pr_number.txt) | ||
| gh pr comment "$PR_NUMBER" --body-file phoneme_feature_test_results.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #! /usr/bin/env Rscript | ||
|
|
||
| ## Tests for cross-inventory integrity. Checks that: | ||
| ## 1. No source accidentally split one language (Glottocode, LanguageName, SpecificDialect, BibtexKey) across two InventoryIDs | ||
| ## 2. Every BibtexKey in the mapping file resolves to a real entry in | ||
| ## phoible-references.bib. | ||
| ## 3. Every InventoryID in the mapping files exists in the aggregated | ||
| ## data, and vice versa. | ||
|
|
||
| library(dplyr, warn.conflicts=FALSE) | ||
| library(testthat, warn.conflicts=FALSE) | ||
|
|
||
| ## load PHOIBLE data | ||
| phoible_data_file <- file.path("..", "data", "phoible.csv") | ||
| phoible_col_types <- readr::cols(InventoryID="c", Marginal="l", .default="c") | ||
| phoible <- readr::read_csv(phoible_data_file, col_types=phoible_col_types) | ||
|
|
||
| bibtex_mapping_file <- file.path("..", "mappings", "InventoryID-Bibtex.csv") | ||
| bibtex_mapping <- readr::read_csv(bibtex_mapping_file, col_types=readr::cols(.default="c")) | ||
|
|
||
| # Join the phoible data with the mapping file to get a combined dataset for testing | ||
| phoible_with_bibtex <- phoible %>% | ||
| left_join(bibtex_mapping, by="InventoryID", relationship="many-to-many") | ||
|
|
||
| references_bib_file <- file.path("..", "mappings", "phoible-references.bib") | ||
|
|
||
| context("Cross-inventory integrity") | ||
|
|
||
| test_that("no source accidentally split one language across two InventoryIDs", { | ||
| ## Checks whether the same (Source, Glottocode, LanguageName, SpecificDialect, BibtexKey) tuple | ||
| ## appears in more than one InventoryID. | ||
| phoible_with_bibtex %>% | ||
| filter(!is.na(Glottocode)) %>% | ||
| distinct(InventoryID, Source, Glottocode, LanguageName, SpecificDialect, BibtexKey) %>% | ||
| group_by(Source, Glottocode, LanguageName, SpecificDialect, BibtexKey) %>% | ||
| filter(n_distinct(InventoryID) > 1) %>% | ||
| ungroup() -> | ||
| split_duplicates | ||
|
|
||
| expect(nrow(split_duplicates) == 0, | ||
| paste(c("SAME (Source, Glottocode, LanguageName, SpecificDialect, BibtexKey) APPEARS IN MULTIPLE INVENTORYIDS:", | ||
| capture.output(print(split_duplicates, n=Inf))), | ||
| sep="\n") | ||
| ) | ||
| } | ||
| ) | ||
|
|
||
| test_that("every BibtexKey resolves to a real bib entry", { | ||
| ## Check that every BibtexKey in the mapping file resolves to a real entry in phoible-references.bib. | ||
|
|
||
| ## regex to match BibTeX keys in the .bib file | ||
| citekey_re <- "(?m)^@\\w+\\s*\\{\\s*([^,]+?)\\s*," | ||
|
|
||
| bib_keys <- stringr::str_match_all( | ||
| readr::read_file(references_bib_file), citekey_re | ||
| )[[1]][, 2] | ||
|
|
||
| mapping_keys <- bibtex_mapping %>% pull(BibtexKey) %>% unique() | ||
| missing_keys <- setdiff(mapping_keys, bib_keys) | ||
|
|
||
| # Exclude special case of InventoryID 201 (Arrente), which has "NO SOURCE GIVEN" as its BibtexKey | ||
| missing_keys <- setdiff(missing_keys, bibtex_mapping %>% filter(InventoryID == 201) %>% pull(BibtexKey)) | ||
|
|
||
| ## report which InventoryID(s) cite each missing key | ||
| offending_rows <- bibtex_mapping %>% | ||
| filter(BibtexKey %in% missing_keys) %>% | ||
| arrange(BibtexKey, as.integer(InventoryID)) | ||
| offending_summary <- offending_rows %>% | ||
| group_by(BibtexKey) %>% | ||
| summarise(InventoryIDs = paste(InventoryID, collapse=", "), .groups="drop") | ||
|
|
||
| expect(length(missing_keys) == 0, | ||
| paste(c(paste("BIBTEXKEYS WITH NO MATCHING ENTRY IN", | ||
| basename(references_bib_file)), | ||
| paste0(offending_summary$BibtexKey, " (InventoryID ", | ||
| offending_summary$InventoryIDs, ")")), | ||
| sep="\n") | ||
| ) | ||
| } | ||
| ) | ||
|
|
||
| test_that("mapping-file and aggregated-data InventoryIDs match in both directions", { | ||
| phoible_ids <- phoible %>% pull(InventoryID) %>% unique() | ||
| mapping_ids <- bibtex_mapping %>% pull(InventoryID) %>% as.integer() %>% unique() | ||
|
|
||
| only_in_mapping <- setdiff(mapping_ids, phoible_ids) | ||
| only_in_phoible <- setdiff(phoible_ids, mapping_ids) | ||
|
|
||
| expect(length(only_in_mapping) == 0, | ||
| paste(c("INVENTORYIDS IN InventoryID-Bibtex.csv BUT MISSING FROM", | ||
| "AGGREGATED DATA:", paste(only_in_mapping, collapse=" ")), | ||
| sep="\n") | ||
| ) | ||
| expect(length(only_in_phoible) == 0, | ||
| paste(c("INVENTORYIDS IN AGGREGATED DATA BUT MISSING FROM", | ||
| "InventoryID-Bibtex.csv:", paste(only_in_phoible, collapse=" ")), | ||
| sep="\n") | ||
| ) | ||
| } | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #! /usr/bin/env Rscript | ||
|
|
||
| ## Regression test for c-cedilla staying precomposed in order_ipa() | ||
| ## (aggregation-helper-functions.R), rather than decomposing it. | ||
|
|
||
| library(stringi, warn.conflicts=FALSE) | ||
| library(testthat, warn.conflicts=FALSE) | ||
|
|
||
| source(file.path("..", "scripts", "aggregation-helper-functions.R")) | ||
|
|
||
| context("Special-case exceptions regression") | ||
|
|
||
| test_that("c-cedilla is unchanged by order_ipa()", { | ||
| ordered <- order_ipa("ç") | ||
| expect(identical(ordered, "ç"), | ||
| paste("Expected c-cedilla phoneme to be unchanged by order_ipa(), got", | ||
| shQuote(ordered))) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #! /usr/bin/env Rscript | ||
|
|
||
| ## Regression test for the click/modifier typing in order_ipa() (aggregation-helper-functions.R). | ||
| ## Clicks are deliberately typed "M", the same glyph-type code as real modifier letters | ||
| ## so they factor into feature-vector assignment the same way | ||
| ## (see create_glyph_type_variables()/make_typestring()). | ||
|
|
||
| library(stringi, warn.conflicts=FALSE) | ||
| library(testthat, warn.conflicts=FALSE) | ||
|
|
||
| source(file.path("..", "scripts", "aggregation-helper-functions.R")) | ||
|
|
||
| context("Click/modifier regression") | ||
|
|
||
| test_that("a click is not deleted when followed by a modifier letter", { | ||
| ## dental click U+01C0 + aspirated U+02B0 both typed "M" | ||
| ## triggering the "MM" canonical-reordering block | ||
| result <- order_ipa("ǀʰ") | ||
| expect(stri_detect_fixed(result, "ǀ"), | ||
| paste("Click character was lost from", shQuote(result))) | ||
| expect(nchar(result) == 2, | ||
| paste("Expected a 2-character result, got", shQuote(result), | ||
| "(", nchar(result), "characters)")) | ||
| }) | ||
|
|
||
| test_that("a click is not deleted when preceding a modifier letter", { | ||
| ## same "MM" span, reversed input order | ||
| result <- order_ipa("ʰǀ") | ||
| expect(stri_detect_fixed(result, "ǀ"), | ||
| paste("Click character was lost from", shQuote(result))) | ||
| expect(nchar(result) == 2, | ||
| paste("Expected a 2-character result, got", shQuote(result), | ||
| "(", nchar(result), "characters)")) | ||
| }) | ||
|
|
||
| test_that("a click followed by a diacritic is not swapped the way a modifier would be", { | ||
| ## dental click + devoiced/ring-below diacritic (U+0325) - Typed "MD" | ||
| ## Should not be swapped to "DM" because the click is not a real modifier letter. | ||
| result <- order_ipa("ǀ̥") | ||
| expect(stri_detect_fixed(result, "ǀ"), | ||
| paste("Click character was lost from", shQuote(result))) | ||
| expect(identical(stri_sub(result, 1, 1), "ǀ"), | ||
| paste("Expected click to remain first, got", shQuote(result))) | ||
| }) | ||
|
|
||
| test_that("a click preceding a real modifier+diacritic doesn't block their swap", { | ||
| ## typestring "MMD" with a click first, then a modifier letter, then a diacritic. | ||
| ## The modifier+diacritic pair should still be swapped, but the click should remain first. | ||
| result <- order_ipa("ǀʰ̥") | ||
| expect(stri_detect_fixed(result, "ǀ"), | ||
| paste("Click character was lost from", shQuote(result))) | ||
| expect(identical(stri_sub(result, 1, 1), "ǀ"), | ||
| paste("Expected click to remain first, got", shQuote(result))) | ||
| expect(identical(result, "ǀ̥ʰ"), | ||
| paste("Expected the modifier+diacritic pair to still be swapped", | ||
| "(click skip should not suppress it), got", shQuote(result))) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.