Skip to content

Commit d762783

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

3 files changed

Lines changed: 64 additions & 58 deletions

File tree

.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: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ on:
1919
jobs:
2020
dsBaseClient_test_suite:
2121
runs-on: ubuntu-latest
22-
timeout-minutes: 180
23-
permissions:
24-
contents: read
2522

26-
# These should all be constant, except TEST_FILTER. This can be used to test
23+
# This logic automatically selects the image tag
24+
container:
25+
image: >-
26+
ghcr.io/${{ github.repository_owner }}/ds-base-env:${{
27+
startsWith(github.ref_name, 'dev-') &&
28+
replace(github.ref_name, 'dev-', 'v') ||
29+
'latest'
30+
}}-dev
31+
options: --user root -v /var/run/docker.sock:/var/run/docker.sock
32+
33+
# These should all be constant, except TEST_FILTER. This can be used to test
2734
# subsets of test files in the testthat directory. Options are like:
2835
# '*' <- Run all tests.
2936
# 'asNumericDS*' <- Run all asNumericDS tests, i.e. all the arg, etc. tests.
@@ -54,58 +61,6 @@ jobs:
5461
persist-credentials: false
5562
token: ${{ env.GITHUB_TOKEN }}
5663

57-
- name: Uninstall default MySQL
58-
run: |
59-
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
60-
sudo service mysql stop || true
61-
sudo apt-get update
62-
sudo apt-get remove --purge mysql-client mysql-server mysql-common -y
63-
sudo apt-get autoremove -y
64-
sudo apt-get autoclean -y
65-
sudo rm -rf /var/lib/mysql/
66-
67-
- uses: r-lib/actions/setup-pandoc@v2
68-
69-
- uses: r-lib/actions/setup-r@v2
70-
with:
71-
r-version: release
72-
http-user-agent: release
73-
use-public-rspm: true
74-
75-
- name: Install R and dependencies
76-
run: |
77-
sudo apt-get install --no-install-recommends software-properties-common dirmngr -y
78-
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
79-
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
80-
sudo apt-get update -qq
81-
sudo apt-get upgrade -y
82-
sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev libgsl-dev libgit2-dev r-base -y
83-
sudo apt-get install -qq libharfbuzz-dev libfribidi-dev libmagick++-dev xml-twig-tools -y
84-
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')"
85-
sudo R -q -e "devtools::install_github(repo='datashield/dsDangerClient', ref=Sys.getenv('BRANCH_NAME'))"
86-
87-
- uses: r-lib/actions/setup-r-dependencies@v2
88-
with:
89-
dependencies: 'c("Imports")'
90-
extra-packages: |
91-
any::rcmdcheck
92-
cran::devtools
93-
cran::git2r
94-
cran::RCurl
95-
cran::readr
96-
cran::magrittr
97-
cran::xml2
98-
cran::purrr
99-
cran::dplyr
100-
cran::stringr
101-
cran::tidyr
102-
cran::quarto
103-
cran::knitr
104-
cran::kableExtra
105-
cran::rmarkdown
106-
cran::downlit
107-
needs: check
108-
10964
- name: Check manual updated
11065
run: |
11166
orig_sum=$(find man -type f | sort -u | xargs cat | md5sum)
@@ -194,11 +149,11 @@ jobs:
194149
- name: Parse results from testthat and covr
195150
run: |
196151
Rscript --verbose --vanilla ../testStatus/source/parse_test_report.R logs/ logs/ https://github.com/datashield/${{ env.PROJECT_NAME }}/blob/${{ env.BRANCH_NAME }} '([^:]+)' '(?<=::)[^:]+(?=::)'
197-
working-directory: dsBaseClient
152+
working-directory: dsBaseClient
198153
env:
199154
PROJECT_NAME: ${{ env.PROJECT_NAME }}
200155
BRANCH_NAME: ${{ env.BRANCH_NAME }}
201-
156+
202157
- name: Render report
203158
run: |
204159
cd testStatus

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)