Skip to content

Commit

Permalink
Code cleanup and better string handling (#20)
Browse files Browse the repository at this point in the history
Primarily a housekeeping release. Took care of some minor linting and
some redundant code. Made some changes to how string were being handled
for various input. The allocation should be more efficient and safer as
a result. Could see some minor impact on speed as a couple loops were
added to calculate string length. Overall should improve ability to
maintain and debug the code.

Added GitHub actions for CI. This will close #19.

Needed to add a conditional compile for strlcat since some systems
(such as OSX) have it natively.
  • Loading branch information
nawendt authored Sep 16, 2022
1 parent c1ea732 commit 226f2ae
Show file tree
Hide file tree
Showing 41 changed files with 2,053 additions and 1,805 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
^README\.md$
^\.DS_Store$
^\.Rhistory$
^\.git$
^\.github$
^\.git_commit_template$
^\.gitignore$
^\.travis\.yml$
^\.vscode$
^m4$
^install_.*\.sh$
^appveyor\.yml$
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/check-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]

name: Build (Latest ecCodes)

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}

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

steps:
- uses: actions/checkout@v2

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libproj-dev libaec-dev libopenjp2-7-dev libpng-dev
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install proj libaec openjpeg zlib
- name: Build eccodes from source
run: ./install_eccodes.sh
shell: bash

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
71 changes: 71 additions & 0 deletions .github/workflows/check-minimum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]

name: Build (Minimum ecCodes)

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}

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

steps:
- uses: actions/checkout@v2

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libproj-dev libaec-dev libopenjp2-7-dev libpng-dev
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install proj libaec openjpeg zlib
- name: Build eccodes from source (Linux)
if: runner.os == 'Linux'
run: ./install_eccodes.sh
shell: bash

- name: Build eccodes from source (macOS)
if: runner.os == 'macOS'
env:
OPENJPEG_INCLUDE_DIR: /usr/local/include/openjpeg-2.5
run: ./install_eccodes.sh
shell: bash

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
58 changes: 58 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]

name: Build (System ecCodes)

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

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

steps:
- uses: actions/checkout@v2

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libproj-dev libeccodes-dev
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: brew install proj eccodes

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
35 changes: 35 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]

name: Lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install gribr dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libproj-dev libeccodes-dev
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
36 changes: 36 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]

name: Codecov

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install gribr dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libproj-dev libeccodes-dev
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
autom4te.cache
*.log
*.status
.vscode
src/*.o
src/*.so
src/*.dll
Expand Down
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
Package: gribr
Type: Package
Title: Read GRIB Files
Version: 1.2.3
Date: 2021-01-14
Version: 1.2.4
Date: 2022-09-16
Author: Nathan Wendt <[email protected]>
Maintainer: Nathan Wendt <[email protected]>
BugReports: https://github.com/nawendt/gribr/issues
Description: R interface for GRIB files using ECMWF ecCodes. Easily read GRIB data into native R data types.
License: BSD_2_clause + file LICENSE
LazyData: TRUE
RoxygenNote: 7.1.1
License: BSD_3_clause + file LICENSE
RoxygenNote: 7.2.1
Encoding: UTF-8
NeedsCompilation: yes
SystemRequirements: ECMWF ecCodes (>= 2.19.0)
Expand Down
18 changes: 12 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
Copyright (c) 2016, Nathan Wendt
BSD 3-Clause License

Copyright (c) 2022, Nathan Wendt
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(print,grib)
export(grib_api_version)
export(grib_close)
export(grib_cube)
export(grib_expand_grids)
Expand Down
Loading

0 comments on commit 226f2ae

Please sign in to comment.