Skip to content

Commit

Permalink
ci: fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Sep 7, 2024
1 parent f8b08e7 commit 3d3c403
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 62 deletions.
72 changes: 44 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,67 @@ jobs:
fail-fast: false
matrix:
include:
# - os: ubuntu-24.04
# container: rockylinux:8
# nodejs_version: 18
# - os: ubuntu-24.04
# container: node:18-alpine3.16
# - os: macos-12
# nodejs_version: 18
# - os: ubuntu-latest
# container: rockylinux:9
# nodejs_version: 20
# - os: ubuntu-latest
# container: node:20-alpine3.20
# - os: macos-latest
# nodejs_version: 20
# nodejs_arch: x64
# - os: macos-14
# nodejs_version: 18
# - os: macos-latest
# nodejs_version: 20
# nodejs_arch: arm64
# - os: windows-2019
# nodejs_version: 18
# - os: windows-latest
# nodejs_version: 20
# nodejs_arch: x86
- os: windows-2019
nodejs_version: 18
- os: windows-latest
nodejs_version: 20
nodejs_arch: x64
steps:
- uses: pnpm/action-setup@v4
with:
version: 9.7.1

- name: Dependencies (Rocky Linux glibc)
if: contains(matrix.container, 'rockylinux')
run: |
curl -sL https://rpm.nodesource.com/setup_${{ matrix.nodejs_version }}.x | bash -
dnf install -y gcc-toolset-11-gcc-c++ make git python3.12 nodejs
echo "/opt/rh/gcc-toolset-11/root/usr/bin" >> $GITHUB_PATH
echo "PYTHON=/usr/bin/python3.12" >> $GITHUB_ENV
# - name: Dependencies (Rocky Linux glibc)
# if: contains(matrix.container, 'rockylinux')
# run: |
# curl -sL https://rpm.nodesource.com/setup_${{ matrix.nodejs_version }}.x | bash -
# dnf install -y gcc-toolset-11-gcc-c++ make git python3.12 nodejs
# echo "/opt/rh/gcc-toolset-11/root/usr/bin" >> $GITHUB_PATH
# echo "PYTHON=/usr/bin/python3.12" >> $GITHUB_ENV

- name: Dependencies (Linux musl)
if: contains(matrix.container, 'alpine')
run: apk add build-base git python3 --update-cache
# - name: Dependencies (Linux musl)
# if: contains(matrix.container, 'alpine')
# run: apk add build-base git python3 --update-cache

- name: Dependencies (Python - macOS, Windows)
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
uses: actions/setup-python@v5
with:
python-version: "3.12"
# - name: Dependencies (Python - macOS, Windows)
# if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
# uses: actions/setup-python@v5
# with:
# python-version: "3.12"

- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: List files (non-Windows)
if: runner.os != 'Windows'
run: |
echo "Current directory:"
pwd
echo "All files recursively:"
find . -type f
- name: List files (Windows)
if: runner.os == 'Windows'
run: |
echo "Current directory:"
pwd
echo "All files recursively:"
Get-ChildItem -Recurse | ForEach-Object { $_.FullName }
- name: Dependencies (Node.js - macOS, Windows)
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
uses: actions/setup-node@v4
Expand Down
55 changes: 21 additions & 34 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,6 @@
"NAPI_VERSION=<(napi_build_version)"
],
"targets": [
{
"target_name": "libpg_query",
"type": "none",
"actions": [{
"action_name": "build_libpg_query",
"inputs": [],
"outputs": ["libpg_query/libpg_query.a"],
"conditions": [
[
'OS=="win"',
{
"action": [
"cmd",
"/c",
"cd /d libpg_query && MAKEFLAGS=-w nmake /F Makefile.msvc build",
]
},
],
[
'OS!="win"',
{
"action": [
"sh",
"-c",
"cd libpg_query && MAKEFLAGS=-w make build",
]
},
],
],
}],
},
{
"target_name": "queryparser",
"sources": [
Expand Down Expand Up @@ -63,7 +32,13 @@
"libraries": [
"-L<!(pwd)/libpg_query",
"-lpg_query"
]
],
"actions": [{
"action_name": "build_libpg_query",
"inputs": [],
"outputs": ["libpg_query/libpg_query.a"],
"action": ["scripts/build_libpg_query.sh"]
}],
}
],
[
Expand All @@ -77,7 +52,13 @@
"CLANG_CXX_LIBRARY": "libc++",
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"MACOSX_DEPLOYMENT_TARGET": "10.7"
}
},
"actions": [{
"action_name": "build_libpg_query",
"inputs": [],
"outputs": ["libpg_query/libpg_query.a"],
"action": ["scripts/build_libpg_query.sh"]
}],
}
],
[
Expand All @@ -101,7 +82,13 @@
},
"defines": [
"NAPI_DISABLE_CPP_EXCEPTIONS"
]
],
"actions": [{
"action_name": "build_libpg_query",
"inputs": [],
"outputs": ["libpg_query/libpg_query.lib"],
"action": ["cmd", "/C", "scripts/build_libpg_query.bat"]
}],
}
]
]
Expand Down
12 changes: 12 additions & 0 deletions scripts/build_libpg_query.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo on
setlocal enabledelayedexpansion

if not defined CI (
git submodule update --init --recursive
)

set MAKEFLAGS=
set MFLAGS=

cd libpg_query
nmake /F Makefile.msvc build
13 changes: 13 additions & 0 deletions scripts/build_libpg_query.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
set -x

if [ -z "$CI" ]; then
git submodule update --init --recursive
fi

unset MAKEFLAGS
unset MFLAGS

cd libpg_query
make build

0 comments on commit 3d3c403

Please sign in to comment.