|
| 1 | +################################################################################################### |
| 2 | +### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH RPM RUNNER ### |
| 3 | +### HOW TO USE: ### |
| 4 | +### `version` is the expected Scala version; the installed scala/scalac/scaladoc ### |
| 5 | +### are asserted to report it, then a program is compiled and run. ### |
| 6 | +### NOTE: Requires `scala.rpm` artifact uploaded within the same run ### |
| 7 | +### ### |
| 8 | +################################################################################################### |
| 9 | + |
| 10 | +name: Test 'scala' RPM Package |
| 11 | +run-name: Test 'scala' (${{ inputs.version }}) RPM Package |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + version: |
| 17 | + required: true |
| 18 | + type: string |
| 19 | + |
| 20 | +jobs: |
| 21 | + test: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + image: |
| 27 | + - fedora:43 |
| 28 | + - fedora:latest |
| 29 | + - almalinux:9 |
| 30 | + - almalinux:10 |
| 31 | + - opensuse/leap:16.0 |
| 32 | + - opensuse/tumbleweed |
| 33 | + container: ${{ matrix.image }} |
| 34 | + env: |
| 35 | + VERSION: ${{ inputs.version }} |
| 36 | + steps: |
| 37 | + - name: Download rpm artifact |
| 38 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 39 | + with: |
| 40 | + name: scala.rpm |
| 41 | + path: . |
| 42 | + |
| 43 | + - name: Install Scala Runner |
| 44 | + run: | |
| 45 | + if command -v dnf >/dev/null; then |
| 46 | + dnf install -y ./scala.rpm |
| 47 | + elif command -v zypper >/dev/null; then |
| 48 | + zypper --non-interactive --gpg-auto-import-keys refresh |
| 49 | + zypper --non-interactive install --allow-unsigned-rpm ./scala.rpm |
| 50 | + else |
| 51 | + echo "No supported package manager (dnf/zypper) found"; exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Verify installation layout |
| 55 | + run: | |
| 56 | + set -e |
| 57 | + echo "Checking /usr/bin/scala symlink..." |
| 58 | + test -L /usr/bin/scala |
| 59 | + test "$(readlink -f /usr/bin/scala)" = /usr/share/scala3/bin/scala |
| 60 | +
|
| 61 | + echo "Checking VERSION file..." |
| 62 | + test -f /usr/share/scala3/VERSION |
| 63 | + cat /usr/share/scala3/VERSION |
| 64 | +
|
| 65 | + echo "Checking scala-cli launcher..." |
| 66 | + test -x /usr/share/scala3/libexec/scala-cli |
| 67 | +
|
| 68 | + echo "Checking maven2 directory..." |
| 69 | + test -d /usr/share/scala3/maven2 |
| 70 | +
|
| 71 | + - name: Test Scala Runner |
| 72 | + run: | |
| 73 | + out="$(scala --version)"; echo "$out" |
| 74 | + echo "$out" | grep -qF "Scala version (default): $VERSION" |
| 75 | + - name: Test the `scalac` command |
| 76 | + run: | |
| 77 | + out="$(scalac --version)"; echo "$out" |
| 78 | + echo "$out" | grep -qF "Scala compiler version $VERSION" |
| 79 | + - name: Test the `scaladoc` command |
| 80 | + run: | |
| 81 | + out="$(scaladoc --version)"; echo "$out" |
| 82 | + echo "$out" | grep -qF "Scaladoc version $VERSION" |
| 83 | +
|
| 84 | + - name: Smoke test - compile and run |
| 85 | + run: | |
| 86 | + echo '@main def test() = println("Hello from Scala")' > test.scala |
| 87 | + scala run --server=false test.scala |
| 88 | +
|
| 89 | + - name: Uninstall the `scala` package |
| 90 | + run: | |
| 91 | + if command -v dnf >/dev/null; then |
| 92 | + dnf remove -y scala3 |
| 93 | + elif command -v zypper >/dev/null; then |
| 94 | + zypper --non-interactive remove scala3 |
| 95 | + fi |
0 commit comments