Skip to content

Commit a0f3b80

Browse files
authored
Create pr_check.yml
Add github actions
1 parent 32afbd3 commit a0f3b80

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

.github/workflows/pr_check.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: PR CMD check & build site
2+
3+
on:
4+
pull_request:
5+
push:
6+
paths:
7+
- 'DESCRIPTION'
8+
- '**.yml'
9+
branches:
10+
- devel
11+
- RELEASE_3_21
12+
13+
env:
14+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
15+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
CRAN: https://p3m.dev/cran/__linux__/noble/latest
17+
BIOC_RELEASE: RELEASE_3_21
18+
19+
jobs:
20+
set-matrix:
21+
runs-on: ubuntu-24.04
22+
outputs:
23+
matrix: ${{ steps.set.outputs.matrix }}
24+
steps:
25+
- name: Set Matrix Bioconductor Version
26+
id: set
27+
run: |
28+
MATRIX="{\"include\":[{\"bioc_version\":\"$GITHUB_REF_NAME\"}]}"
29+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
30+
31+
check:
32+
needs: set-matrix
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
36+
container: bioconductor/bioconductor_docker:${{ matrix.bioc_version }}
37+
38+
steps:
39+
- name: Checkout Repository
40+
uses: actions/checkout@v4
41+
with:
42+
ref: ${{ matrix.bioc_version }}
43+
44+
- name: Query dependencies
45+
run: |
46+
BiocManager::install(c("covr", "BiocCheck"))
47+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
48+
shell: Rscript {0}
49+
50+
- name: Cache R packages
51+
if: runner.os != 'Windows'
52+
uses: actions/cache@v4
53+
with:
54+
path: /usr/local/lib/R/site-library
55+
key: ${{ runner.os }}-r-${{ matrix.bioc_version }}-${{ hashFiles('.github/depends.Rds') }}
56+
restore-keys: ${{ runner.os }}-r-${{ matrix.bioc_version }}-
57+
58+
- name: Install GPG
59+
if: ${{ github.ref == 'refs/heads/devel' && github.event_name != 'pull_request' }}
60+
run: sudo apt-get update && sudo apt-get install -y gpg
61+
62+
- name: Install Dependencies
63+
run: |
64+
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories())
65+
BiocManager::install(c("rcmdcheck", "BiocCheck"), ask = FALSE, update = TRUE)
66+
shell: Rscript {0}
67+
68+
- name: Check Package
69+
env:
70+
_R_CHECK_CRAN_INCOMING_REMOTE_: false
71+
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error", check_dir = "check")
72+
shell: Rscript {0}
73+
74+
- name: Test coverage
75+
if: ${{ success() && github.ref == 'refs/heads/devel' && github.event_name != 'pull_request' }}
76+
run: |
77+
cov <- covr::package_coverage(
78+
quiet = FALSE,
79+
clean = FALSE,
80+
type = "all",
81+
install_path = file.path(
82+
normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"),
83+
"package"
84+
)
85+
)
86+
covr::to_cobertura(cov)
87+
shell: Rscript {0}
88+
89+
- name: Upload test results to Codecov
90+
if: ${{ success() && github.ref == 'refs/heads/devel' && github.event_name != 'pull_request' }}
91+
uses: codecov/codecov-action@v4
92+
with:
93+
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
94+
file: ./cobertura.xml
95+
plugin: noop
96+
disable_search: true
97+
token: ${{ secrets.CODECOV_TOKEN }}
98+
99+
- name: Run BiocCheck
100+
id: bioccheck
101+
run: |
102+
BiocCheck::BiocCheck(
103+
dir('check', 'tar.gz$', full.names = TRUE),
104+
`quit-with-status` = TRUE, `no-check-bioc-help` = TRUE
105+
)
106+
shell: Rscript {0}
107+
108+
- name: Build pkgdown
109+
if: ${{ github.ref == format('refs/heads/{0}', env.BIOC_RELEASE) && github.event_name != 'pull_request' }}
110+
run: |
111+
PATH=$PATH:$HOME/bin/ Rscript -e 'pkgdown::build_site()'
112+
113+
- name: Upload pkgdown artifact
114+
if: github.ref == format('refs/heads/{0}', env.BIOC_RELEASE)
115+
uses: actions/upload-pages-artifact@v3
116+
with:
117+
path: docs
118+
119+
dock:
120+
if: ${{ github.ref == 'refs/heads/devel' }}
121+
runs-on: ubuntu-24.04
122+
needs: check
123+
steps:
124+
- name: Checkout Repository
125+
if: ${{ success() && github.event_name != 'pull_request' }}
126+
uses: actions/checkout@v4
127+
128+
- name: Register repo name
129+
if: ${{ github.event_name != 'pull_request' }}
130+
id: reg_repo_name
131+
run: |
132+
echo CONT_IMG_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
133+
134+
- name: Login to Docker Hub
135+
if: ${{ github.event_name != 'pull_request' }}
136+
uses: docker/login-action@v2
137+
with:
138+
username: ${{ secrets.DOCKERHUB_USERNAME }}
139+
password: ${{ secrets.DOCKERHUB_TOKEN }}
140+
141+
- name: Build and Push Docker
142+
if: ${{ success() && github.event_name != 'pull_request' }}
143+
uses: docker/build-push-action@v6
144+
with:
145+
context: .
146+
file: ./inst/docker/pkg/Dockerfile
147+
push: true
148+
tags: >
149+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:latest,
150+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
151+
152+
deploy:
153+
needs: check
154+
permissions:
155+
contents: write
156+
pages: write
157+
id-token: write
158+
runs-on: ubuntu-24.04
159+
160+
steps:
161+
- name: Deploy to GitHub Pages
162+
if: ${{ github.ref == format('refs/heads/{0}', env.BIOC_RELEASE) && github.event_name != 'pull_request' }}
163+
id: deployment
164+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)