Skip to content

Synchronize shared configuration #963

Synchronize shared configuration

Synchronize shared configuration #963

Workflow file for this run

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@v4
- name: Cleanup macOS
if: runner.os == 'macOS'
run: |
sudo rm -rf /Applications/Xcode.app \
/Library/Developer/CommandLineTools
sudo xcode-select --reset
- name: Install WSL
if: runner.os == 'Windows'
shell: powershell
run: |
Write-Output "::group::Install Windows Subsystem for Linux"
winget install --name 'Windows Subsystem for Linux' --accept-source-agreements --accept-package-agreements --silent --verbose
Write-Output "::endgroup::"
# Install the new distro
$storeId="9PN20MSR04DW"
$launcher="ubuntu2204.exe"
$appxname="Ubuntu22.04LTS"
# Uninstall pre-existing appx
$pkgFullName = (Get-AppxPackage | Where-Object Name -like "CanonicalGroupLimited.${appxname}").PackageFullName
if ( "$pkgFullName" -ne "" ) {
Remove-AppxPackage "${pkgFullName}" 3>&1 2>&1 | Out-Null
}
# Unregister leftover distros
$env:WSL_UTF8=1
wsl.exe --shutdown
wsl.exe --unregister Ubuntu-22.04 3>&1 2>&1 | Out-Null
Write-Output "::group::Install a new distro"
winget install --id "${storeId}" --accept-source-agreements --accept-package-agreements --silent
Write-Output "::endgroup::"
# Register the new distro
& ${launcher} install --root --ui=none
# Testing succesful install
& ${launcher} run echo Created a new distro with user: '$(whoami)'
if ( ! $? ) { Exit(1) }
- name: Set up WSL
if: runner.os == 'Windows'
shell: powershell
run: |
wsl --update
wsl --version
wsl --set-default-version 2
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