# How to improve CI.yml to avoid running a test-set twice

**URL:** <https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258>\
**Category:** General Usage\
**Tags:** question, ci\
**Created:** [March 22, 2025, 10:39am UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258 "2025-03-22T10:39:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 22, 2025, 10:39am UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258/1 "2025-03-22T10:39:15Z")

</div>

Im my CI.yml file I have:

```julia
      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?

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [March 22, 2025, 12:28pm UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258/2 "2025-03-22T12:28:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 24, 2025, 4:33am UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258/3 "2025-03-24T04:33:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 24, 2025, 8:22am UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258/4 "2025-03-24T08:22:41Z")

</div>

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](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:

```yaml
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:

```yaml
  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()'

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 24, 2025, 10:33am UTC](https://discourse.julialang.org/t/how-to-improve-ci-yml-to-avoid-running-a-test-set-twice/127258/5 "2025-03-24T10:33:29Z")

</div>

But this is not yet working. What am I doing wrong?

```julia
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.
