generated from hubverse-org/hubTemplate
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
210ef08
commit 0ce123d
Showing
1 changed file
with
21 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,34 @@ | ||
name: Hub Submission Validation (R) | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: main | ||
paths: | ||
- 'model-output/**' | ||
- 'model-metadata/*' | ||
branches: | ||
- main | ||
|
||
jobs: | ||
validate-submission: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
- name: Set up R | ||
uses: r-lib/actions/setup-r@v2 | ||
with: | ||
install-r: false | ||
use-public-rspm: true | ||
|
||
- name: Install system dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libcurl4-openssl-dev libv8-dev | ||
- name: Cache R packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.R_LIBS_USER }} | ||
key: ${{ runner.os }}-r-${{ hashFiles('DESCRIPTION') }} | ||
restore-keys: ${{ runner.os }}-r- | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install hubUtils from specific branch | ||
run: | | ||
Rscript -e 'install.packages("remotes")' | ||
Rscript -e 'remotes::install_github("kjsato/hubUtils@main-mr_schema", upgrade = "never")' | ||
- name: Install hubData from specific branch | ||
run: | | ||
Rscript -e 'remotes::install_github("kjsato/hubData@main-mr_schema", upgrade = "never")' | ||
- name: Install hubAdmin from specific branch | ||
run: | | ||
Rscript -e 'remotes::install_github("kjsato/hubAdmin@main-mr_schema", upgrade = "never")' | ||
- name: Install HubValidations | ||
run: | | ||
Rscript -e 'remotes::install_github("kjsato/hubValidations@main-mr_schema-conv_origin_date", upgrade = "never")' | ||
- name: Set up R | ||
uses: r-lib/actions/setup-r@v2 | ||
|
||
- name: Run validations | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
run: | | ||
library("hubValidations") | ||
v <- hubValidations::validate_pr( | ||
gh_repo = Sys.getenv("GITHUB_REPOSITORY"), | ||
pr_number = Sys.getenv("PR_NUMBER"), | ||
skip_submit_window_check = FALSE | ||
) | ||
hubValidations::check_for_errors(v) | ||
shell: Rscript {0} | ||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
git diff --quiet || echo "changes_detected=true" >> $GITHUB_ENV | ||
- name: Commit and push changes | ||
if: env.changes_detected == 'true' | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m "Automatically update files after validation" | ||
git push origin HEAD:${{ github.head_ref }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Cache R packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ runner.tool_cache }}/R | ||
key: ${{ runner.os }}-r-${{ hashFiles('**/*.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-r- | ||
- name: Install dependencies | ||
run: Rscript -e 'install.packages(readLines("dependencies.txt"))' | ||
|
||
- name: Run validation script | ||
run: Rscript validate.R |