Skip to content

Commit 8429089

Browse files
committed
chore: build image which can be reused to speed up CI
1 parent ac77774 commit 8429089

File tree

3 files changed

+70
-103
lines changed

3 files changed

+70
-103
lines changed

.github/workflows/build-env.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
release_tag:
5+
description: 'Image tag (e.g., v7.0.0-dev)'
6+
required: true
7+
danger_version:
8+
description: 'dsDangerClient version/branch'
9+
required: true
10+
default: 'v7.0.0-dev'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Log in to GHCR
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Build and Push
27+
uses: docker/build-push-action@v5
28+
with:
29+
context: .
30+
push: true
31+
build-args: |
32+
DANGER_VERSION=${{ github.event.inputs.danger_version }}
33+
tags: ghcr.io/${{ github.repository_owner }}/ds-base-env:${{ github.event.inputs.release_tag }}

.github/workflows/dsBaseClient_test_suite.yaml

Lines changed: 19 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Adapted from `armadillo_azure-pipelines.yml` by Roberto Villegas-Diaz
44
#
55
# Inside the root directory $(Pipeline.Workspace) will be a file tree like:
6-
# /dsBaseClient <- Checked out version of datashield/dsBaseClient
7-
# /dsBaseClient/logs <- Where results of tests and logs are collated
8-
# /testStatus <- Checked out version of datashield/testStatus
6+
# /dsBaseClient <- Checked out version of datashield/dsBaseClient
7+
# /dsBaseClient/logs <- Where results of tests and logs are collated
8+
# /testStatus <- Checked out version of datashield/testStatus
99
#
1010
# As of Sept. 2025 this takes ~ 95 mins to run.
1111
################################################################################
@@ -24,11 +24,16 @@ jobs:
2424
permissions:
2525
contents: read
2626

27-
# These should all be constant, except TEST_FILTER. This can be used to test
28-
# subsets of test files in the testthat directory. Options are like:
29-
# '*' <- Run all tests.
30-
# 'asNumericDS*' <- Run all asNumericDS tests, i.e. all the arg, etc. tests.
31-
# '*_smk_*' <- Run all the smoke tests for all functions.
27+
# This logic automatically selects the image tag
28+
container:
29+
image: >-
30+
ghcr.io/${{ github.repository_owner }}/ds-base-env:${{
31+
startsWith(github.ref_name, 'dev-') &&
32+
replace(github.ref_name, 'dev-', 'v') ||
33+
'latest'
34+
}}-dev
35+
options: --user root -v /var/run/docker.sock:/var/run/docker.sock
36+
3237
env:
3338
TEST_FILTER: '_-|datachk-|smk-|arg-|disc-|perf-|smk_expt-|expt-|math-'
3439
_r_check_system_clock_: 0
@@ -55,57 +60,8 @@ jobs:
5560
persist-credentials: false
5661
token: ${{ env.GITHUB_TOKEN }}
5762

58-
- name: Uninstall default MySQL
59-
run: |
60-
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
61-
sudo service mysql stop || true
62-
sudo apt-get update
63-
sudo apt-get remove --purge mysql-client mysql-server mysql-common -y
64-
sudo apt-get autoremove -y
65-
sudo apt-get autoclean -y
66-
sudo rm -rf /var/lib/mysql/
67-
68-
- uses: r-lib/actions/setup-pandoc@v2
69-
70-
- uses: r-lib/actions/setup-r@v2
71-
with:
72-
r-version: release
73-
http-user-agent: release
74-
use-public-rspm: true
75-
76-
- name: Install R and dependencies
77-
run: |
78-
sudo apt-get install --no-install-recommends software-properties-common dirmngr -y
79-
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
80-
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
81-
sudo apt-get update -qq
82-
sudo apt-get upgrade -y
83-
sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev libgsl-dev libgit2-dev r-base -y
84-
sudo apt-get install -qq libharfbuzz-dev libfribidi-dev libmagick++-dev xml-twig-tools -y
85-
sudo R -q -e "install.packages(c('devtools','covr','fields','meta','metafor','ggplot2','gridExtra','data.table','DSI','DSOpal','DSLite','MolgenisAuth','MolgenisArmadillo','DSMolgenisArmadillo','DescTools','e1071'), repos='https://cloud.r-project.org')"
86-
sudo R -q -e "devtools::install_github(repo='datashield/dsDangerClient', ref=Sys.getenv('BRANCH_NAME'))"
87-
88-
- uses: r-lib/actions/setup-r-dependencies@v2
89-
with:
90-
dependencies: 'c("Imports")'
91-
extra-packages: |
92-
any::rcmdcheck
93-
cran::devtools
94-
cran::git2r
95-
cran::RCurl
96-
cran::readr
97-
cran::magrittr
98-
cran::xml2
99-
cran::purrr
100-
cran::dplyr
101-
cran::stringr
102-
cran::tidyr
103-
cran::quarto
104-
cran::knitr
105-
cran::kableExtra
106-
cran::rmarkdown
107-
cran::downlit
108-
needs: check
63+
- name: Install PR version of dsBaseClient
64+
run: R CMD INSTALL dsBaseClient
10965

