Skip to content

ci

ci #268

Workflow file for this run

name: ci
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
jobs:
lint:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
steps:
- name: Add Homebrew to $PATH
if: runner.os == 'Linux'
run: |
# mitigate https://github.com/actions/runner-images/issues/6283
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >>"$GITHUB_PATH"
- uses: actions/checkout@v3
- name: Install Prettier
run: npm i -g prettier@'^2'
- name: Check web code formatting with Prettier
run: prettier --check .
- name: Install formatters with Homebrew
run: brew install shfmt taplo
- name: Check shell script formatting with shfmt
run: shfmt -d -i 2 .
- name: Install ShellCheck (https://github.com/koalaman/shellcheck) on macOS
if: runner.os == 'macOS'
run: brew install bash shellcheck
- name: Check shell script formatting with ShellCheck
run: |
shopt -s globstar nullglob
set -- **/*.{sh,bash}
if [ -n "$1" ]; then
echo "Checking $@"
shellcheck "$@"
else
echo "No shell scripts for ShellCheck to check."
fi
shell: bash
env:
SHELLCHECK_OPTS: -e SC1071 -e SC1090 -e SC1091
- name: Check TOML formatting with Taplo
run: |
taplo check .taplo.toml
taplo check --schema https://starship.rs/config-schema.json .config/starship.toml
taplo fmt --check **/*.toml
test:
if: github.event_name != 'push'
needs: [lint]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
timeout-minutes: 100
env:
STRAP_CI: 1
STRAP_DEBUG: 1
STRAP_DOTFILES_BRANCH: ${{ github.ref }}
STRAP_GIT_EMAIL: [email protected]
STRAP_GIT_NAME: GitHub Actions
STRAP_GITHUB_USER: br3ndonland
steps:
- name: Add Homebrew to $PATH
if: runner.os == 'Linux'
run: |
# mitigate https://github.com/actions/runner-images/issues/6283
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >>"$GITHUB_PATH"
- name: Clean up Homebrew
run: |
command -v brew &>/dev/null && brew test-bot --only-cleanup-before ||
echo "Homebrew not found."
- name: Clean up macOS
if: runner.os == 'macOS'
run: |
sudo rm -rf /usr/local/Caskroom /usr/local/Homebrew /usr/local/bin/brew \
/usr/local/.??* /Applications/Xcode.app /Library/Developer/CommandLineTools
- name: Create a non-admin user account
run: |
if ${{ runner.os == 'Linux' }}; then
sudo useradd -m non-admin-user
elif ${{ runner.os == 'macOS' }}; then
sudo sysadminctl -addUser non-admin-user
fi
- name: Run bootstrap.sh with a non-admin user without Homebrew installed
run: |
bootstrap_script_url="https://raw.githubusercontent.com/$STRAP_GITHUB_USER/dotfiles/$STRAP_DOTFILES_BRANCH/bootstrap.sh"
sudo --preserve-env --user=non-admin-user /usr/bin/env bash -c "$(curl -fsSL $bootstrap_script_url)"
- name: Run bootstrap.sh
run: |
bootstrap_script_url="https://raw.githubusercontent.com/$STRAP_GITHUB_USER/dotfiles/$STRAP_DOTFILES_BRANCH/bootstrap.sh"
/usr/bin/env bash -c "$(curl -fsSL $bootstrap_script_url)"
- name: Rerun bootstrap.sh to test idempotence
run: bash "$HOME/.dotfiles/bootstrap.sh"
- name: Rerun bootstrap.sh with a non-admin user
run: |
if ${{ runner.os == 'Linux' }}; then
home_prefix=/home
elif ${{ runner.os == 'macOS' }}; then
home_prefix=/Users
fi
sudo --preserve-env --user=non-admin-user /usr/bin/env bash "$home_prefix/non-admin-user/.dotfiles/bootstrap.sh"
- name: Check Homebrew configuration
run: brew config
- name: Check for potential problems with brew doctor
run: brew doctor || echo "Potential problems detected. See output for details."