Skip to content

Fixes #2 Caching does not work#4

Merged
Yuri05 merged 3 commits into
Open-Systems-Pharmacology:mainfrom
Yuri05:main
Feb 23, 2026
Merged

Fixes #2 Caching does not work#4
Yuri05 merged 3 commits into
Open-Systems-Pharmacology:mainfrom
Yuri05:main

Conversation

@Yuri05

@Yuri05 Yuri05 commented Feb 22, 2026

Copy link
Copy Markdown
Member

Extracted the common "Setup OSP Infrastructure" part from the 2 workflows (should be moved later to the Workflows repo).
Fixes #2 Caching does not work.

Now when executed for the 1st time from a new branch (or after changing of tools.csv configuration) - a new cache is created and used in the subsequent runs from this branch (saves 6-7 minutes per qualification run).

Summary by CodeRabbit

  • Chores
    • Streamlined internal CI/CD setup processes to improve build reliability and maintainability through centralized environment configuration.

Yuri05 and others added 3 commits February 20, 2026 22:37
* Initial plan

* Extract environment setup into standalone composite GitHub Action

Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>

* Update action.yml

* Update create-evaluation_reports.yml

* Update create-qualification_reports.yml

* Update action.yml

* Update action.yml

* Update .github/workflows/create-evaluation_reports.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update .github/workflows/create-qualification_reports.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update .github/workflows/create-evaluation_reports.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update action.yml

* Update create-evaluation_reports.yml

* Update create-qualification_reports.yml

* Update action.yml

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update action.yml

* Update action.yml

* Update action.yml
* Update action.yml

* Update action.yml
@coderabbitai

coderabbitai Bot commented Feb 22, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Introduces a new composite GitHub Action that consolidates R, PK-Sim, and QualificationRunner environment setup with caching logic, then simplifies two workflows to use this action instead of their previous multi-step setup sequences.

Changes

Cohort / File(s) Summary
New Composite Action
.github/actions/setup-qualification-environment/action.yml
New composite action handling R library path setup, git configuration, cache key computation, cache restore/save, and conditional setup of R, Pandoc, chromehtml2pdf, and ggplot2 downgrade based on cache hit/miss.
Simplified Workflows
.github/workflows/create-evaluation_reports.yml, .github/workflows/create-qualification_reports.yml
Replaced extensive pre-run environment setup (git config, caching, R/Pandoc/chromehtml2pdf installation, qualification environment setup) with a single call to the new composite action; removed 72 lines of duplicate boilerplate across both files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Initial commit #1: Directly related refactoring that consolidates the same multi-step setup logic from both workflow files into a new composite action for reusability.

Poem

🐰 Setup steps once scattered and spread,
Now bundled in one action thread,
Caching springs forth with delight,
Workflows run swift—what a sight!
No more duplication to dread!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Fixes #2 Caching does not work' directly addresses the main objective: fixing caching functionality.
Linked Issues check ✅ Passed The PR addresses issue #2 by extracting shared setup into a composite GitHub Action that implements proper caching for environment setup steps, directly fixing the caching problem.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing caching: introducing the composite action, simplifying workflows, and enabling cache reuse across runs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
.github/actions/setup-qualification-environment/action.yml (3)

8-11: Hardcoded tools.csv path reduces reusability.

The tools-path is hardcoded to tools.csv in both the cache key computation (line 16) and the remote action call (line 60), but this composite action doesn't declare any inputs. If you plan to move this to the shared Workflows repo, consider adding a tools-path input with a default of tools.csv now to ease that migration.

Example: declare an input
 name: 'Setup Qualification Environment'
 description: 'Sets up the qualification environment (R, PK-Sim, QualificationRunner) with caching support'
 
+inputs:
+  tools-path:
+    description: 'Path to the tools.csv file'
+    required: false
+    default: 'tools.csv'
+
 runs:
   using: composite
   steps:

Then replace tools.csv references with ${{ inputs.tools-path }}.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/setup-qualification-environment/action.yml around lines 8 -
11, Add a new action input named tools-path (default "tools.csv") to the
action.yml inputs section and update all hardcoded references to "tools.csv"
(used in the cache key computation and the remote action call) to use the input
expression ${{ inputs.tools-path }} instead; ensure the input is documented in
the action metadata so callers can override it and verify both the cache key
generation and the remote action invocation now reference the new tools-path
input rather than the literal filename.

13-17: Cache key includes R_LIBS_USER path — consider whether this adds value.

R_LIBS_USER resolves to ${RUNNER_TEMP}\Library, which is a fixed path on GitHub-hosted windows-2022 runners (typically D:\a\_temp\Library). Including it in the cache key means the key is stable as long as GitHub doesn't change the runner's temp path. If the intent is to differentiate by runner type, consider using the runner OS label explicitly instead, which is more readable and intentional:

echo "CACHE_KEY=ospsuite-windows-2022-${{ hashFiles('tools.csv') }}" >> $GITHUB_ENV

