diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 9287a65b..0f83fd27 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -15,6 +15,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install deps + run: make install + - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index c074af37..abf5b9a2 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -25,6 +25,9 @@ jobs: with: fetch-depth: 0 + - name: Install deps + run: make install + - name: Fuzz run: | go test ./pkg/usaddress/... -fuzz Fuzz -fuzztime 10m diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d20ad6d6..a6f45116 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,6 +24,9 @@ jobs: go-version: stable id: go + - name: Install deps + run: make install + - name: Run Tests (Linux) if: runner.os == 'Linux' run: make check @@ -53,6 +56,9 @@ jobs: run: | choco install -y make mingw + - name: Install deps + run: make install + - name: Run Short Tests (Non-Linux) run: | go test ./... -short @@ -85,6 +91,9 @@ jobs: sudo systemctl stop mono-xsp4.service || true sudo killall mono || true + - name: Install deps + run: make install + - name: Build Frontend run: make build diff --git a/.github/workflows/openshift.yml b/.github/workflows/openshift.yml index 4004de38..03e2aa42 100644 --- a/.github/workflows/openshift.yml +++ b/.github/workflows/openshift.yml @@ -29,6 +29,9 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v3 + - name: Install deps + run: make install + - name: Docker Build if: runner.os == 'Linux' run: make docker-openshift diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a37f074e..6c2f13fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,9 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v4 + - name: Install deps + run: make install + - name: Short Tests if: runner.os == 'Linux' env: @@ -74,6 +77,9 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v4 + - name: Install deps + run: make install + - name: Load Release URL File from release job uses: actions/download-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 05d3c8a5..7df91ba1 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ openapi-generator*jar *.db +/libpostal/ + webui/build/ webui/node_modules/ diff --git a/makefile b/makefile index 7e28eb4a..76f13150 100644 --- a/makefile +++ b/makefile @@ -19,6 +19,72 @@ endif run: CGO_ENABLED=0 go run github.com/moov-io/watchman/cmd/server +# Detect OS +ifeq ($(OS),Windows_NT) + detected_OS := Windows +else + detected_OS := $(shell uname -s) +endif + +# Detect architecture for macOS +ifeq ($(detected_OS),Darwin) + ARCH := $(shell uname -m) + ifeq ($(ARCH),arm64) + CONFIGURE_FLAGS := --datadir=/tmp/libpostal-data --disable-sse2 + else + CONFIGURE_FLAGS := --datadir=/tmp/libpostal-data + endif +else + CONFIGURE_FLAGS := --datadir=/tmp/libpostal-data +endif + +# Installation target +install: +ifeq ($(detected_OS),Windows) + @$(MAKE) install-windows +else ifeq ($(detected_OS),Linux) + @$(MAKE) install-linux +else ifeq ($(detected_OS),Darwin) + @$(MAKE) install-macos +else + @echo "Unsupported operating system: $(detected_OS)" + @exit 1 +endif + +install-linux: + sudo apt-get install -y curl autoconf automake libtool pkg-config + @$(MAKE) install-libpostal + +install-macos: + brew install curl autoconf automake libtool pkg-config + @echo "Detecting architecture: $(ARCH)" +ifeq ($(ARCH),arm64) + @echo "ARM architecture detected (M1/M2). SSE2 will be disabled." +else + @echo "Intel architecture detected. SSE2 optimizations will be enabled." +endif + @$(MAKE) install-libpostal + +install-windows: + pacman -Syu + pacman -S autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc + @$(MAKE) install-libpostal + +install-libpostal: + @echo "Cloning libpostal repository..." + git clone https://github.com/openvenues/libpostal || true + cd libpostal && \ + ./bootstrap.sh && \ + ./configure $(CONFIGURE_FLAGS) && \ + make -j$(shell nproc || echo 4) && \ + if [ "$(detected_OS)" = "Windows" ]; then \ + make install; \ + else \ + sudo make install; \ + fi + +.PHONY: install install-linux install-macos install-windows install-libpostal + build: build-server build-batchsearch build-watchmantest ifeq ($(OS),Windows_NT) @echo "Skipping webui build on Windows." @@ -38,7 +104,7 @@ build-watchmantest: .PHONY: check check: ifeq ($(OS),Windows_NT) - @echo "Skipping checks on Windows, currently unsupported." + go test ./... -short else @wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh @chmod +x ./lint-project.sh