-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pull request standard checks, linting, test coverage
- Loading branch information
1 parent
0489bf8
commit 07c3804
Showing
3 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,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, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: R-CMD-check | ||
|
||
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: macos-13-xlarge, r: 'release'} | ||
#- {os: windows-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@v4 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: ${{ matrix.config.r }} | ||
rtools-version: "43" | ||
windows-path-include-rtools: true | ||
update-rtools: true | ||
http-user-agent: ${{ matrix.config.http-user-agent }} | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::tictoc | ||
any::units | ||
any::rcmdcheck | ||
any::knitr | ||
any::rmarkdown | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true |
This file contains 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,32 @@ | ||
# 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, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: lint | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- 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} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
This file contains 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,111 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# also derived from https://github.com/we-cli/coverage-badge-action | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: test-coverage-local | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::covr | ||
needs: coverage | ||
|
||
- name: Cache C++ and R dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/R | ||
~/.local/share/R | ||
key: dependencies-${{ runner.os }}-${{ hashFiles('**/DESCRIPTION') }} | ||
restore-keys: | | ||
dependencies-${{ runner.os }}- | ||
- name: Test coverage | ||
run: > | ||
Rscript -e | ||
"covd<-covr::coverage_to_list()$totalcoverage; | ||
write.table(covd[length(covd)], file = '${{ github.workspace }}/local_cov.Rout', row.names = F, col.names = F)" | ||
shell: bash | ||
|
||
- name: Get Values | ||
id: get-values | ||
shell: bash | ||
run: | | ||
COV=$(cat ${{ github.workspace }}/local_cov.Rout) | ||
echo "Patch coverage read from local_cov.Rout: $COV" | ||
echo "coverage=$COV" >> $GITHUB_OUTPUT | ||
- name: Checkout gh-pages | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: gh-pages | ||
|
||
- name: Patch comparison | ||
id: patch-comparison | ||
shell: bash | ||
run: | | ||
cov_patch="${{ steps.get-values.outputs.coverage }}" | ||
if [[ ! -f cov_current.Rout ]]; then | ||
cov_current=0 | ||
else | ||
cov_current=$(cat cov_current.Rout) | ||
fi | ||
echo "Current coverage: $cov_current" | ||
if (( $(echo "$cov_patch >= $cov_current" | bc -l) )); then | ||
echo "Patch coverage ($cov_patch) is greater than or equal to current coverage ($cov_current)." | ||
echo "cov_update=$cov_patch" >> $GITHUB_OUTPUT | ||
else | ||
echo "Patch coverage ($cov_patch) is less than current coverage ($cov_current)." | ||
exit 1 | ||
fi | ||
- name: Overwrite cov_current.Rout | ||
if: ${{ github.event_name == 'push' }} | ||
shell: bash | ||
run: | | ||
cov_update="${{ steps.patch-comparison.outputs.cov_update }}" | ||
touch cov_current.Rout | ||
echo "$cov_update" > cov_current.Rout | ||
- name: Create Badges | ||
shell: bash | ||
run: | | ||
npm i -g badgen-cli | ||
export COV=${{ steps.get-values.outputs.coverage }} | ||
COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `orange`') | ||
mkdir -p badges | ||
badgen -j coverage -s $COV% -c $COLOR > badges/coverage.svg | ||
- name: Deploy Badges | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "Update badges [skip ci] & cov_current.Rout" | ||
branch: gh-pages | ||
skip_fetch: true | ||
skip_checkout: true | ||
|
||
# Without this, will get Error: | ||
# Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/coverage-badge-action/coverage-badge-action/action.yml'. | ||
# Did you forget to run actions/checkout before running your local action? | ||
- name: Checkout Back | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} |