Skip to content

Commit ccda2b4

Browse files
authored
Refactor Github Actions (#264)
* Deprecate coverage action inputs They are no longer used. 1. To generate code coverage reports latest available coverage package is installed as library by ST (requires Package Control!). Coverage reports are created from within ST's plugin environment. 2. Coverage reports are to be uploaded via via codecov action, which has to deal with installing required coverage python packages itself. * Drop obsolete package recovery Package Control is configured not to auto-update or touch any package. Restoring something after installing Package Control is obsolete. * Add step names * Don't start ST after installing Starting and stopping ST is just a waste of time. It will be started to install Package Control. * Enable coverage on MacOS * Deprecate install-unittesting action input 1. Allowing to not install UnitTesting is odd as tests won't run without it. 2. Installing a version which is unrelated with current action revision is also odd and confusing. If a certain version is desired for CI, it can be selected via `SublimeText/UnitTesting/actions/setup@<revision>`. The `setup` action always installs the UnitTesting package, which is bundled with the action's revision, if UnitTesting is not the checked out package or hasn't been installed as extra-package. That's possible as the action is part of UnitTesting package. The package doesn't need to be re-downloaded. * Refactor setup steps * On demand download Package Control This commit prevents Package Control.sublime-package from being downloaded and installed, if Package Control folder already exists as extracted package. This may be the case if it is the package to test or was installed via `extra-packages` input.
1 parent b9d7ae6 commit ccda2b4

5 files changed

Lines changed: 110 additions & 131 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ jobs:
3131
- uses: "./actions/setup"
3232
with:
3333
sublime-text-version: ${{ matrix.st-version }}
34-
install-unittesting: false
3534
- uses: "./actions/run-tests"
3635
with:
3736
coverage: true
38-
- if: runner.os == 'Windows' || runner.os == 'Linux'
39-
uses: codecov/codecov-action@v4
37+
- uses: codecov/codecov-action@v4
4038
with:
4139
token: ${{secrets.CODECOV_TOKEN}}
4240

@@ -62,8 +60,6 @@ jobs:
6260
steps:
6361
- uses: actions/checkout@v4
6462
- uses: SublimeText/UnitTesting/actions/setup@v1
65-
with:
66-
install-unittesting: false
6763
- uses: SublimeText/UnitTesting/actions/run-tests@v1
6864

6965
test-as-extra-package:
@@ -83,7 +79,6 @@ jobs:
8379
- uses: "./UnitTesting/actions/setup"
8480
with:
8581
package-path: UnitTesting-example
86-
install-unittesting: false
8782
extra-packages: |
8883
SublimeText/UnitTesting
8984
- uses: "./UnitTesting/actions/run-tests"

actions/setup/action.yaml

Lines changed: 107 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ inputs:
2121
required: true
2222
default: './'
2323
install-unittesting:
24-
description: Whether to install UnitTesting.
24+
description: Whether to install UnitTesting (DEPRECATED, replaced by SublimeText/UnitTesting/actions/setup@ref).
2525
required: true
2626
default: true
2727
unittesting-version:
28-
description: Version of UnitTesting. Use latest release if empty.
28+
description: Version of UnitTesting (DEPRECATED, replaced by SublimeText/UnitTesting/actions/setup@ref).
2929
required: false
3030
default: ''
3131
install-coverage:
32-
description: Whether to install coverage.
32+
description: Whether to install coverage (DEPRECATED, no longer used).
3333
required: true
3434
default: true
3535
coverage-version:
36-
description: Version of coverage. Use latest release if empty.
36+
description: Version of coverage (DEPRECATED, no longer used).
3737
required: false
3838
default: ''
3939
install-package-control:
@@ -58,103 +58,105 @@ inputs:
5858
runs:
5959
using: 'composite'
6060
steps:
61-
- name: Set environmental variables
61+
- name: Setup Environment Variables
6262
run: |
63-
echo "SUBLIME_TEXT_VERSION=${{ inputs.sublime-text-version }}" >> $GITHUB_ENV
64-
echo "SUBLIME_TEXT_ARCH=${{ inputs.sublime-text-arch }}" >> $GITHUB_ENV
65-
shell: bash
66-
- name: Setup SUBLIME_TEXT_PACKAGES
67-
run: |
68-
if [ $SUBLIME_TEXT_VERSION -ge 4 ]; then
69-
if [ $(uname) = 'Darwin' ]; then
70-
STP="$HOME/Library/Application Support/Sublime Text/Packages"
71-
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
72-
STP="$HOME/.config/sublime-text/Packages"
73-
else
74-
STP="/c/st/Data/Packages/"
75-
fi
76-
else
77-
if [ $(uname) = 'Darwin' ]; then
78-
STP="$HOME/Library/Application Support/Sublime Text $SUBLIME_TEXT_VERSION/Packages"
79-
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
80-
STP="$HOME/.config/sublime-text-$SUBLIME_TEXT_VERSION/Packages"
81-
else
82-
STP="/c/st/Data/Packages/"
83-
fi
84-
fi
85-
echo "SUBLIME_TEXT_PACKAGES=$STP" >> $GITHUB_ENV
86-
shell: bash
87-
- run: |
8863
if [ "${{ runner.os }}" = "Windows" ]; then
8964
echo "c:\st" >> $GITHUB_PATH
9065
else
9166
echo "$HOME/.local/bin" >> $GITHUB_PATH
9267
fi
68+
case ${{ inputs.sublime-text-version }} in
69+
3)
70+
case ${{ runner.os }} in
71+
Linux)
72+
STP="$HOME/.config/sublime-text-${{ inputs.sublime-text-version }}/Packages";;
73+
macOS)
74+
STP="$HOME/Library/Application Support/Sublime Text ${{ inputs.sublime-text-version }}/Packages";;
75+
Windows)
76+
STP="/c/st/Data/Packages/";;
77+
*)
78+
exit 1
79+
esac;;
80+
4)
81+
case ${{ runner.os }} in
82+
Linux)
83+
STP="$HOME/.config/sublime-text/Packages";;
84+
macOS)
85+
STP="$HOME/Library/Application Support/Sublime Text/Packages";;
86+
Windows)
87+
STP="/c/st/Data/Packages/";;
88+
*)
89+
exit 1
90+
esac;;
91+
*)
92+
exit 1
93+
esac
94+
echo "SUBLIME_TEXT_PACKAGES=$STP" >> $GITHUB_ENV
95+
echo "SUBLIME_TEXT_ARCH=${{ inputs.sublime-text-arch }}" >> $GITHUB_ENV
96+
echo "SUBLIME_TEXT_VERSION=${{ inputs.sublime-text-version }}" >> $GITHUB_ENV
9397
shell: bash
94-
- if: runner.os == 'Linux'
98+
- name: Setup Graphical User Interface
99+
if: runner.os == 'Linux'
95100
run: |
96101
sudo bash $GITHUB_ACTION_PATH/install_ubuntu_sys_req.sh
97102
echo "DISPLAY=:1" >> $GITHUB_ENV
98-
99-
if [ "${{ inputs.display }}" = "xvfb" ]; then
100-
sudo apt-get install xvfb
101-
elif [ "${{ inputs.display }}" = "turbovnc" ]; then
102-
wget https://phoenixnap.dl.sourceforge.net/project/turbovnc/2.2.5/turbovnc_2.2.5_amd64.deb
103-
sudo dpkg -i turbovnc_2.2.5_amd64.deb
104-
echo "/opt/TurboVNC/bin" >> $GITHUB_PATH
105-
fi
106-
if [ "${{ inputs.display }}" != "false" ]; then
107-
if [ "${{ inputs.window-manager }}" = "xfce" ]; then
108-
sudo apt-get install --no-install-recommends xfce4 xfce4-goodies dbus-x11
109-
elif [ "${{ inputs.window-manager }}" = "icewm" ]; then
110-
sudo apt-get install icewm
111-
elif [ "${{ inputs.window-manager }}" = "fluxbox" ]; then
112-
sudo apt-get install fluxbox
113-
fi
114-
fi
115-
shell: bash
116-
- if: runner.os == 'Linux'
117-
run: |
118-
if [ "${{ inputs.display }}" = "xvfb" ]; then
119-
Xvfb $DISPLAY -screen 0 1024x768x24 -ac +extension GLX +render -noreset &
120-
sleep 1
121-
if [ "${{ inputs.window-manager }}" = "xfce" ]; then
122-
nohup startxfce4 &
123-
elif [ "${{ inputs.window-manager }}" = "icewm" ]; then
124-
nohup icewm &
125-
elif [ "${{ inputs.window-manager }}" = "fluxbox" ]; then
126-
nohup fluxbox &
127-
fi
128-
elif [ "${{ inputs.display }}" = "turbovnc" ]; then
129-
mkdir $HOME/.vnc
130-
echo $RANDOM$RANDOM | vncpasswd -f > $HOME/.vnc/passwd
131-
chmod 0600 $HOME/.vnc/passwd
132-
if [ "${{ inputs.window-manager }}" = "xfce" ]; then
133-
vncserver $DISPLAY -geometry 1024x768 -depth 24 -wm "startxfce4"
134-
elif [ "${{ inputs.window-manager }}" = "false" ]; then
135-
vncserver $DISPLAY -geometry 1024x768 -depth 24
136-
else
137-
vncserver $DISPLAY -geometry 1024x768 -depth 24 -wm "${{ inputs.window-manager }}"
138-
fi
139-
fi
103+
# install display driver
104+
case ${{ inputs.display }} in
105+
xvfb)
106+
sudo apt-get install xvfb ;;
107+
turbovnc)
108+
wget https://phoenixnap.dl.sourceforge.net/project/turbovnc/2.2.5/turbovnc_2.2.5_amd64.deb
109+
sudo dpkg -i turbovnc_2.2.5_amd64.deb
110+
echo "/opt/TurboVNC/bin" >> $GITHUB_PATH
111+
esac
112+
# install window manager
113+
case ${{ inputs.window-manager }} in
114+
fluxbox|icewm)
115+
sudo apt-get install ${{ inputs.window-manager }} ;;
116+
xfce)
117+
sudo apt-get install --no-install-recommends xfce4 xfce4-goodies dbus-x11 ;;
118+
esac
140119
shell: bash
141-
- if: runner.os == 'Linux' || runner.os == 'macOS'
120+
- name: Start Graphical User Interface
121+
if: runner.os == 'Linux'
142122
run: |
143-
bash $GITHUB_ACTION_PATH/install_sublime_text.sh
123+
case ${{ inputs.display }} in
124+
xvfb)
125+
Xvfb $DISPLAY -screen 0 1024x768x24 -ac +extension GLX +render -noreset &
126+
sleep 1
127+
case ${{ inputs.window-manager }} in
128+
fluxbox|icewm)
129+
nohup ${{ inputs.window-manager }} & ;;
130+
xfce)
131+
nohup startxfce4 & ;;
132+
esac ;;
133+
turbovnc)
134+
mkdir $HOME/.vnc
135+
echo $RANDOM$RANDOM | vncpasswd -f > $HOME/.vnc/passwd
136+
chmod 0600 $HOME/.vnc/passwd
137+
case ${{ inputs.window-manager }} in
138+
false)
139+
vncserver $DISPLAY -geometry 1024x768 -depth 24 ;;
140+
fluxbox|icewm)
141+
vncserver $DISPLAY -geometry 1024x768 -depth 24 -wm "${{ inputs.window-manager }}" ;;
142+
xfce)
143+
vncserver $DISPLAY -geometry 1024x768 -depth 24 -wm "startxfce4" ;;
144+
esac
145+
esac
144146
shell: bash
145-
- if: runner.os == 'Windows'
147+
- name: Install Sublime Text
146148
run: |
147-
pwsh $Env:GITHUB_ACTION_PATH/install_sublime_text.ps1 --verbose
148-
shell: pwsh
149-
- run: |
150-
# Disable warnings about detached HEAD
151-
# https://stackoverflow.com/questions/36794501
152-
git config --global advice.detachedHead false
153-
149+
# download and install Sublime Text
150+
if [ "${{ runner.os }}" = "Windows" ]; then
151+
pwsh $GITHUB_ACTION_PATH/install_sublime_text.ps1 --verbose;
152+
else
153+
bash $GITHUB_ACTION_PATH/install_sublime_text.sh;
154+
fi
154155
# block sublime text website ip
155156
bash $GITHUB_ACTION_PATH/block_ip.sh
156157
shell: bash
157-
- run: |
158+
- name: Determine Test Package
159+
run: |
158160
REPO="$GITHUB_REPOSITORY"
159161
if [ "${{ inputs.install-package }}" = "true" ]; then
160162
cd "${{ inputs.package-path }}"
@@ -170,26 +172,29 @@ runs:
170172
171173
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
172174
shell: bash
173-
- run: |
175+
- name: Install Packages
176+
run: |
177+
# Disable warnings about detached HEAD
178+
# https://stackoverflow.com/questions/36794501
179+
git config --global advice.detachedHead false
180+
174181
. $GITHUB_ACTION_PATH/utils.sh
175182
176183
# Copy plugin files to Packages/<Package> folder if files are checked out.
177184
if [ "${{ inputs.install-package }}" = "true" ]; then
178185
cd "${{ inputs.package-path }}"
179186
if [ -d "./.git" ] && [ ! -d "$SUBLIME_TEXT_PACKAGES/$PACKAGE" ]; then
180187
# symlink does not play well with coverage
181-
echo "copy the package to sublime package directory"
188+
echo "Copy checked out package '$PACKAGE' to $SUBLIME_TEXT_PACKAGES/$PACKAGE"
182189
mkdir -p "$SUBLIME_TEXT_PACKAGES/$PACKAGE"
183190
cp -r ./ "$SUBLIME_TEXT_PACKAGES/$PACKAGE"
184191
# detached head will crash package control
185192
rm -rf "$SUBLIME_TEXT_PACKAGES/$PACKAGE/.git"
186193
fi
187194
cd -
188195
fi
189-
if [ "${{ inputs.install-unittesting }}" = "true" ]; then
190-
InstallPackage "UnitTesting" "https://github.com/SublimeText/UnitTesting" "${{ inputs.unittesting-version }}"
191-
fi
192196
197+
# Install extra packages to to Packages/<Package>
193198
while read -r x; do
194199
if [[ "$x" =~ ^(.*):(.*)/([^@]*)@?(.*)$ ]]; then
195200
PKG="${BASH_REMATCH[1]}"
@@ -206,25 +211,20 @@ runs:
206211
fi
207212
InstallPackage "$PKG" "https://github.com/$USER/$REPO" "$SHA"
208213
done <<< "${{ inputs.extra-packages }}"
214+
215+
# Install UnitTesting to Packages/UnitTesting if not yet exists
216+
if [ ! -d "$SUBLIME_TEXT_PACKAGES/UnitTesting" ]; then
217+
echo "Copy action's 'UnitTesting' to $SUBLIME_TEXT_PACKAGES/UnitTesting"
218+
mkdir -p "$SUBLIME_TEXT_PACKAGES/UnitTesting"
219+
cp -r "$GITHUB_ACTION_PATH/../../" "$SUBLIME_TEXT_PACKAGES/UnitTesting"
220+
fi
209221
shell: bash
210-
- if: (runner.os == 'Linux' || runner.os == 'macOS') && inputs.install-package-control == 'true'
211-
run: |
212-
bash $GITHUB_ACTION_PATH/install_package_control.sh
213-
shell: bash
214-
- if: runner.os == 'Windows' && inputs.install-package-control == 'true'
222+
- name: Install Package Control
223+
if: inputs.install-package-control == 'true'
215224
run: |
216-
pwsh $Env:GITHUB_ACTION_PATH/install_package_control.ps1 --verbose
217-
shell: pwsh
218-
- run: |
219-
if [ "${{ inputs.install-package }}" = "true" ]; then
220-
# package control may have updated the checked out repo, we need to restore it
221-
if [ -f "$SUBLIME_TEXT_PACKAGES/$PACKAGE/dependency-metadata.json" ]; then
222-
cd "${{ inputs.package-path }}"
223-
rm -rf "$SUBLIME_TEXT_PACKAGES/$PACKAGE"
224-
cp -r ./ "$SUBLIME_TEXT_PACKAGES/$PACKAGE"
225-
rm -rf "$SUBLIME_TEXT_PACKAGES/$PACKAGE/.git"
226-
touch "$SUBLIME_TEXT_PACKAGES/$PACKAGE/.sublime-dependency"
227-
cd -
228-
fi
225+
if [ "${{ runner.os }}" = "Windows" ]; then
226+
pwsh $GITHUB_ACTION_PATH/install_package_control.ps1 --verbose;
227+
else
228+
bash $GITHUB_ACTION_PATH/install_package_control.sh;
229229
fi
230230
shell: bash

