Create NPM package #22
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
name: CI | |
on: [push, pull_request] | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
env: | |
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" | |
_R_CHECK_CRAN_INCOMING_REMOTE_: false | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '6.0.x' | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4' | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install python dependecies | |
run: pip install cffi numba pytest | |
- name: Install JS dependecies | |
run: cd $GITHUB_WORKSPACE/tests/js && npm install | |
# setup R environment | |
- name: Query R package dependencies | |
run: | | |
install.packages('remotes') | |
if (!dir.exists(".github")) dir.create(".github") | |
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | |
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") | |
working-directory: ./src/r | |
shell: Rscript {0} | |
- name: Cache R packages | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('src/r/.github/R-version') }}-1-${{ hashFiles('src/r/.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-${{ hashFiles('src/r/.github/R-version') }}-1- | |
- name: Install system dependencies for R packages | |
if: runner.os == 'Linux' | |
run: | | |
while read -r cmd | |
do | |
eval sudo $cmd | |
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') | |
working-directory: ./src/r | |
- name: Install R package dependencies | |
run: | | |
remotes::install_deps(dependencies = TRUE) | |
remotes::install_cran("devtools") | |
shell: Rscript {0} | |
working-directory: ./src/r | |
- name: Generate R package documentation | |
run: | | |
echo "# Generated by roxygen2: do not edit by hand" > NAMESPACE | |
Rscript tools/deploy.R -p && Rscript -e 'devtools::document()' | |
working-directory: ./src/r | |
- name: Run tests (Python) | |
run: cd $GITHUB_WORKSPACE && python -m pytest -v -s | |
- name: Run tests (JavaScript) | |
run: cd $GITHUB_WORKSPACE/tests/js && npm test | |
- name: Run tests (C#) | |
run: cd $GITHUB_WORKSPACE/src/c_sharp && sudo dotnet test | |
- name: Run tests (R) | |
run: cd $GITHUB_WORKSPACE/src/r && R CMD build . && R CMD check --no-manual --as-cran psychrolib*tar.gz | |
- name: Publish NPM package | |
run: | | |
cd src/js | |
npm publish --provenance --access public || echo 'This version is already published. Skipping this step!' | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
gh-pages: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install python dependecies | |
run: pip install sphinx==2.4.* sphinx_bootstrap_theme sphinx-autodoc-typehints m2r mistune==0.8.4 | |
- name: Build docs | |
run: sphinx-build docs/sphinx build/html | |
- name: Publish docs | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: build/html | |
force_orphan: true |