That said, the current approach works — this is just a readability suggestion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/setup-qualification-environment/action.yml around lines 13 -
17, The CACHE_KEY currently embeds env.R_LIBS_USER which expands to a
runner-specific temp path; update the action.yml step that sets CACHE_KEY so it
uses an explicit, readable runner identifier (e.g., the OS label) instead of ${
env.R_LIBS_USER }—locate the lines that write CACHE_KEY (the echo assigning
CACHE_KEY=ospsuite-${{ env.R_LIBS_USER }}-${{ hashFiles('tools.csv') }}) and
replace the env.R_LIBS_USER portion with a fixed runner token like the OS label
(or another intentional discriminator) while keeping the hashFiles('tools.csv')
part intact.

55-60: Naming overlap with the remote action may cause confusion.

The local composite action (.github/actions/setup-qualification-environment) has the same directory name as the remote action it delegates to on cache miss (Open-Systems-Pharmacology/Workflows/.github/actions/setup-qualification-environment@main). While this works correctly because they're in different repos, it makes it harder for maintainers to tell them apart at a glance. The PR description notes this is "intended to be moved later to the Workflows repo" — consider adding a comment here clarifying the relationship (e.g., "delegates to the upstream action that performs the actual setup").

Also, if the remote action at Workflows repo ever adds its own caching layer, this would result in double-caching. Worth keeping in mind during the planned migration.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/setup-qualification-environment/action.yml around lines 55 -
60, The composite action step with id "qualification-environment" currently uses
the remote action
"Open-Systems-Pharmacology/Workflows/.github/actions/setup-qualification-environment@main"
which shares the same directory name as the local composite action and can
confuse maintainers; update the step to include a short inline comment
clarifying that this local composite delegates to the upstream action (e.g.,
"delegates to upstream Workflows action that performs actual setup") and
optionally rename the local action directory or the step id to avoid name
collision; also add a TODO note near the if-cache logic warning about potential
double-caching if the upstream action later implements caching.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/actions/setup-qualification-environment/action.yml:
- Around line 8-11: Add a new action input named tools-path (default
"tools.csv") to the action.yml inputs section and update all hardcoded
references to "tools.csv" (used in the cache key computation and the remote
action call) to use the input expression ${{ inputs.tools-path }} instead;
ensure the input is documented in the action metadata so callers can override it
and verify both the cache key generation and the remote action invocation now
reference the new tools-path input rather than the literal filename.
- Around line 13-17: The CACHE_KEY currently embeds env.R_LIBS_USER which
expands to a runner-specific temp path; update the action.yml step that sets
CACHE_KEY so it uses an explicit, readable runner identifier (e.g., the OS
label) instead of ${ env.R_LIBS_USER }—locate the lines that write CACHE_KEY
(the echo assigning CACHE_KEY=ospsuite-${{ env.R_LIBS_USER }}-${{
hashFiles('tools.csv') }}) and replace the env.R_LIBS_USER portion with a fixed
runner token like the OS label (or another intentional discriminator) while
keeping the hashFiles('tools.csv') part intact.
- Around line 55-60: The composite action step with id
"qualification-environment" currently uses the remote action
"Open-Systems-Pharmacology/Workflows/.github/actions/setup-qualification-environment@main"
which shares the same directory name as the local composite action and can
confuse maintainers; update the step to include a short inline comment
clarifying that this local composite delegates to the upstream action (e.g.,
"delegates to upstream Workflows action that performs actual setup") and
optionally rename the local action directory or the step id to avoid name
collision; also add a TODO note near the if-cache logic warning about potential
double-caching if the upstream action later implements caching.

Comment on lines +69 to +79
# Save the prepared environment so subsequent runs can skip setup
- name: Save setup cache
if: steps.cache-setup.outputs.cache-hit != 'true'
continue-on-error: true
uses: actions/cache/save@v5
with:
key: ${{ env.CACHE_KEY }}
path: |
${{ env.R_LIBS_USER }}
${{ github.workspace }}/PK-Sim
${{ github.workspace }}/QualificationRunner

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When executing a workflow with >= 2 models (resp. >= 2 qualifications) for the first time from a branch (so that no cache exists yet) - each of these parallel jobs will try to save the cache with the same cache key.
N-1 jobs will not be able to do this because the cache was already created by the 1st job. Which is OK and can be safely ignored. So adding continue-on-error: true here.
The job will then produce a warning like below and continue:

Image

- name: Configure git, set cache key
run: |
git config --global core.longpaths true
echo "CACHE_KEY=ospsuite-${{ env.R_LIBS_USER }}-${{ hashFiles('tools.csv') }}" >> $GITHUB_ENV

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined the variable R_LIBS_USER in the previous step and not here, because the value of the environment GHA variable can be evaluated only in the next GHA step (pretty weird)

@Yuri05 Yuri05 merged commit 7fb6e37 into Open-Systems-Pharmacology:main Feb 23, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caching does not work

2 participants