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

Support Test and CI #38

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test macOS

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
workflow_dispatch:

jobs:
test-macos:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [macos-latest]

steps:
- name: Checkout pgGeocoder
uses: actions/checkout@v4

- name: Install dependencies
run: |
brew install postgresql postgis

- name: Install pgTAP
run: |
git clone https://github.com/theory/pgtap.git pgTapExtension
cd pgTapExtension
make -j
make install
cpan TAP::Parser::SourceHandler::pgTAP
ln -s $(find `brew --prefix` -name pg_prove) symlink it into $(brew --prefix)/bin

- name: Start PostgreSQL
run: |
pg_ctl -D $(brew --prefix)/var/postgresql@14 start
createuser -s postgres

- name: Wait PostgreSQL launch
run: |
pg_isready -U postgres -h localhost -p 5432
psql -U postgres -h localhost -p 5432 -c "SELECT version();"

- name: Set up database
run: |
cp .env.example .env
cp tests/.env.test tests/.env
bash tests/create_test_db_from_fixtures.sh

- name: Run test
run: |
cd tests/normalize-japanese-addresses
pg_prove -U postgres -h localhost -p 5432 -d addresses_test addresses.test.sql
pg_prove -U postgres -h localhost -p 5432 -d addresses_test main.test.sql
71 changes: 71 additions & 0 deletions .github/workflows/test-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test Ubuntu

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
workflow_dispatch:

jobs:
test-ubuntu:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-22.04]

steps:
- name: Checkout pgGeocoder
uses: actions/checkout@v4

- name: Set PostgreSQL/PostGIS major version
run: |
pg_major=$(psql --version | grep -Po '(?<=psql \(PostgreSQL\) )[^;]+(?=\.\d+ \()')
echo "PG_MAJOR=${pg_major}" >> $GITHUB_ENV
echo "POSTGIS_MAJOR=3" >> $GITHUB_ENV

- name: Add PostgreSQL APT repository
run: |
sudo apt-get install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ \
$(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libtap-parser-sourcehandler-pgtap-perl \
postgresql-${PG_MAJOR} \
postgresql-${PG_MAJOR}-pgtap \
postgresql-${PG_MAJOR}-postgis-${POSTGIS_MAJOR} \
postgresql-${PG_MAJOR}-postgis-${POSTGIS_MAJOR}-scripts

- name: Start PostgreSQL (with trust authentication)
run: |
sudo sed -i "s/\(peer\|scram-sha-256\)$/trust/g" "/etc/postgresql/${PG_MAJOR}/main/pg_hba.conf"
sudo cat "/etc/postgresql/${PG_MAJOR}/main/pg_hba.conf"
sudo systemctl start postgresql.service

- name: Wait PostgreSQL launch
run: |
pg_isready -U postgres -h localhost -p 5432
psql -U postgres -h localhost -p 5432 -c "SELECT version();"

- name: Set up database
run: |
cp .env.example .env
cp tests/.env.test tests/.env
bash tests/create_test_db_from_fixtures.sh

- name: Run test
run: |
cd tests/normalize-japanese-addresses
pg_prove -U postgres -h localhost -p 5432 -d addresses_test addresses.test.sql
pg_prove -U postgres -h localhost -p 5432 -d addresses_test main.test.sql
Loading