Skip to content

Commit

Permalink
update CI and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed May 8, 2024
1 parent db59c15 commit 57aa0a9
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 66 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-18.04, r: 'oldrel-3'}
- {os: ubuntu-18.04, r: 'oldrel-4'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -59,3 +60,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
6 changes: 4 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -39,7 +41,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -27,5 +27,24 @@ jobs:
needs: coverage

- name: Test coverage
run: covr::codecov(quiet = FALSE)
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ a given colour space.
``` r
spectrum_lab <- convert_colour(spectrum, 'rgb', 'lab')
spectrum_lab
#> l a b
#> [1,] 53.24079 80.09246 67.203197
#> [2,] 72.26072 30.16539 77.224482
#> [3,] 93.60533 -41.94504 90.274226
#> [4,] 88.07403 -83.10813 83.593379
#> [5,] 88.19634 -80.27943 57.926987
#> [6,] 91.11322 -48.08753 -14.131186
#> [7,] 47.90478 35.19678 -82.006104
#> [8,] 33.81896 79.70044 -105.279006
#> [9,] 51.90416 90.99470 -74.834222
#> [10,] 55.65103 86.52861 -9.719051
#> l a b
#> [1,] 53.24079 80.09796 67.20432
#> [2,] 72.26072 30.17136 77.22610
#> [3,] 93.60533 -41.93879 90.27635
#> [4,] 88.07403 -83.10282 83.59544
#> [5,] 88.19634 -80.27407 57.92961
#> [6,] 91.11322 -48.08151 -14.12690
#> [7,] 47.90478 35.20130 -82.00196
#> [8,] 33.81896 79.70472 -105.27489
#> [9,] 51.90416 91.00028 -74.83009
#> [10,] 55.65103 86.53436 -9.71618

decode_colour(codes, to = 'lab')
#> l a b
#> [1,] 53.24079 80.09246 67.203197
#> [2,] 72.26072 30.16539 77.224482
#> [3,] 93.60533 -41.94504 90.274226
#> [4,] 88.07403 -83.10813 83.593379
#> [5,] 88.19634 -80.27943 57.926987
#> [6,] 91.11322 -48.08753 -14.131186
#> [7,] 47.90478 35.19678 -82.006104
#> [8,] 33.81896 79.70044 -105.279006
#> [9,] 51.90416 90.99470 -74.834222
#> [10,] 55.65103 86.52861 -9.719051
#> l a b
#> [1,] 53.24079 80.09796 67.20432
#> [2,] 72.26072 30.17136 77.22610
#> [3,] 93.60533 -41.93879 90.27635
#> [4,] 88.07403 -83.10282 83.59544
#> [5,] 88.19634 -80.27407 57.92961
#> [6,] 91.11322 -48.08151 -14.12690
#> [7,] 47.90478 35.20130 -82.00196
#> [8,] 33.81896 79.70472 -105.27489
#> [9,] 51.90416 91.00028 -74.83009
#> [10,] 55.65103 86.53436 -9.71618

encode_colour(spectrum_lab, from = 'lab')
#> [1] "#FF0000" "#FF9900" "#CCFF00" "#33FF00" "#00FF66" "#00FFFF" "#0066FF"
Expand Down Expand Up @@ -147,31 +147,31 @@ compare_colour(spectrum, spectrum2, 'rgb', method = 'cie2000')[1:6, 1:6]

`farver` currently supports the following colour spaces:

- CMY
- CMYK
- HSL
- HSB
- HSV
- CIE L\*AB
- Hunter LAB
- OK LAB
- LCH(ab)
- LCH(uv)
- LCH(OK)
- LUV
- RGB
- XYZ
- YXY
- CMY
- CMYK
- HSL
- HSB
- HSV
- CIE L\*AB
- Hunter LAB
- OK LAB
- LCH(ab)
- LCH(uv)
- LCH(OK)
- LUV
- RGB
- XYZ
- YXY

## Supported distance measures

`farver` supports the following colour distance metrics

- Euclidean
- CIE1976
- CIE94
- CIE2000
- CMC
- Euclidean
- CIE1976
- CIE94
- CIE2000
- CMC

## White References

Expand Down
Binary file modified man/figures/README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions tests/testthat/test-comparison.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("comparison")

spectrum <- unname(t(col2rgb(rainbow(10))))
spectrum2 <- unname(t(col2rgb(heat.colors(5))))
reconvert <- function(data, space) {
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-conversion.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("conversion")

spectrum <- unname(t(col2rgb(rainbow(10))))
reconvert <- function(data, space) {
unname(round(convert_colour(convert_colour(data, 'rgb', space), space, 'rgb')))
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-non-finite.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ bad_colours <- cbind(
)

test_that("non-finite values are treated correctly", {
expect_error(decode_colour(bad_codes), 'Malformed colour string `#345`')
expect_error(decode_colour(bad_codes[-1]), 'Unknown colour name: test')
expect_true(all(is.na(decode_colour(bad_codes[-c(1, 4)]))[3, ]))
expect_false(any(is.na(decode_colour(bad_codes[-c(1, 4)]))[1:2, ]))

expect_true(all(is.na(encode_colour(bad_colours))[2:5]))
expect_false(any(is.na(encode_colour(bad_colours))[c(1,6)]))

expect_true(all(is.na(convert_colour(bad_colours, 'rgb', 'lab')[2:5, ])))
expect_false(any(is.na(convert_colour(bad_colours, 'rgb', 'lab')[c(1,6), ])))

col_compare <- compare_colour(bad_colours, from_space = 'rgb')
col_compare <- col_compare[upper.tri(col_compare)]

expect_true(all(is.na(col_compare[-11])))
expect_false(any(is.na(col_compare[11])))
})

0 comments on commit 57aa0a9

Please sign in to comment.