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

Rust Hydration #201

Merged
merged 13 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
venv/*
*/.direnv/*
*/.ruff_cache/*
*/.pytest_cache/*
*/.vscode/*
*/.mypy_cache/*
*/.pgadmin/*
Expand All @@ -14,5 +15,5 @@ venv/*
*/.github/*
*/env/*
Dockerfile
docker-compose.yml
docker compose.yml
*/.devcontainer/*
221 changes: 212 additions & 9 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,224 @@ env:
DOCKER_BUILDKIT: 1

jobs:
test:
name: test
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
pgdocker: ${{ steps.check.outputs.pgtag }}
buildpgdocker: ${{ steps.check.outputs.buildpg }}
pyrustdocker: ${{ steps.check.outputs.pytag }}
buildpyrustdocker: ${{ steps.check.outputs.buildpy }}

steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
pgstac:
- 'docker/pgstac/**'
pypgstac:
- 'docker/pypgstac/**'
- id: check
run: |
buildpg=false;
ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
[[ "${{ steps.filter.outputs.pgstac }}" == "true" ]] && buildpg=true || ref=main;
echo "pgtag=${{ env.REGISTRY }}/stac-utils/pgstac-postgres:$ref" >>$GITHUB_OUTPUT;
echo "buildpg=$buildpg" >>$GITHUB_OUTPUT;
buildy=false;
ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
[[ "${{ steps.filter.outputs.pypgstac }}" == "true" ]] && buildpy=true || ref=main;
echo "pytag=${{ env.REGISTRY }}/stac-utils/pgstac-pyrust:$ref" >>$GITHUB_OUTPUT;
echo "buildpy=$buildpg" >>$GITHUB_OUTPUT;

buildpg:
name: Build and push base postgres
if: ${{ needs.changes.outputs.buildpgdocker == 'true' }}
runs-on: ubuntu-latest
needs: [changes]
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- name: builder
id: builder
uses: docker/build-push-action@v2
- uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Base Postgres
uses: docker/build-push-action@v4
with:
context: .
load: true
push: false
target: pgstacbase-plrust
file: docker/pgstac/Dockerfile
tags: ${{ needs.changes.outputs.pgdocker }}
push: true
cache-from: type=gha
cache-to: type=gha, mode=max

buildpyrust:
name: Build and push base pyrust
if: ${{ needs.changes.outputs.buildpyrustdocker == 'true' }}
runs-on: ubuntu-latest
needs: [changes]
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Base pyrust
uses: docker/build-push-action@v4
with:
context: .
target: pyrustbase
file: docker/pypgstac/Dockerfile
tags: ${{ needs.changes.outputs.pyrustdocker }}
push: true
cache-from: type=gha
cache-to: type=gha, mode=max

test:
name: test
needs: [changes, buildpg, buildpyrust]
runs-on: ubuntu-latest
container:
image: ${{ needs.changes.outputs.pyrustdocker }}
env:
PGPASSWORD: postgres
PGHOST: postgres
PGDATABASE: postgres
PGUSER: postgres

services:
postgres:
env:
POSTGRES_PASSWORD: postgres
image: ${{ needs.changes.outputs.pgdocker }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3
- name: Install pypgstac
working-directory: /__w/pgstac/pgstac/src/pypgstac
run: |
pip install .[dev,test,psycopg];

- name: Run tests
run: docker run --rm ${{ steps.builder.outputs.imageid }} test
working-directory: /__w/pgstac/pgstac/docker/pypgstac/bin
run: |
./test

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 /home/runner/work/pgstac/pgstac/dist
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: /home/runner/work/pgstac/pgstac/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 /home/runner/work/pgstac/pgstac/dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: /home/runner/work/pgstac/pgstac/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 /home/runner/work/pgstac/pgstac/dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: /home/runner/work/pgstac/pgstac/dist/*

# release:
# name: Release
# runs-on: ubuntu-latest
# if: "startsWith(github.ref, 'refs/tags/')"
# needs: [linux, windows, macos, sdist]
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: wheels
# - name: Publish to PyPI
# uses: PyO3/maturin-action@v1
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# with:
# command: upload
# args: --skip-existing *
Loading