1+ # ##################################################################################################
2+ # ##                  THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH MSI RUNNER                  ###
3+ # ## HOW TO USE:                                                                                 ###
4+ # ##  Provide optional `version` to test if installed binaries are installed with                ###
5+ # ##  correct Scala version.                                                                     ###
6+ # ## NOTE: Requires `scala.msi` artifact uploaded within the same run                            ###
7+ # ##                                                                                             ###
8+ # ##################################################################################################
9+ 
10+ name : Test 'scala' MSI Package 
11+ run-name : Test 'scala' (${{ inputs.version }}) MSI Package 
12+ 
13+ on :
14+   workflow_call :
15+     inputs :
16+       version :
17+         required : true 
18+         type : string 
19+       java-version :
20+         required : true 
21+         type     : string 
22+ 
23+ jobs :
24+   test :
25+     runs-on : windows-latest 
26+     steps :
27+       - uses : actions/setup-java@v4 
28+         with :
29+           distribution : temurin 
30+           java-version : ${{ inputs.java-version }} 
31+       - name : Download MSI artifact 
32+         uses : actions/download-artifact@v4 
33+         with :
34+           name : scala.msi 
35+           path : . 
36+ 
37+       #  Run the MSI installer
38+       #  During normal installation msiexec would modify the PATH automatically. 
39+       #  However, it seems not to work in GH Actions. Append the PATH manually instead.
40+       - name : Install Scala Runner 
41+         shell : pwsh 
42+         run : | 
43+           Start-Process 'msiexec.exe' -ArgumentList '/I "scala.msi" /L*V "install.log" /qb' -Wait 
44+           Get-Content 'install.log' 
45+           Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\scala\bin" 
46+ 
47+ #  Run tests to ensure the Scala Runner was installed and works
48+       - name : Test Scala Runner 
49+         shell : pwsh 
50+         run : | 
51+           scala --version 
52+           if (-not (scala --version | Select-String "Scala version \(default\): ${{ inputs.version }}")) { 
53+             Write-Host "Invalid Scala version of MSI installed runner, expected ${{ inputs.version }}" 
54+             Exit 1 
55+           } 
56+ name  : Test the `scalac` command 
57+         shell : pwsh 
58+         run : | 
59+           scalac --version 
60+           if (-not (scalac --version | Select-String "Scala compiler version ${{ inputs.version }}")) { 
61+             Write-Host "Invalid scalac version of MSI installed runner, expected ${{ inputs.version }}" 
62+             Exit 1 
63+           } 
64+ name  : Test the `scaladoc` command 
65+         shell : pwsh 
66+         run : | 
67+           scaladoc --version 
68+           if (-not (scaladoc --version | Select-String "Scaladoc version ${{ inputs.version }}")) { 
69+             Write-Host "Invalid scaladoc version of MSI installed runner, expected ${{ inputs.version }}" 
70+             Exit 1 
71+           } 
72+ name  : Uninstall the `scala` package 
73+         shell : pwsh 
74+         run : | 
75+           Start-Process 'msiexec.exe' -ArgumentList '/X "scala.msi" /L*V "uninstall.log" /qb' -Wait 
76+           Get-Content 'uninstall.log' 
77+ 
0 commit comments