Skip to content

Commit

Permalink
Add new inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Mar 7, 2024
1 parent c2a41c2 commit fa1a2f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
46 changes: 33 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,29 @@ inputs:
description: "Version of the tool"
required: true
windows:
description: "Enable Windows runner"
description: "(legacy) Enable Windows runner, latest version"
required: false
default: false
windows-version:
description: "Enable Windows runner. If both `windows` and `windows-version` inputs are set, the explicit version will take priority"
required: false
default: ""
macos:
description: "Enable macOS runner"
description: "(legacy) Enable macOS runner, latest version"
required: false
default: false
macos-version:
description: "Enable macOS runner. If both `macos` and `macos-version` inputs are set, the explicit version will take priority"
required: false
default: ""
ubuntu:
description: "Enable Ubuntu runner"
description: "(legacy) Enable Ubuntu runner, latest version"
required: false
default: false
ubuntu-version:
description: "Enable Ubuntu runner. If both `ubuntu` and `ubuntu-version` inputs are set, the explicit version will take priority"
required: false
default: ""

outputs:
matrix:
Expand All @@ -34,23 +46,31 @@ runs:
- name: Set up options
shell: bash
run: |
# Extract e.g. 0.1 from /runner/foo/bar/.../v0.1
wget -q https://github.com/Kleidukos/get-tested/releases/download/v${{ inputs.version }}/get-tested-${{ inputs.version }}-linux-amd64 -O get-tested
chmod +x get-tested
echo "::debug:: Windows enabled: ${{ inputs.windows }}"
if [[ ${{ inputs.windows}} = "true" ]]
then echo "WINDOWS=--windows" >> $GITHUB_ENV
if [[ -n ${{ inputs.windows-version}} ]]
echo "::debug:: Windows explicit enabled: ${{ inputs.windows-version }}"
then echo "WINDOWS=\"--windows-version=${{ inputs.windows-version }}\"" >> $GITHUB_ENV
elif [[ ${{ inputs.windows }} == "true" ]]
echo "::debug:: Windows fallback enabled: ${{ inputs.windows }}"
then echo "WINDOWS=--windows" >> $GITHUB_ENV
fi
echo "::debug:: macOS enabled: ${{ inputs.macos }}"
if [[ ${{ inputs.macos}} = "true" ]]
then echo "MACOS=--macos" >> $GITHUB_ENV
if [[ ${{ -n inputs.macos-version}} ]]
echo "::debug:: macOS explicit version enabled: ${{ inputs.macos-version }}"
then echo "MACOS=\"--macos-version=${{ inputs.macos-version }}\"" >> $GITHUB_ENV
elif [[ ${{ inputs.macos }} == "true" ]]
echo "::debug:: macOS fallback enabled: ${{ inputs.macos }}"
then echo "MACOS=--macos" >> $GITHUB_ENV
fi
echo "::debug:: Ubuntu enabled: ${{ inputs.ubuntu }}"
if [[ ${{ inputs.ubuntu}} = "true" ]]
then echo "UBUNTU=--ubuntu" >> $GITHUB_ENV
if [[ ${{ -n inputs.ubuntu-version}} ]]
echo "::debug:: Ubuntu explicit version enabled: ${{ inputs.ubuntu-version }}"
then echo "UBUNTU=\"--ubuntu-version=${{ inputs.ubuntu-version }}\"" >> $GITHUB_ENV
elif [[ ${{ inputs.ubuntu }} == "true" ]]
echo "::debug:: Ubuntu fallback enabled: ${{ inputs.ubuntu }}"
then echo "UBUNTU=--ubuntu" >> $GITHUB_ENV
fi
- name: Extract the tested GHC versions
Expand Down
20 changes: 10 additions & 10 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import Effectful.Error.Static
import Options.Applicative
import System.Exit

import Extract
import Types
import Data.Text (Text)
import Data.Vector (Vector)
import Data.Text.Display (display)
import Data.Vector (Vector)
import Extract
import Types

data Options = Options
{ path :: FilePath
Expand Down Expand Up @@ -55,7 +55,7 @@ runOptions options = do
genericPackageDescription <- loadFile options.path
let supportedCompilers = extractTestedWith genericPackageDescription
filteredList =
processFlag MacOS options.macosFlag options.macosVersion
processFlag MacOS options.macosFlag options.macosVersion
<> processFlag Ubuntu options.ubuntuFlag options.ubuntuVersion
<> processFlag Windows options.windowsFlag options.windowsVersion
pure $
Expand All @@ -70,16 +70,16 @@ withInfo opts desc = info (helper <*> opts) $ progDesc desc

processFlag
:: RunnerOS
-- ^ OS flag we're processing
-- ^ OS flag we're processing
-> Bool
-- ^ explicit version
-- ^ explicit version
-> Maybe Text
-- ^ legacy fallback
-- ^ legacy fallback
-> Vector Text
processFlag runnerOS legacyFallback mExplicitVersion =
processFlag runnerOS legacyFallback mExplicitVersion =
case mExplicitVersion of
Just explicitVersion -> Vector.singleton (display runnerOS <> "-" <> explicitVersion)
Nothing ->
if legacyFallback
then Vector.singleton $ display runnerOS <> "-latest"
else Vector.empty
then Vector.singleton $ display runnerOS <> "-latest"
else Vector.empty
4 changes: 2 additions & 2 deletions app/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ data ProcessingError
(Display)
via ShowInstance ProcessingError

data RunnerOS
data RunnerOS
= Ubuntu
| Windows
| Windows
| MacOS
deriving stock (Eq, Ord, Show)

Expand Down

0 comments on commit fa1a2f5

Please sign in to comment.