-
-
Notifications
You must be signed in to change notification settings - Fork 1k
124 lines (106 loc) · 3.83 KB
/
tests.yml
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
name: CI
on:
push:
branches:
- master
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
tests:
strategy:
matrix:
os:
- macOS-latest
- ubuntu-latest
- windows-latest
include:
- os: macOS-latest
shell: bash
- os: ubuntu-latest
shell: bash
- os: windows-latest
shell: wsl -- dos2unix <"$(wslpath '{0}')" | bash --noprofile --norc -euo pipefail
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Set up Git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Cleanup macOS
if: runner.os == 'macOS'
run: |
sudo rm -rf /Applications/Xcode.app \
/Library/Developer/CommandLineTools
sudo xcode-select --reset
- name: Set up WSL
if: runner.os == 'Windows'
shell: powershell
run: |
wsl --update
wsl --version
wsl --set-default-version 2
# `wsl --install Ubuntu-22.04 --no-launch` has been having issues in CI since 2024-06-14
Invoke-WebRequest https://github.com/microsoft/WSL/raw/master/distributions/DistributionInfo.json |
Select-Object -ExpandProperty Content |
ConvertFrom-JSON |
Select-Object -ExpandProperty Distributions |
Where-Object Name -EQ "Ubuntu-22.04" |
Select-Object -ExpandProperty Amd64PackageUrl |
% { Invoke-WebRequest $_ -OutFile Ubuntu2204.appx }
Add-AppxPackage Ubuntu2204.appx
ubuntu2204 install --root
wsl --set-default Ubuntu-22.04
wsl --list --verbose
wsl --exec apt-get update
wsl --exec apt-get install -y --no-install-recommends build-essential dos2unix
wsl --exec /usr/sbin/useradd --create-home runner
wsl -- --% echo "runner ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/runner
ubuntu2204 config --default-user runner
echo "WSLENV=CI:GITHUB_ACTIONS:RUNNER_OS:GITHUB_PATH/p" >> $env:GITHUB_ENV # allow some basic envs to be passed in
- name: Check Bash 3.x syntax
if: runner.os == 'macOS'
run: |
/bin/bash -u -n install.sh
/bin/bash -u -O extglob -n uninstall.sh
- name: Set up Homebrew PATH
run: |
if [[ "${RUNNER_OS}" = "macOS" ]]
then
echo "/usr/local/bin:/usr/bin:/bin" >> "${GITHUB_PATH}"
elif [[ "${RUNNER_OS}" = "Windows" ]]
then
echo "$(wslpath -w /home/linuxbrew/.linuxbrew/bin)" >> "${GITHUB_PATH}"
else
echo "/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin" >> "${GITHUB_PATH}"
fi
- name: Uninstall GitHub Actions Homebrew
run: |
if which brew &>/dev/null
then
/bin/bash uninstall.sh -n >/dev/null
/bin/bash uninstall.sh -f >/dev/null
fi
- run: /bin/bash -c "$(cat install.sh)"
- run: brew config
- run: brew install ack
- run: /bin/bash uninstall.sh -f >/dev/null
- run: /bin/bash -c "$(cat install.sh)"
- name: Uninstall and reinstall with sudo NOPASSWD
if: runner.os == 'Linux'
run: |
echo "${USER} ALL=(ALL) NOPASSWD:ALL" | sudo tee "/etc/sudoers.d/${USER}"
/bin/bash uninstall.sh -f >/dev/null
/bin/bash -c "$(cat install.sh)"
- name: Check code styles
run: |
brew install shellcheck shfmt diffutils
brew style *.sh
- run: /bin/bash uninstall.sh -n >/dev/null
- run: /bin/bash uninstall.sh -f >/dev/null