11066
- name: Check manual updated
11167
run: |
@@ -169,7 +125,6 @@ jobs:
169125
),
170126
"coveragelist.csv"
171127
)'
172-
173128
mv coveragelist.csv logs/
174129
mv test_* logs/
175130
working-directory: dsBaseClient
@@ -180,7 +135,6 @@ jobs:
180135
echo "Number of testsuites with issues: $issue_count"
181136
sed 's/failures="0" errors="0"//' test_results.xml | grep errors= > issues.log || true
182137
cat issues.log || true
183-
# continue with workflow even when some tests fail
184138
exit 0
185139
working-directory: dsBaseClient/logs
186140

@@ -193,52 +147,14 @@ jobs:
193147

194148
- name: Parse results from testthat and covr
195149
run: |
196-
Rscript --verbose --vanilla ../testStatus/source/parse_test_report.R logs/
150+
Rscript --verbose --vanilla ../testStatus/source/parse_test_report.R logs/ logs/ https://github.com/datashield/${{ env.PROJECT_NAME }}/blob/${{ env.BRANCH_NAME }} '([^:]+)' '(?<=::)[^:]+(?=::)'
197151
working-directory: dsBaseClient
152+
env:
153+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
154+
BRANCH_NAME: ${{ env.BRANCH_NAME }}
198155

199156
- name: Render report
200157
run: |
201158
cd testStatus
202-
203159
mkdir -p new/logs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/
204160
mkdir -p new/docs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/
205-
mkdir -p new/docs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/latest/
206-
207-
# Copy logs to new logs directory location
208-
cp -rv ../dsBaseClient/logs/* new/logs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/
209-
cp -rv ../dsBaseClient/logs/${{ env.WORKFLOW_ID }}.txt new/logs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/
210-
211-
R -e 'input_dir <- file.path("../new/logs", Sys.getenv("PROJECT_NAME"), Sys.getenv("BRANCH_NAME"), Sys.getenv("WORKFLOW_ID")); quarto::quarto_render("source/test_report.qmd", execute_params = list(input_dir = input_dir))'
212-
mv source/test_report.html new/docs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/index.html
213-
cp -r new/docs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/${{ env.WORKFLOW_ID }}/* new/docs/${{ env.PROJECT_NAME }}/${{ env.BRANCH_NAME }}/latest
214-
215-
env:
216-
PROJECT_NAME: ${{ env.PROJECT_NAME }}
217-
BRANCH_NAME: ${{ env.BRANCH_NAME }}
218-
WORKFLOW_ID: ${{ env.WORKFLOW_ID }}
219-
220-
- name: Upload test logs
221-
uses: actions/upload-artifact@v4
222-
with:
223-
name: dsbaseclient-logs
224-
path: testStatus/new
225-
226-
- name: Dump environment info
227-
run: |
228-
echo -e "\n#############################"
229-
echo -e "ls /: ######################"
230-
ls -al .
231-
echo -e "\n#############################"
232-
echo -e "lscpu: ######################"
233-
lscpu
234-
echo -e "\n#############################"
235-
echo -e "memory: #####################"
236-
free -m
237-
echo -e "\n#############################"
238-
echo -e "env: ########################"
239-
env
240-
echo -e "\n#############################"
241-
echo -e "R sessionInfo(): ############"
242-
R -e 'sessionInfo()'
243-
sudo apt install tree -y
244-
tree .

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM rocker/r-ver:4.3.0
2+
3+
# 1. System Libraries
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
sudo software-properties-common dirmngr wget curl \
6+
libxml2-dev libcurl4-openssl-dev libssl-dev libgsl-dev libgit2-dev \
7+
libharfbuzz-dev libfribidi-dev libmagick++-dev xml-twig-tools \
8+
docker.io docker-compose-v2 \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# 2. R Packages (Stable dependencies)
12+
RUN R -e "options(repos = c(RSPM = 'https://packagemanager.posit.co/cran/__linux__/jammy/latest', CRAN = 'https://cloud.r-project.org')); \
13+
install.packages(c('devtools','remotes','covr','fields','meta','metafor','ggplot2','gridExtra','data.table','DSI','DSOpal','DSLite','MolgenisAuth','MolgenisArmadillo','DSMolgenisArmadillo','DescTools','e1071', \
14+
'rcmdcheck','git2r','RCurl','readr','magrittr','xml2','purrr','dplyr','stringr','tidyr','knitr','kableExtra','rmarkdown','downlit'))"
15+
16+
# 3. dsDangerClient (Pass the version as a build argument)
17+
ARG DANGER_VERSION=master
18+
RUN R -e "remotes::install_github('datashield/dsDangerClient', ref='${DANGER_VERSION}')"

0 commit comments

Comments
 (0)