|
| 1 | +name: Validate |
| 2 | +on: |
| 3 | + pull_request_target: |
| 4 | + types: [synchronize, opened, reopened] |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'model-output/**.parquet' |
| 9 | + - 'model-metadata/*' |
| 10 | + - '!**README**' |
| 11 | + |
| 12 | +jobs: |
| 13 | + validates-files: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + env: |
| 17 | + GH_PR_NUMBER: ${{ github.event.pull_request.number }} |
| 18 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + ref: ${{ github.event.pull_request.head.sha }} |
| 25 | + fetch-depth: 1 |
| 26 | + sparse-checkout: | |
| 27 | + .github/ |
| 28 | + src |
| 29 | + hub-config |
| 30 | + model-output/ |
| 31 | + model-metadata/ |
| 32 | +
|
| 33 | + - name: Setup R |
| 34 | + uses: r-lib/actions/setup-r@v2 |
| 35 | + |
| 36 | + - name: Install system dependencies |
| 37 | + run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev |
| 38 | + |
| 39 | + - name: Cache R packages |
| 40 | + id: cache |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ${{ env.R_LIBS_USER }} |
| 44 | + key: ${{ runner.os }}-${{ hashFiles('.github/requirement_validation.txt') }}-1 |
| 45 | + |
| 46 | + - name: Install dependencies |
| 47 | + if: ( steps.cache.outputs.cache-hit != 'true' ) |
| 48 | + run: | |
| 49 | + R -e 'Sys.setenv("NOT_CRAN" = TRUE) |
| 50 | + install.packages(c("arrow", "gh", "remotes")) |
| 51 | + Sys.unsetenv("NOT_CRAN") |
| 52 | + remotes::install_url("https://github.com/midas-network/SMHvalidation/archive/refs/heads/main.zip")' |
| 53 | + env: |
| 54 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Run Validation - Open/reopen |
| 57 | + if: ( github.event.action != 'synchronize' ) |
| 58 | + run: | |
| 59 | + R -e 'source("src/validation.R") |
| 60 | + pr_validate(Sys.getenv("GITHUB_REPOSITORY"), |
| 61 | + Sys.getenv("GH_PR_NUMBER"), "", ".", |
| 62 | + Sys.getenv("GH_TOKEN"))' |
| 63 | +
|
| 64 | + - name: Run Validation - Synchronize |
| 65 | + if: ( github.event.action == 'synchronize' ) |
| 66 | + run: | |
| 67 | + R -e 'source("src/validation.R") |
| 68 | + pr_validate(Sys.getenv("GITHUB_REPOSITORY"), |
| 69 | + Sys.getenv("GH_PR_NUMBER"), |
| 70 | + Sys.getenv("GH_COMMIT_SHA"), ".", |
| 71 | + Sys.getenv("GH_TOKEN"))' |
| 72 | + env: |
| 73 | + GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} |
| 74 | + |
0 commit comments