actions/setup/install_package_control.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $STPU = "C:\st\Data\Packages\User"
1313
New-Item -itemtype directory $STPU -force >$null
1414

1515
$PC_PATH = "$STIP\Package Control.sublime-package"
16-
if (-not (Test-Path $PC_PATH)) {
16+
if (-not (Test-Path $PC_PATH) -and -not (Test-Path "$STP\Package Control")) {
1717
Write-Verbose "Downloading Package Control.sublime-package"
1818
$PC_URL = "https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
1919
(New-Object System.Net.WebClient).DownloadFile($PC_URL, $PC_PATH)

actions/setup/install_package_control.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if [ ! -d "$STIP" ]; then
4242
fi
4343

4444
PC_PATH="$STIP/Package Control.sublime-package"
45-
if [ ! -f "$PC_PATH" ]; then
45+
if [ ! -f "$PC_PATH" ] && [ ! -d "$STP/Package Control" ]; then
4646
echo Downloading Package Control.sublime-package
4747
PC_URL="https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
4848
curl -s -L "$PC_URL" -o "$PC_PATH"

actions/setup/install_sublime_text.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ if [ $(uname) = 'Darwin' ]; then
110110
# See https://github.com/SublimeText/UnitTesting/issues/200
111111
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
112112
-f "$HOME/Applications/$SUBLIME_TEXT.app"
113-
114-
# make `subl` available
115-
open "$HOME/Applications/$SUBLIME_TEXT.app"
116-
sleep 2
117-
pkill '[Ss]ubl' || true
118-
pkill 'plugin_host' || true
119-
sleep 2
120113
else
121114
echo "Sublime Text was installed already!"
122115
exit 1
@@ -156,21 +149,12 @@ else
156149
fi
157150
done
158151
if [ $SUBLIME_TEXT_VERSION -ge 4 ]; then
159-
# FIXME, move it to DOckerfile
160-
sudo apt-get install -y xz-utils
161152
tar xf ~/sublimetext.tar.xz -C ~/
162153
else
163154
tar jxf ~/sublimetext.tar.bz2 -C ~/
164155
fi
165156
mkdir -p $HOME/.local/bin
166157
ln -sf "$HOME/$SUBLIME_TEXT/sublime_text" $HOME/.local/bin/subl
167-
168-
# make `subl` available
169-
"$HOME/$SUBLIME_TEXT/sublime_text" &
170-
sleep 2
171-
pkill '[Ss]ubl' || true
172-
pkill 'plugin_host' || true
173-
sleep 2
174158
else
175159
echo "Sublime Text was installed already!"
176160
exit 1

0 commit comments

Comments
 (0)