-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaction.yml
More file actions
163 lines (147 loc) · 5.86 KB
/
Copy pathaction.yml
File metadata and controls
163 lines (147 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: "Test supported GHC versions"
description: "Generate a test matrix from your cabal file's `tested-with` stanza"
inputs:
cabal-file:
description: "The path to your cabal file, e.g. somefolder/myproject.cabal"
required: true
version:
description: "Version of the get-tested tool"
required: false
default: ""
windows:
description: "Enable Windows runner, latest version"
required: false
default: 'false'
deprecationMessage: "Please use 'windows-version: latest' instead."
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, latest version"
required: false
default: 'false'
deprecationMessage: "Please use 'macos-version: latest' instead."
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, latest version"
required: false
default: 'false'
deprecationMessage: "Please use 'ubuntu-version: latest' instead."
ubuntu-version:
description: "Enable Ubuntu runner. If both `ubuntu` and `ubuntu-version` inputs are set, the explicit version will take priority"
required: false
default: ""
newest:
description: "Enable only the newest GHC version found in the cabal file"
required: false
default: 'false'
oldest:
description: "Enable only the oldest GHC version found in the cabal file"
required: false
default: 'false'
versions-only:
description: "Return the list of version only"
required: false
default: 'false'
outputs:
matrix:
description: "The GHC version matrix"
value: ${{ steps.set-matrix.outputs.matrix }}
runs:
using: "composite"
steps:
- name: Checkout base repo
uses: actions/checkout@v7
# The following does not work:
#
# uses: Kleidukos/get-tested/setup-get-tested@${{ github.action_ref }}
#
# See: https://github.com/actions/runner/issues/895
- name: Set up get-tested
uses: Kleidukos/get-tested/setup-get-tested@449950cc728817063e27a6731e3ae6589e980870
with:
version: ${{ inputs.version }}
- name: Set up OS options
shell: bash
run: |
set_versions() {
local name="$1" # UBUNTU / WINDOWS / MACOS
local flag="$2" # --ubuntu-version
local versions="$3" # "latest,18.04"
local legacy="$4" # true/false
local legacy_flag="$5" # --ubuntu
local result=""
if [[ -n "$versions" ]]; then
IFS=',' read -ra arr <<< "$versions"
for v in "${arr[@]}"; do
v="${v#"${v%%[![:space:]]*}"}"
v="${v%"${v##*[![:space:]]}"}"
result+=" $flag $v"
done
elif [[ "$legacy" == "true" ]]; then
echo "::warning title=Legacy option::$name legacy flag used"
result="$legacy_flag"
fi
echo "$name=$result" >> "$GITHUB_ENV"
}
set_versions "UBUNTU" "--ubuntu-version" "${{ inputs.ubuntu-version }}" "${{ inputs.ubuntu }}" "--ubuntu"
set_versions "WINDOWS" "--windows-version" "${{ inputs.windows-version }}" "${{ inputs.windows }}" "--windows"
set_versions "MACOS" "--macos-version" "${{ inputs.macos-version }}" "${{ inputs.macos }}" "--macos"
- name: Set up `oldest` and `newest` options
shell: bash
run: |
echo "::debug::Is --newest enabled: ${{ inputs.newest }}"
echo "::debug::Is --oldest enabled: ${{ inputs.oldest }}"
if [[ "${{ inputs.oldest }}" == "true" && "${{ inputs.newest }}" == "true" ]]; then
echo "::error title=Incompatible options::You cannot use the 'oldest' and 'newest' options together!"
exit 1
fi
if [[ "${{ inputs.oldest }}" == "true" ]]
then
echo "::debug::oldest version enabled"
echo "RELATIVE_VERSION=--oldest" >> "$GITHUB_ENV"
elif [[ "${{ inputs.newest }}" == "true" ]]
then
echo "::debug::newest version enabled"
echo "RELATIVE_VERSION=--newest" >> "$GITHUB_ENV"
else
echo "::debug::No relative version selected"
fi
- name: Extract the tested GHC versions
id: set-matrix
shell: bash
run: |
requested_version="${{ inputs.version }}"
minium_modern_version="0.1.9.0"
version_only_min_version="0.1.10.0~rc2"
versions_only="${{ inputs.versions-only }}"
normalized_requested="$(echo "$requested_version" | sed 's/-rc/~rc/')"
head-or-default () {
[[ "$requested_version" == "" ]] || [[ "$requested_version" == "get-tested-head" ]]
}
if [[ "$versions_only" == "true" ]] && { head-or-default || dpkg --compare-versions "$normalized_requested" ge "$version_only_min_version"; }; then
set -x
./get-tested $RELATIVE_VERSION "${{ inputs.cabal-file }}"
{ set +x; } 2>/dev/null
exit 0
fi
if [[ "$WINDOWS" == "" ]] && [[ "$MACOS" == "" ]] && [[ "$UBUNTU" == "" ]]; then
echo "At least one runner needed, please check the README.md in the get-tested repo"
exit 1
fi
if [[ "$requested_version" == "" ]] || [[ "$requested_version" == "get-tested-head" ]] || dpkg --compare-versions "$normalized_requested" ge "$minium_modern_version"; then
set -x
./get-tested $WINDOWS $MACOS $UBUNTU $RELATIVE_VERSION "${{ inputs.cabal-file }}"
{ set +x; } 2>/dev/null
else
set -x
./get-tested $WINDOWS $MACOS $UBUNTU $RELATIVE_VERSION "${{ inputs.cabal-file }}" >> "$GITHUB_OUTPUT"
{ set +x; } 2>/dev/null
fi
branding:
icon: 'list'
color: 'blue'