Skip to content

Commit 77a37eb

Browse files
authored
feat: min NN lock date (#43)
* test: new job to filter matrix * fix: typo * fix: correct json output * feat: add as input * test * fix use env * debug * test * fix: min date when setting env * fix format * fix linting * update readme * test: linting * fix: typo * fix review improvements * fix: linting
1 parent 62f3e1d commit 77a37eb

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

.github/workflows/check_nn_versions.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ on:
2727
required: false
2828
type: boolean
2929
default: false
30+
min_lock_date:
31+
description: Minimum lock date to use for historic checks
32+
required: false
33+
type: string
34+
default: '2000-01-01'
3035
secrets:
3136
TOKEN_APP_ID:
3237
description: ID of the GitHub app used to generate a new token
@@ -37,7 +42,27 @@ on:
3742
permissions:
3843
contents: read
3944
jobs:
45+
filter-nn-versions:
46+
runs-on: macos-latest
47+
outputs:
48+
config: ${{ steps.filter.outputs.config }}
49+
env:
50+
MIN_LOCK_DATE: ${{ inputs.min_lock_date || '2000-01-01' }}
51+
steps:
52+
- name: NN lock dates and R versions
53+
run: |
54+
cat > config.json <<EOF
55+
[
56+
{"date":"2023-10-25","r":"4.3.1"},
57+
{"date":"2024-08-06","r":"4.4.1"}
58+
]
59+
EOF
60+
- name: Filter lock dates
61+
id: filter
62+
run: |
63+
echo "jq --arg date $MIN_LOCK_DATE --compact-output '[.[] | select(.date >= $date)]' config.json" >> "$GITHUB_OUTPUT"
4064
R-CMD-check:
65+
needs: filter-nn-versions
4166
runs-on: '${{ matrix.os }}'
4267
name: '${{ matrix.os }} (R ${{ matrix.config.r }}, ${{ matrix.config.date }})'
4368
strategy:
@@ -47,11 +72,7 @@ jobs:
4772
- macos-latest
4873
- windows-latest
4974
- ubuntu-latest
50-
config:
51-
- date: 2023-10-25
52-
r: 4.3.1
53-
- date: 2024-08-06
54-
r: 4.4.1
75+
config: ${{ fromJSON(needs.filter-nn-versions.outputs.config) }}
5576
env:
5677
R_KEEP_PKG_SOURCE: 'yes'
5778
ERROR_ON_DEFAULT: '"warning"'

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Repository to manage GitHub Actions workflows for our Open-Source projects.
55
It contains the following workflows:
66

77
1. [R-CMD-check standard](.github/workflows/check_current_version.yaml): Standard R CMD check, that checks the package for current version of R on MacOs and Windows, and for the previous, current, and development version of R on Linux.
8-
2. [R-CMD-check NN versions](.github/workflows/check_nn_versions.yaml): Same as 1., but uses the R version and packages available as per given lock dates.
8+
2. [R-CMD-check NN versions](.github/workflows/check_nn_versions.yaml): Same as 1., but uses the R version and packages available as per given lock dates. See below for how to configure the lock dates.
99
3. [Test coverage](.github/workflows/coverage.yaml): Derives test coverage for the package and publishes a summary table to the pull request. For Open-Source repositories this also gives you the option to upload code coverage results to [codecov.io](https://codecov.io).
1010
4. [pkgdown](.github/workflows/pkgdown.yaml): Renders and publishes a `pkgdown` website for your package (to your `gh-pages` branch). For a pull request the page is published to `{base url of package}/dev/{pr number}`, and a link to this development webpage is posted as a comment to your pull request.
1111
5. [megalinter](.github/workflows/megalinter.yaml): Lints your entire project using the [megalinter](https://megalinter.io/) tool. Note that for the [cspell](https://github.com/streetsidesoftware/cspell) linter words in `inst/WORDLIST` are automatically added as a dictionary if the file exists.
@@ -114,7 +114,26 @@ jobs:
114114

115115
Where the secrets point to a GitHub App in your organisation that have read access to the relevant
116116
repositories. Using the `actions/create-github-app-token@v2` action this generates a new token, that
117-
have the neccasary acess, to be used in the step setting up the R dependencies.
117+
have the necessary access, to be used in the step setting up the R dependencies.
118118

119119
See also [Authenticating with a GitHub App](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow#authenticating-with-a-github-app)
120120
for more information on this way of authenticating.
121+
122+
## Filter NN lock dates
123+
124+
The lock dates used in [R-CMD-check NN versions](.github/workflows/check_nn_versions.yaml) can be
125+
configured using the `min_lock_date` input. This subsets the standard list of lock dates and
126+
their corresponding R versions to only include lock dates from this date going forward.
127+
128+
The below snippet only uses lock dates from 06Aug2024 and going forward:
129+
130+
```yaml
131+
check-nn-version:
132+
name: Check NN version
133+
uses: >-
134+
NovoNordisk-OpenSource/r.workflows/.github/workflows/check_nn_versions.yaml@main
135+
with:
136+
min_lock_date: '2024-08-06'
137+
```
138+
139+
For list of used lock dates can be seen inside the workflow file.

0 commit comments

Comments
 (0)