Skip to content

Use dynamic matrix for CI testing #5

Use dynamic matrix for CI testing

Use dynamic matrix for CI testing #5

Workflow file for this run

name: CI
on:
pull_request:
branches: [ '**' ]
push:
branches: [ "master" ]
tags: [ "v*" ]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs:
discover:
runs-on: ubuntu-latest
outputs:
test-targets: ${{ steps.get-targets.outputs.targets }}
steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: temurin:11
- name: Get test targets
id: get-targets
run: |
TARGETS=$(./mill resolve __.test --no-server | grep -v "^===" | jq -R -s -c 'split("\n")[:-1]')
echo "targets=$TARGETS" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
needs: discover
strategy:
matrix:
target: ${{ fromJson(needs.discover.outputs.test-targets) }}
steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: temurin:11
- name: Test ${{ matrix.target }}
run: ./mill --no-server ${{ matrix.target }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: always() # always run even if the previous step fails
with:
detailed_summary: true
annotate_only: true
report_paths: 'out/**/test-report.xml'
publish:
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: temurin:11
- name: Publish
run: ./mill --no-server --jobs 0 mill.scalalib.SonatypeCentralPublishModule/
env:
MILL_PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
MILL_PGP_SECRET_BASE64: ${{ secrets.PGP_SECRET }}
MILL_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MILL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}