Im my CI.yml file I have:
matrix:
version:
- '1.10'
- '1'
- 'pre'
This is intended. I want to test with the latest stable Julia release, the latest Julia release and any upcoming beta version (pre-release).
But if there is no pre-release (like in the moment), then this runs the tests twice with the same Julia version (1.11).
How can this be avoided?
You can have an if: condition
entry in the job spec which says (in pseudo code) “if version == "pre"
and the actual Julia version is 1.11.* then skip”. I’m on my phone and don’t know the correct syntax off-hand.
2 Likes
I don’t think that’d work that way, matrix.version
is just a string, github has no idea what that resolves to in the julia-actions/setup
workflow.
I got a suggestion from perplexity.ai, but it looks very complicated:
https://www.perplexity.ai/search/im-my-ci-yml-file-i-have-matri-dFge.CLiSemYW3qaHBlH.w
First, create a job to determine the available Julia versions:
jobs:
check_versions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Get Julia versions
id: versions
run: |
STABLE=$(curl -s https://julialang-s3.julialang.org/bin/versions.json | jq -r '.stable.version')
LATEST=$(curl -s https://julialang-s3.julialang.org/bin/versions.json | jq -r '.latest.version')
PRE=$(curl -s https://julialang-s3.julialang.org/bin/versions.json | jq -r '.pre.version')
echo "STABLE=$STABLE" >> $GITHUB_OUTPUT
echo "LATEST=$LATEST" >> $GITHUB_OUTPUT
echo "PRE=$PRE" >> $GITHUB_OUTPUT
- name: Set matrix
id: set-matrix
run: |
if [ "${{ steps.versions.outputs.PRE }}" != "null" ] && [ "${{ steps.versions.outputs.PRE }}" != "${{ steps.versions.outputs.LATEST }}" ]; then
echo "matrix={\"version\":[\"${{ steps.versions.outputs.STABLE }}\",\"${{ steps.versions.outputs.LATEST }}\",\"${{ steps.versions.outputs.PRE }}\"]}" >> $GITHUB_OUTPUT
else
echo "matrix={\"version\":[\"${{ steps.versions.outputs.STABLE }}\",\"${{ steps.versions.outputs.LATEST }}\"]}" >> $GITHUB_OUTPUT
fi
Then, modify your test job to use the dynamically generated matrix:
test:
needs: check_versions
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.check_versions.outputs.matrix)}}
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- name: Run tests
run: julia --project=@. -e 'using Pkg; Pkg.test()'
But this is not yet working. What am I doing wrong?
ufechner@ufryzen:~$ STABLE=$(curl -s https://julialang-s3.julialang.org/bin/versions.json | jq -r '.stable.version')
ufechner@ufryzen:~$ echo $STABLE
null
If I look at the versions.json
file it is not obvious how to determine the latest stable version… A lot of versions are marked as stable.