Skip to content

Commit 0d7bc26

Browse files
committed
Added a suite of GitHub actions for tests, docs and publishing.
1 parent af00027 commit 0d7bc26

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed

.github/workflows/build-docs.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
6+
7+
name: Build documentation
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Node
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 22
19+
20+
- name: Restore the node modules
21+
uses: actions/cache@v4
22+
with:
23+
path: '**/node_modules'
24+
key: npm-${{ hashFiles('**/package.json') }}
25+
26+
- name: Install JSDoc
27+
run: npm i --include=dev
28+
29+
- name: Run JSDoc
30+
run: npm run jsdoc
31+
32+
- name: GH Pages Deployment
33+
uses: JamesIves/github-pages-deploy-action@v4
34+
with:
35+
branch: gh-pages # The branch the action should deploy to.
36+
folder: docs/built
37+
target-folder: docs
38+
clean: true # Automatically remove deleted files from the deploy branch

.github/workflows/publish-npm.yaml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
on:
2+
workflow_run:
3+
workflows: [Run unit tests]
4+
types: [completed]
5+
branches: [master]
6+
7+
name: Build and publish to NPM
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 22
22+
23+
# We only run the remaining (remote-touching) steps if the version has actually changed.
24+
- name: Extract package versions
25+
shell: bash
26+
run: |
27+
current_version=$(npm pkg get version | sed 's/"//g')
28+
echo "NEW_WOBBEGONG_VERSION=${current_version}" >> $GITHUB_ENV
29+
old_version=$(npm view wobbegong version)
30+
update=0 && [[ $old_version != $current_version ]] && update=1
31+
echo "UPDATE_WOBBEGONG=${update}" >> $GITHUB_ENV
32+
echo "Current version is ${current_version} (published ${old_version})"
33+
34+
- name: Cache Modules
35+
if: env.UPDATE_WOBBEGONG == 1
36+
uses: actions/cache@v4
37+
with:
38+
path: '**/node_modules'
39+
key: npm-${{ hashFiles('package.json') }}
40+
41+
- name: Update NPM packages
42+
if: env.UPDATE_WOBBEGONG == 1
43+
run: npm i --include=dev
44+
45+
- name: Cache mock files
46+
if: env.UPDATE_WOBBEGONG == 1
47+
uses: actions/cache@v4
48+
with:
49+
path: tests/mock-files
50+
key: mock-${{ hashFiles('tests/mock.R') }}
51+
52+
- name: Double-checking tests
53+
if: env.UPDATE_WOBBEGONG == 1
54+
run: npm run test
55+
56+
- name: Publish to NPM
57+
if: env.UPDATE_WOBBEGONG == 1
58+
run: npm publish
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
62+
- name: Tagging the release
63+
if: env.UPDATE_WOBBEGONG == 1
64+
uses: actions/github-script@v5
65+
with:
66+
script: |
67+
github.rest.git.createRef({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
ref: 'refs/tags/' + process.env.NEW_WOBBEGONG_VERSION,
71+
sha: context.sha
72+
})

.github/workflows/run-tests.yaml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
7+
name: Run unit tests
8+
9+
jobs:
10+
create_mock:
11+
runs-on: ubuntu-latest
12+
container: bioconductor/bioconductor_docker:devel
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Cache RDS files
19+
id: cache-mock
20+
uses: actions/cache@v4
21+
with:
22+
path: tests/mock-files
23+
key: mock-${{ hashFiles('tests/mock.R') }}
24+
25+
- name: Restore the package directory
26+
if: steps.cache-mock.outputs.cache-hit != 'true'
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ env.R_PKG_DIR }}
30+
key: check-packages
31+
32+
- name: Clone the wobbegong R package
33+
if: steps.cache-mock.outputs.cache-hit != 'true'
34+
run: git clone https://github.com/kanaverse/wobbegong-R rpkg
35+
36+
- name: Install dependencies
37+
if: steps.cache-mock.outputs.cache-hit != 'true'
38+
shell: Rscript {0}
39+
run: |
40+
stuff <- read.dcf("rpkg/DESCRIPTION")
41+
stuff <- stuff[,intersect(colnames(stuff), c("Imports", "LinkingTo", "Suggests", "Depends"))]
42+
deps <- sub(" .*", "", unlist(strsplit(stuff, ",\\s*"), use.names=FALSE))
43+
BiocManager::install(deps)
44+
45+
- name: Install the R package
46+
if: steps.cache-mock.outputs.cache-hit != 'true'
47+
run: R CMD INSTALL rpkg
48+
49+
- name: Build the mock files
50+
if: steps.cache-mock.outputs.cache-hit != 'true'
51+
run: |
52+
cd tests
53+
R -f mock.R
54+
55+
test:
56+
runs-on: ubuntu-latest
57+
needs: [ create_mock ]
58+
59+
steps:
60+
- name: Checkout repo
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Node
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 22
67+
68+
- name: Cache Modules
69+
uses: actions/cache@v4
70+
with:
71+
path: '**/node_modules'
72+
key: npm-${{ hashFiles('package.json') }}
73+
74+
- name: Update NPM packages
75+
run: npm i --include=dev
76+
77+
- name: Cache mock files
78+
uses: actions/cache@v4
79+
with:
80+
path: tests/mock-files
81+
key: mock-${{ hashFiles('tests/mock.R') }}
82+
83+
- name: Run tests
84+
run: npm run test

0 commit comments

Comments
 (0)