Skip to content

Commit

Permalink
update scripts/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bitner committed Oct 29, 2024
1 parent f1d71d5 commit fb00d97
Show file tree
Hide file tree
Showing 37 changed files with 2,156 additions and 402 deletions.
178 changes: 178 additions & 0 deletions .github/workflows/civ2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: CI

on:
push:
branches:
- main
- release*
pull_request:

env:
REGISTRY: ghcr.io
REGISTRYPATH: ghcr.io/stac-utils/
PGSTACIMAGE: ghcr.io/stac-utils/pgstac-postgres
PGSTACLATEST: ghcr.io/stac-utils/pgstac-postgres:latest
IMAGE_NAME: ${{ github.repository }}
DOCKER_BUILDKIT: 1
PIP_BREAK_SYSTEM_PACKAGES: 1
PGPASSWORD: postgres
PGHOST: postgres
PGDATABASE: postgres
PGUSER: postgres
POSTGRES_PASSWORD: postgres

jobs:
# This builds a base postgres image that has everything installed to be able to run pgstac.
buildpg:
name: Build and push base postgres image
runs-on: ubuntu-latest
steps:
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
pgstac/pgstac-postgres
${{ env.PGSTACIMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Base Postgres
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
target: pgstac
file: docker/pgstac/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
push: true
cache-from: type=gha
cache-to: type=gha, mode=max

linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: src/pypgstac
target: ${{ matrix.target }}
args: --release --out /tmp/dist
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: /tmp/dist/*

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: src/pypgstac
target: ${{ matrix.target }}
args: --release --out /tmp/dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: /tmp/dist/*

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: src/pypgstac
target: ${{ matrix.target }}
args: --release --out /tmp/dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: /tmp/dist/*

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
working-directory: src/pypgstac
command: sdist
args: --out /tmp/dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: /tmp/dist/*

test:
name: test
needs: [buildpg, linux]
runs-on: ubuntu-latest
services:
postgres:
image: ghcr.io/stac-utils/pgstac-postgres:latest
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Get Wheel
uses: actions/download-artifact@v4
with:
name: wheels
path: /tmp/wheels
- name: Install pypgstac
working-directory: /__w/pgstac/pgstac/src/pypgstac
run: |
for i in /tmp/wheels/pypgstac*x86_64.whl; do uv pip install pypgstac@$i; done
- name: Run tests
working-directory: /__w/pgstac/pgstac/docker/pypgstac/bin
run: |
./test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ src/pypgstac/target
src/pypgstac/python/pypgstac/*.so
.vscode
.ipynb_checkpoints
src/pypgstac/.mypy_cache
src/pypgstac/.pytest_cache
src/pypgstac/.mypy_cache
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
Expand All @@ -13,17 +13,20 @@ repos:
- id: detect-private-key
- id: check-json
- id: mixed-line-ending
args: [--fix=auto]
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-symlinks


- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.284'
rev: 'v0.7.1'
hooks:
- id: ruff
files: pypgstac\/.*\.py$
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
files: pypgstac\/.*\.py$

- repo: local
hooks:
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [v0.9.2]

### Added

Expand All @@ -16,7 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- the text search is un-indexed and will be very slow for item-level searches!

### Fixed

- Fix paging links and add tests for collections_search
- Fix issues with scripts and docker
- Add `open=True` in `psycopg.ConnectionPool` to avoid future behavior change
- Switch from postgres `server_version` to `server_version_num` to get PG version (Fixes #300)
- Allow read-only replicas work even when the context extension is enabled (Fixes #300)
Expand Down Expand Up @@ -531,7 +532,7 @@ _TODO_

- Fixed issue with pypgstac loads which caused some writes to fail ([#18](https://github.com/stac-utils/pgstac/pull/18))

[Unreleased]: https://github.com/stac-utils/pgstac/compare/v0.9.1...main
[v0.9.2]: https://github.com/stac-utils/pgstac/compare/v0.9.1...v0.9.2
[v0.9.1]: https://github.com/stac-utils/pgstac/compare/v0.9.0...v0.9.1
[v0.9.0]: https://github.com/stac-utils/pgstac/compare/v0.8.5...v0.9.0
[v0.8.5]: https://github.com/stac-utils/pgstac/compare/v0.8.4...v0.8.5
Expand Down
20 changes: 19 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ services:
- PGDATABASE=postgis
ports:
- "5439:5432"
develop:
watch:
- action: rebuild
path: ./src/pgstac
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 1s
retries: 15
start_period: 30s
timeout: 10s
volumes:
- pgstac-pgdata:/var/lib/postgresql/data
command: postgres

pypgstac:
container_name: pypgstac
image: pypgstac
Expand All @@ -35,6 +46,13 @@ services:
- PGPASSWORD=password
- PGDATABASE=postgis
depends_on:
- pgstac
pgstac:
condition: service_healthy
restart: true
develop:
watch:
- action: rebuild
path: ./src/pypgstac

volumes:
pgstac-pgdata:
Loading

0 comments on commit fb00d97

Please sign in to comment.