Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows and macOS CI #152

Merged
merged 100 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
ddc67e6
Run CI on Windows
karlhorky Apr 1, 2024
84c2b1f
Add simple script with connection string
karlhorky Apr 1, 2024
c43fe63
Switch from connection string to env vars
karlhorky Apr 1, 2024
5a47db7
Fix import path
karlhorky Apr 1, 2024
2e75908
Update ley.config.js
karlhorky Apr 1, 2024
980e98a
Add psql command
karlhorky Apr 2, 2024
9e48776
Add semicolon
karlhorky Apr 2, 2024
c1fbcce
Merge branch 'main' into test-ci-on-windows
karlhorky Apr 2, 2024
8e92890
Update ci-windows.yml
karlhorky Apr 2, 2024
55f50fe
Use ampersand in command
karlhorky Apr 2, 2024
b802dcc
Remove environment variable
karlhorky Apr 2, 2024
2c45a6e
Switch to PowerShell
karlhorky Apr 2, 2024
8540838
Add back environment variable
karlhorky Apr 2, 2024
7a3dfc8
Add back semicolon
karlhorky Apr 2, 2024
218edc9
Add host flag
karlhorky Apr 2, 2024
c820763
Remove unnecessary steps
karlhorky Apr 2, 2024
5c5f6ce
Remove commented line
karlhorky Apr 2, 2024
425aaf4
Add error logging
karlhorky Apr 2, 2024
c3ac742
Merge branch 'main' into test-ci-on-windows
karlhorky Apr 2, 2024
496aba2
Switch to bash shell
karlhorky Apr 2, 2024
81cdc84
Add debugging
karlhorky Apr 2, 2024
c57fcda
Remove postgres connection from psql
karlhorky Apr 2, 2024
990724b
Use env on step
karlhorky Apr 2, 2024
86031f6
Reenable pnpm install
karlhorky Apr 2, 2024
15ba65f
Enable correct psql command
karlhorky Apr 2, 2024
b8975b2
Remove unnecessary env config
karlhorky Apr 2, 2024
884fb29
Use connection string
karlhorky Apr 2, 2024
5f432cc
Temporarily remove libpg-query
karlhorky Apr 2, 2024
a875634
Add logging
karlhorky Apr 2, 2024
71be1a8
Add missing PGPASSWORD environment variables
karlhorky Apr 2, 2024
b81a814
Add back libpg-query dependencies
karlhorky Apr 2, 2024
8ba19c6
Update Ley config
karlhorky Apr 2, 2024
cb5008e
Discard changes to pnpm-lock.yaml
karlhorky Apr 3, 2024
dabc113
Discard changes to package.json
karlhorky Apr 3, 2024
3b081b8
Switch to node-linker=hoisted for Windows
karlhorky Apr 3, 2024
81dda45
Add linting error
karlhorky Apr 3, 2024
9eaa632
Move error to down function
karlhorky Apr 3, 2024
0a471cf
Upgrade ESLint config version
karlhorky Apr 3, 2024
f60c30b
Fix error
karlhorky Apr 3, 2024
90b591b
Downgrade eslint-config-upleveled to pre-SafeQL v.
karlhorky Apr 3, 2024
9275fe9
Start converting to single PostgreSQL setup script
karlhorky Apr 3, 2024
14525e1
Add to PATH in previous step
karlhorky Apr 3, 2024
469b6e8
Configure PGDATA
karlhorky Apr 3, 2024
155c4e8
Switch back to separate GITHUB_PATH step
karlhorky Apr 3, 2024
cf77e4d
Create PGDATA directory
karlhorky Apr 3, 2024
c6da7b7
Remove all starting commands
karlhorky Apr 3, 2024
0c25b2c
Add initdb
karlhorky Apr 3, 2024
854eb61
Start PostgreSQL as postgres user
karlhorky Apr 3, 2024
57d7bd9
Add path to pg_ctl
karlhorky Apr 3, 2024
16dbf71
Try PGBIN
karlhorky Apr 3, 2024
0eb6565
Try non-interactive flag
karlhorky Apr 3, 2024
d3ee0ae
Try su
karlhorky Apr 3, 2024
183b7b5
Change socket directory
karlhorky Apr 3, 2024
18d8d4a
Run in bash shell
karlhorky Apr 3, 2024
a3a4b11
Make socket directory
karlhorky Apr 3, 2024
db6aa08
Check if ready
karlhorky Apr 3, 2024
bb720c8
Set PGHOST env var
karlhorky Apr 3, 2024
de10d1b
Move to previous step
karlhorky Apr 3, 2024
228035c
Specify host socket
karlhorky Apr 3, 2024
7ebec82
Try running as non-privileged user
karlhorky Apr 3, 2024
355ba17
Create database
karlhorky Apr 3, 2024
cdf2daa
Remove commands
karlhorky Apr 3, 2024
b1196d2
Create database before creating user
karlhorky Apr 3, 2024
1acf937
Enable CI on macOS and Windows
karlhorky Apr 3, 2024
53f2177
Simplify
karlhorky Apr 3, 2024
c67ba32
Add binaries to PATH
karlhorky Apr 3, 2024
7b632b1
Convert back slashes to forward slashes
karlhorky Apr 3, 2024
9b35cfa
Add logging
karlhorky Apr 3, 2024
b5871d3
Use cygpath --unix
karlhorky Apr 3, 2024
1c6537a
Use cygpath only on Windows
karlhorky Apr 3, 2024
9ad4ffa
Fix slash
karlhorky Apr 3, 2024
8f1a84a
Run initdb with user
karlhorky Apr 3, 2024
0b6891c
Add username
karlhorky Apr 3, 2024
f00a774
Add username flag
karlhorky Apr 3, 2024
12670f7
Use default postgres user
karlhorky Apr 3, 2024
8677749
Create user first
karlhorky Apr 3, 2024
ef28b38
Don't grant
karlhorky Apr 3, 2024
c8c3cb9
Use default username for Linux and macOS
karlhorky Apr 3, 2024
98dc476
Use postgres database and user
karlhorky Apr 3, 2024
3930acf
Use postgres user
karlhorky Apr 3, 2024
9c69b96
Fix Python 3.12 issue with pnpm<v9
karlhorky Apr 3, 2024
829c1e0
Fix CRLF for Windows Prettier check
karlhorky Apr 3, 2024
4ff4fb5
Use long flag
karlhorky Apr 3, 2024
e5495d1
Use node-linker=hoisted on Windows
karlhorky Apr 3, 2024
f974e88
Use short flag
karlhorky Apr 3, 2024
668d45a
Start cleaning up workflow steps
karlhorky Apr 3, 2024
18e8fab
Switch order, add comments
karlhorky Apr 3, 2024
6b8d227
Add logging, remove pg_isready check
karlhorky Apr 3, 2024
bed6ce4
Move first echo to top
karlhorky Apr 3, 2024
a9a4682
Switch to double quotes
karlhorky Apr 3, 2024
db044f1
Improve log message
karlhorky Apr 3, 2024
5d53553
Add double quotes
karlhorky Apr 3, 2024
83cc2b9
Remove obsolete commented steps
karlhorky Apr 3, 2024
5d7a6ec
Remove Windows workflow file
karlhorky Apr 3, 2024
518d111
Remove unnecessary shell config
karlhorky Apr 3, 2024
56da253
Add extra lines
karlhorky Apr 3, 2024
2509d37
Remove testing file
karlhorky Apr 3, 2024
62748cf
Add reference and TODO
karlhorky Apr 3, 2024
e4b41eb
Merge branch 'main' into test-ci-on-windows
karlhorky Apr 3, 2024
9d267b4
Update lockfile
karlhorky Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 68 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,105 @@ on: push
jobs:
ci:
name: CI
runs-on: ubuntu-latest
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:
- name: Start preinstalled PostgreSQL on Ubuntu
# Start preinstalled PostgreSQL database on Windows, macOS and Linux
# https://github.com/karlhorky/github-tricks/#github-actions-start-preinstalled-postgresql-database-on-windows-macos-and-linux
- name: Add PostgreSQL binaries to PATH
shell: bash
run: |
sudo systemctl start postgresql.service
pg_isready
- name: Create database user
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: |
sudo -u postgres psql --command="CREATE USER $PGUSERNAME PASSWORD '$PGPASSWORD'" --command="\du"
- name: Create database and allow user
run: |
sudo -u postgres createdb --owner=$PGUSERNAME $PGDATABASE
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@v3
with:
version: 'latest'
# Use pnpm v9 beta for Python 3.12 problem with node-gyp
# https://github.com/pnpm/pnpm/issues/2135#issuecomment-2028118254
#
# TODO: Switch back to 'latest' once pnpm v9 released:
# version: 'latest'
version: '9.0.0-beta.2'

# Use the official setup-node action (sets up Node.js):
# https://github.com/actions/setup-node
- 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
Expand Down