|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release* |
| 8 | + pull_request: |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: ghcr.io |
| 12 | + REGISTRYPATH: ghcr.io/stac-utils/ |
| 13 | + PGSTACIMAGE: ghcr.io/stac-utils/pgstac-postgres |
| 14 | + PGSTACLATEST: ghcr.io/stac-utils/pgstac-postgres:latest |
| 15 | + IMAGE_NAME: ${{ github.repository }} |
| 16 | + DOCKER_BUILDKIT: 1 |
| 17 | + PIP_BREAK_SYSTEM_PACKAGES: 1 |
| 18 | + PGPASSWORD: postgres |
| 19 | + PGHOST: postgres |
| 20 | + PGDATABASE: postgres |
| 21 | + PGUSER: postgres |
| 22 | + POSTGRES_PASSWORD: postgres |
| 23 | + |
| 24 | +jobs: |
| 25 | + # This builds a base postgres image that has everything installed to be able to run pgstac. |
| 26 | + buildpg: |
| 27 | + name: Build and push base postgres image |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Docker Meta |
| 31 | + id: meta |
| 32 | + uses: docker/metadata-action@v5 |
| 33 | + with: |
| 34 | + images: | |
| 35 | + pgstac/pgstac-postgres |
| 36 | + ${{ env.PGSTACIMAGE }} |
| 37 | + tags: | |
| 38 | + type=ref,event=branch |
| 39 | + type=ref,event=pr |
| 40 | + type=semver,pattern={{version}} |
| 41 | + type=semver,pattern={{major}}.{{minor}} |
| 42 | + type=semver,pattern={{major}} |
| 43 | + type=sha |
| 44 | + - uses: docker/setup-buildx-action@v3 |
| 45 | + - name: Log in to the Container registry |
| 46 | + uses: docker/login-action@v3 |
| 47 | + with: |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + - name: Build and Push Base Postgres |
| 52 | + uses: docker/build-push-action@v5 |
| 53 | + with: |
| 54 | + platforms: linux/amd64,linux/arm64 |
| 55 | + context: . |
| 56 | + target: pgstac |
| 57 | + file: docker/pgstac/Dockerfile |
| 58 | + tags: ${{ steps.meta.outputs.tags }} |
| 59 | + push: true |
| 60 | + cache-from: type=gha |
| 61 | + cache-to: type=gha, mode=max |
| 62 | + |
| 63 | + linux: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v3 |
| 70 | + - uses: actions/setup-python@v4 |
| 71 | + with: |
| 72 | + python-version: '3.10' |
| 73 | + - name: Build wheels |
| 74 | + uses: PyO3/maturin-action@v1 |
| 75 | + with: |
| 76 | + working-directory: src/pypgstac |
| 77 | + target: ${{ matrix.target }} |
| 78 | + args: --release --out /tmp/dist |
| 79 | + sccache: 'true' |
| 80 | + manylinux: auto |
| 81 | + - name: Upload wheels |
| 82 | + uses: actions/upload-artifact@v3 |
| 83 | + with: |
| 84 | + name: wheels |
| 85 | + path: /tmp/dist/* |
| 86 | + |
| 87 | + windows: |
| 88 | + runs-on: windows-latest |
| 89 | + strategy: |
| 90 | + matrix: |
| 91 | + target: [x64, x86] |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v3 |
| 94 | + - uses: actions/setup-python@v4 |
| 95 | + with: |
| 96 | + python-version: '3.10' |
| 97 | + architecture: ${{ matrix.target }} |
| 98 | + - name: Build wheels |
| 99 | + uses: PyO3/maturin-action@v1 |
| 100 | + with: |
| 101 | + working-directory: src/pypgstac |
| 102 | + target: ${{ matrix.target }} |
| 103 | + args: --release --out /tmp/dist |
| 104 | + sccache: 'true' |
| 105 | + - name: Upload wheels |
| 106 | + uses: actions/upload-artifact@v3 |
| 107 | + with: |
| 108 | + name: wheels |
| 109 | + path: /tmp/dist/* |
| 110 | + |
| 111 | + macos: |
| 112 | + runs-on: macos-latest |
| 113 | + strategy: |
| 114 | + matrix: |
| 115 | + target: [x86_64, aarch64] |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v3 |
| 118 | + - uses: actions/setup-python@v4 |
| 119 | + with: |
| 120 | + python-version: '3.10' |
| 121 | + - name: Build wheels |
| 122 | + uses: PyO3/maturin-action@v1 |
| 123 | + with: |
| 124 | + working-directory: src/pypgstac |
| 125 | + target: ${{ matrix.target }} |
| 126 | + args: --release --out /tmp/dist |
| 127 | + sccache: 'true' |
| 128 | + - name: Upload wheels |
| 129 | + uses: actions/upload-artifact@v3 |
| 130 | + with: |
| 131 | + name: wheels |
| 132 | + path: /tmp/dist/* |
| 133 | + |
| 134 | + sdist: |
| 135 | + runs-on: ubuntu-latest |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v3 |
| 138 | + - name: Build sdist |
| 139 | + uses: PyO3/maturin-action@v1 |
| 140 | + with: |
| 141 | + working-directory: src/pypgstac |
| 142 | + command: sdist |
| 143 | + args: --out /tmp/dist |
| 144 | + - name: Upload sdist |
| 145 | + uses: actions/upload-artifact@v3 |
| 146 | + with: |
| 147 | + name: wheels |
| 148 | + path: /tmp/dist/* |
| 149 | + |
| 150 | + test: |
| 151 | + name: test |
| 152 | + needs: [buildpg, linux] |
| 153 | + runs-on: ubuntu-latest |
| 154 | + services: |
| 155 | + postgres: |
| 156 | + image: ghcr.io/stac-utils/pgstac-postgres:latest |
| 157 | + options: >- |
| 158 | + --health-cmd pg_isready |
| 159 | + --health-interval 10s |
| 160 | + --health-timeout 5s |
| 161 | + --health-retries 5 |
| 162 | +
|
| 163 | + steps: |
| 164 | + - uses: actions/checkout@v3 |
| 165 | + - name: Get Wheel |
| 166 | + uses: actions/download-artifact@v4 |
| 167 | + with: |
| 168 | + name: wheels |
| 169 | + path: /tmp/wheels |
| 170 | + - name: Install pypgstac |
| 171 | + working-directory: /__w/pgstac/pgstac/src/pypgstac |
| 172 | + run: | |
| 173 | + for i in /tmp/wheels/pypgstac*x86_64.whl; do uv pip install pypgstac@$i; done |
| 174 | +
|
| 175 | + - name: Run tests |
| 176 | + working-directory: /__w/pgstac/pgstac/docker/pypgstac/bin |
| 177 | + run: | |
| 178 | + ./test |
0 commit comments