Skip to content

ci

ci #273

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: |
username=non-admin-user
if ${{ runner.os == 'Linux' }}; then
sudo useradd -m $username
home_prefix=/home
elif ${{ runner.os == 'macOS' }}; then
sudo sysadminctl -addUser non-admin-user
home_prefix=/Users
fi
echo "NON_ADMIN_USER_HOME=$home_prefix/$username" >>"$GITHUB_ENV"
- 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)"
working-directory: ${{ env.NON_ADMIN_USER_HOME }}
- 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: sudo --preserve-env --user=non-admin-user /usr/bin/env bash "$NON_ADMIN_USER_HOME/.dotfiles/bootstrap.sh"
working-directory: ${{ env.NON_ADMIN_USER_HOME }}
- 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."