Skip to content

Commit d1b4ebd

Browse files
SchuemieSchuemie
Schuemie
authored and
Schuemie
committed
Updating GitHub Actions
1 parent 82ca15a commit d1b4ebd

File tree

4 files changed

+153
-50
lines changed

4 files changed

+153
-50
lines changed

.github/pull_request_template.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Before you do a pull request, you should always **file an issue** and make sure the package maintainer agrees that it’s a problem, and is happy with your basic proposal for fixing it. We don’t want you to spend a bunch of time on something that we don’t think is a good idea.
2+
3+
Additional requirements for pull requests:
4+
5+
- Adhere to the [Developer Guidelines](https://ohdsi.github.io/MethodsLibrary/developerGuidelines.html) as well as the [OHDSI Code Style](https://ohdsi.github.io/MethodsLibrary/codeStyle.html).
6+
7+
- If possible, add unit tests for new functionality you add.
8+
9+
- Restrict your pull request to solving the issue at hand. Do not try to 'improve' parts of the code that are not related to the issue. If you feel other parts of the code need better organization, create a separate issue for that.
10+
11+
- Make sure you pass R check without errors and warnings before submitting.
12+
13+
- Always target the `develop` branch, and make sure you are up-to-date with the develop branch.
14+

.github/workflows/R_CMD_check_Hades.yaml

+105-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ jobs:
2828
env:
2929
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
3030
RSPM: ${{ matrix.config.rspm }}
31+
CDM5_ORACLE_CDM_SCHEMA: ${{ secrets.CDM5_ORACLE_CDM_SCHEMA }}
32+
CDM5_ORACLE_OHDSI_SCHEMA: ${{ secrets.CDM5_ORACLE_OHDSI_SCHEMA }}
33+
CDM5_ORACLE_PASSWORD: ${{ secrets.CDM5_ORACLE_PASSWORD }}
34+
CDM5_ORACLE_SERVER: ${{ secrets.CDM5_ORACLE_SERVER }}
35+
CDM5_ORACLE_USER: ${{ secrets.CDM5_ORACLE_USER }}
36+
CDM5_POSTGRESQL_CDM_SCHEMA: ${{ secrets.CDM5_POSTGRESQL_CDM_SCHEMA }}
37+
CDM5_POSTGRESQL_OHDSI_SCHEMA: ${{ secrets.CDM5_POSTGRESQL_OHDSI_SCHEMA }}
38+
CDM5_POSTGRESQL_PASSWORD: ${{ secrets.CDM5_POSTGRESQL_PASSWORD }}
39+
CDM5_POSTGRESQL_SERVER: ${{ secrets.CDM5_POSTGRESQL_SERVER }}
40+
CDM5_POSTGRESQL_USER: ${{ secrets.CDM5_POSTGRESQL_USER }}
41+
CDM5_SQL_SERVER_CDM_SCHEMA: ${{ secrets.CDM5_SQL_SERVER_CDM_SCHEMA }}
42+
CDM5_SQL_SERVER_OHDSI_SCHEMA: ${{ secrets.CDM5_SQL_SERVER_OHDSI_SCHEMA }}
43+
CDM5_SQL_SERVER_PASSWORD: ${{ secrets.CDM5_SQL_SERVER_PASSWORD }}
44+
CDM5_SQL_SERVER_SERVER: ${{ secrets.CDM5_SQL_SERVER_SERVER }}
45+
CDM5_SQL_SERVER_USER: ${{ secrets.CDM5_SQL_SERVER_USER }}
3146

3247
steps:
3348
- uses: actions/checkout@v2
@@ -62,12 +77,28 @@ jobs:
6277
do
6378
eval sudo $cmd
6479
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
80+
81+
- name: Install libssh
82+
if: runner.os == 'Linux'
83+
run: |
84+
sudo apt-get install libssh-dev
6585
6686
- name: Install dependencies
6787
run: |
6888
remotes::install_deps(dependencies = TRUE, INSTALL_opts=c("--no-multiarch"))
6989
remotes::install_cran("rcmdcheck")
7090
shell: Rscript {0}
91+
92+
- name: Install covr
93+
if: runner.os == 'macOS'
94+
run: |
95+
remotes::install_cran("covr")
96+
shell: Rscript {0}
97+
98+
- name: Remove check folder if exists
99+
if: runner.os == 'macOS'
100+
run: unlink("check", recursive = TRUE)
101+
shell: Rscript {0}
71102

72103
- name: Check
73104
env:
@@ -77,20 +108,88 @@ jobs:
77108

78109
- name: Upload check results
79110
if: failure()
80-
uses: actions/upload-artifact@main
111+
uses: actions/upload-artifact@v2
81112
with:
82113
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
83114
path: check
115+
116+
- name: Upload source package
117+
if: success() && runner.os == 'macOS' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
118+
uses: actions/upload-artifact@v2
119+
with:
120+
name: package_tarball
121+
path: check/*.tar.gz
122+
123+
- name: Test coverage
124+
if: runner.os == 'macOS'
125+
run: covr::codecov()
126+
shell: Rscript {0}
84127

85128
Release:
86129
needs: R-CMD-Check
130+
131+
runs-on: macOS-latest
132+
133+
env:
134+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
87135

88-
runs-on: ubuntu-20.04
136+
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
89137

90138
steps:
91-
- name: First
92-
if: ${{ github.event_name != 'pull_request' && github.branch == 'master' }}
139+
140+
- uses: actions/checkout@v2
141+
with:
142+
fetch-depth: 0
143+
144+
- name: Check if version has increased
145+
run: |
146+
echo "new_version="$(perl compare_versions --tag) >> $GITHUB_ENV
147+
148+
- name: Display new version number
149+
if: ${{ env.new_version != '' }}
150+
run: |
151+
echo "${{ env.new_version }}"
152+
153+
- name: Create release
154+
if: ${{ env.new_version != '' }}
155+
uses: actions/create-release@v1
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
158+
with:
159+
tag_name: ${{ env.new_version }}
160+
release_name: Release ${{ env.new_version }}
161+
body: |
162+
See NEWS.md for release notes.
163+
draft: false
164+
prerelease: false
165+
166+
- uses: r-lib/actions/setup-r@v1
167+
if: ${{ env.new_version != '' }}
168+
169+
- name: Install drat
170+
if: ${{ env.new_version != '' }}
171+
run: |
172+
install.packages('drat')
173+
shell: Rscript {0}
174+
175+
- name: Remove any tarballs that already exists
176+
if: ${{ env.new_version != '' }}
177+
run: |
178+
rm -f *.tar.gz
179+
180+
- name: Download package tarball
181+
if: ${{ env.new_version != '' }}
182+
uses: actions/download-artifact@v2
183+
with:
184+
name: package_tarball
185+
186+
- name: Push to drat
187+
if: ${{ env.new_version != '' }}
188+
run: |
189+
bash deploy.sh
190+
191+
- name: Push to BroadSea
192+
if: ${{ env.new_version != '' }}
93193
run: |
94-
perl compare_version --tag && \
95-
bash deploy.sh && \
96194
curl --data "build=true" -X POST https://registry.hub.docker.com/u/ohdsi/broadsea-methodslibrary/trigger/f0b51cec-4027-4781-9383-4b38b42dd4f5/
195+

compare_versions

+3-44
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ $r_major = $1;
99
$r_minor = $2;
1010
$r_mod = $3;
1111

12-
print "New R version: $r_major-$r_minor-$r_mod\n";
13-
1412
open(GIT_VERSION, "git describe --tags |");
1513
$git = <GIT_VERSION>;
1614
close(GIT_VERSION);
@@ -20,49 +18,10 @@ $git_major = $1;
2018
$git_minor = $2;
2119
$git_mod = $3;
2220

23-
print "Current git version: $git_major-$git_minor-$git_mod\n";
24-
2521
if ($r_major > $git_major || $r_minor > $git_minor || $r_mod > $git_mod) {
26-
$monotonic = 0;
22+
$new_version = "v$r_major.$r_minor.$r_mod";
2723
} else {
28-
$monotonic = -1;
29-
}
30-
31-
if ($monotonic != 0) {
32-
print "Non-monotonically increasing versions numbers\n";
33-
}
34-
35-
if ($monotonic == 0 & $ARGV[0] eq "--tag") {
36-
37-
open(GIT_TAG, "git tag v$r_major.$r_minor.$r_mod |");
38-
39-
$fail = 0;
40-
while ($line = <GIT_TAG>) {
41-
if ($line =~ /fatal/) {
42-
$fail = 1;
43-
}
44-
print "tag: $line";
45-
} # TODO Check for errors
46-
close(GIT_TAG);
47-
print "tag: END\n\n";
48-
49-
if ($fail eq 1) {
50-
exit(-1);
51-
}
52-
53-
$cmd = "git config user.name \"Marc A. Suchard\"; " .
54-
"git config user.email \"msuchard@ucla.edu\"; " .
55-
"git tag v$r_major.$r_minor.$r_mod ; " .
56-
"git push -q https://\$GH_TOKEN\@github.com/OHDSI/\$PKG_NAME.git --tags";
57-
58-
print "cmd: $cmd\n";
59-
60-
open(GIT_PUSH, "$cmd |");
61-
while ($line = <GIT_PUSH>) {
62-
print "push: $line";
63-
} # TODO Check for errors
64-
close(GIT_PUSH);
65-
print "push: END\n\n";
24+
$new_version = "";
6625
}
6726

68-
exit($monotonic);
27+
print($new_version);

deploy.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset
3+
addToDrat(){
4+
PKG_REPO=$PWD
5+
6+
## Build package tar ball
7+
export PKG_TARBALL=$(ls *.tar.gz)
8+
9+
cd ..; mkdir drat; cd drat
10+
11+
## Set up Repo parameters
12+
git init
13+
git config user.name "Martijn Schuemie"
14+
git config user.email "[email protected]"
15+
git config --global push.default simple
16+
17+
## Get drat repo
18+
git remote add upstream "https://$GH_TOKEN@github.com/OHDSI/drat.git"
19+
git fetch upstream 2>err.txt
20+
git checkout gh-pages
21+
22+
## Link to local R packages
23+
echo 'R_LIBS=~/Rlib' > .Renviron
24+
25+
Rscript -e "drat::insertPackage('$PKG_REPO/$PKG_TARBALL', \
26+
repodir = '.', \
27+
commit='GitHub Actions release: $PKG_TARBALL run $GITHUB_RUN_ID')"
28+
git push
29+
30+
}
31+
addToDrat

0 commit comments

Comments
 (0)