diff --git a/README.md b/README.md index 7848551..3a65ddd 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ jobs: ``` By default, the action will evaluate `using Package` where `Package` is the name of the julia repo that the action runs on. -A custom script can be provided by passing `test_script`. Note that both runs should be given the same script +A custom script can be provided by passing `test_script`. If it is necessary to setup alter the environment the code is run in, you can pass a `setup_script` with the necessary Pkg operations. Note that both runs should be given the same script i.e. ```yaml @@ -64,4 +64,5 @@ i.e. id: invs_pr with: test_script: 'using Package; Package.foo(1)' + setup_script: 'using Pkg; Pkg.develop(["Foo", "Bar"])' ``` diff --git a/action.yml b/action.yml index 907306c..ff13feb 100644 --- a/action.yml +++ b/action.yml @@ -30,14 +30,21 @@ runs: TESTSCRIPT=${{ inputs.test_script }} fi echo "testscript=$TESTSCRIPT" >> $GITHUB_OUTPUT + if [[ '${{ inputs.setup_script }}' == '' ]]; then + SETUPSCRIPT="using Pkg;Pkg.develop(\"${PACKAGENAME}\")" + else + SETUPSCRIPT=${{ inputs.setup_script }} + fi + echo "setupscript=$SETUPSCRIPT" >> $GITHUB_OUTPUT shell: bash - name: Install SnoopCompile tools - run: julia --project -e 'using Pkg; Pkg.add(["SnoopCompileCore", "SnoopCompile", "PrettyTables"])' + run: julia 'using Pkg; Pkg.add(["SnoopCompileCore", "SnoopCompile", "PrettyTables"])' shell: bash - name: Load package on branch id: invs run: | + ${{ steps.info.outputs.setupscript }} using SnoopCompileCore invalidations = @snoopr begin ${{ steps.info.outputs.testscript }} end @@ -61,4 +68,4 @@ runs: println(io, "total=$(inv_total)") println(io, "deps=$(inv_deps)") end - shell: julia --color=yes --project=. {0} + shell: julia --color=yes {0}