Release w3w_prediction v1.3.0 #124
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python Connectors CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| detect-clients: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| clients: ${{ steps.detect.outputs.clients }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect clients to build | |
| id: detect | |
| shell: bash | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| BEFORE_SHA: ${{ github.event.before }} | |
| CURRENT_SHA: ${{ github.sha }} | |
| run: | | |
| set -euo pipefail | |
| # Every buildable package in the repository | |
| ALL_CLIENTS=() | |
| if [ -d common ]; then | |
| ALL_CLIENTS+=("common") | |
| fi | |
| for client in clients/*; do | |
| if [ -d "$client" ]; then | |
| ALL_CLIENTS+=("$(basename "$client")") | |
| fi | |
| done | |
| build_all() { | |
| printf '%s\n' "${ALL_CLIENTS[@]}" | jq -R -s -c 'split("\n") | map(select(. != ""))' | |
| } | |
| BASE_SHA="" | |
| if [ "$EVENT_NAME" = "push" ] \ | |
| && [ -n "${BEFORE_SHA:-}" ] \ | |
| && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ] \ | |
| && git cat-file -e "${BEFORE_SHA}^{commit}" 2>/dev/null; then | |
| BASE_SHA="$BEFORE_SHA" | |
| fi | |
| if [ -z "$BASE_SHA" ]; then | |
| echo "No usable diff base (event '$EVENT_NAME'): building every client" | |
| CLIENTS_JSON=$(build_all) | |
| else | |
| CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$CURRENT_SHA") | |
| echo "Changed files:" | |
| echo "$CHANGED_FILES" | sed 's/^/ /' | |
| CLIENTS_JSON=$(echo "$CHANGED_FILES" | awk -F/ ' | |
| $1 == "common" { print "common" } | |
| $1 == "clients" && NF > 2 { print $2 } | |
| ' | jq -R -s -c 'split("\n") | map(select(. != "")) | unique') | |
| fi | |
| echo "Clients to build: $CLIENTS_JSON" | |
| echo "clients=$CLIENTS_JSON" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: detect-clients | |
| if: ${{ needs.detect-clients.outputs.clients != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| client: ${{ fromJson(needs.detect-clients.outputs.clients) }} | |
| python-version: ["3.12"] | |
| poetry-version: ["1.8.4"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| pip3 install --upgrade pip && \ | |
| pip3 install ruff black && \ | |
| curl -sSL https://install.python-poetry.org | python3 - | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Build ${{ matrix.client }} client | |
| run: | | |
| if [ "${{ matrix.client }}" == "common" ]; then | |
| cd common | |
| else | |
| cd clients/${{ matrix.client }} | |
| fi | |
| # Install dependencies | |
| poetry install | |
| # Format | |
| poetry run black . | |
| # Lint | |
| poetry run ruff check --fix . | |
| # Test | |
| poetry run pytest tests | |
| # Build | |
| poetry build |