Update dependency upgrades - non-major (#358) #856
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: push | |
jobs: | |
ci: | |
name: CI | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
timeout-minutes: 15 | |
env: | |
PGHOST: localhost | |
PGDATABASE: preflight_test_project_next_js_passing | |
PGUSERNAME: preflight_test_project_next_js_passing | |
PGPASSWORD: preflight_test_project_next_js_passing | |
steps: | |
# Create PostgreSQL databases on Windows, macOS and Linux | |
# https://github.com/karlhorky/github-tricks/#github-actions-create-postgresql-databases-on-windows-macos-and-linux | |
- name: Install PostgreSQL on macOS | |
if: runner.os == 'macOS' | |
run: | | |
brew install postgresql@16 | |
# --overwrite: Overwrite pre-installed GitHub Actions PostgreSQL binaries | |
brew link --overwrite postgresql@16 | |
- name: Add PostgreSQL binaries to PATH | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
echo "$PGBIN" >> $GITHUB_PATH | |
elif [ "$RUNNER_OS" == "Linux" ]; then | |
echo "$(pg_config --bindir)" >> $GITHUB_PATH | |
fi | |
- name: Start preinstalled PostgreSQL | |
shell: bash | |
run: | | |
echo "Initializing database cluster..." | |
# Convert backslashes to forward slashes in RUNNER_TEMP for Windows Git Bash | |
export PGHOST="${RUNNER_TEMP//\\//}/postgres" | |
export PGDATA="$PGHOST/pgdata" | |
mkdir -p "$PGDATA" | |
# initdb requires file for password in non-interactive mode | |
export PWFILE="$RUNNER_TEMP/pwfile" | |
echo "postgres" > "$PWFILE" | |
initdb --pgdata="$PGDATA" --username="postgres" --pwfile="$PWFILE" | |
echo "Starting PostgreSQL..." | |
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf" | |
pg_ctl start | |
echo "Creating user..." | |
psql --host "$PGHOST" --username="postgres" --dbname="postgres" --command="CREATE USER $PGUSERNAME PASSWORD '$PGPASSWORD'" --command="\du" | |
echo "Creating database..." | |
createdb --owner="$PGUSERNAME" --username="postgres" "$PGDATABASE" | |
# Avoid CRLF in Windows tests, which cause problems with Prettier: | |
# https://github.com/upleveled/preflight/runs/1824397400 | |
# | |
# Suggested here: https://github.com/actions/checkout/issues/250#issuecomment-635267458 | |
# Example repo: https://github.com/ghdl/ghdl/blob/aa63b5efcd2be66acc26443032df2b251e4b1a7a/.github/workflows/Test.yml#L230-L232 | |
- name: Use LF instead of CRLF for clone | |
run: git config --global core.autocrlf input | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'pnpm' | |
# Avoid Node.js bug with long filenames on Windows | |
# https://github.com/nodejs/node/issues/50753 | |
- run: echo 'node-linker=hoisted' > ./.npmrc | |
shell: bash | |
if: runner.os == 'Windows' | |
- name: Install dependencies | |
run: pnpm install | |
# Remove .npmrc file again on Windows | |
# https://github.com/nodejs/node/issues/50753 | |
- run: rm .npmrc | |
if: runner.os == 'Windows' | |
- run: pnpm migrate up | |
# Also generates next-env.d.ts, required for tsc | |
- name: Build Next.js app | |
run: pnpm build | |
- name: Run TypeScript Compiler | |
run: pnpm tsc | |
- name: Run ESLint | |
run: pnpm eslint . --max-warnings 0 | |
- name: Run Stylelint | |
run: pnpm stylelint '**/*.{css,scss,less,js,tsx}' | |
- name: Install and run Preflight | |
run: | | |
pnpm add --global @upleveled/preflight | |
preflight |