Test Postgres client libraries #57
This file contains 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: Test Postgres client libraries | |
on: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# ┌───────────── minute (0 - 59) | |
# │ ┌───────────── hour (0 - 23) | |
# │ │ ┌───────────── day of the month (1 - 31) | |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | |
- cron: '23 02 * * *' # run once a day, timezone is utc | |
workflow_dispatch: | |
concurrency: | |
# Allow only one workflow per any non-`main` branch. | |
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} | |
cancel-in-progress: true | |
jobs: | |
test-postgres-client-libs: | |
# TODO: switch to gen2 runner, requires docker | |
runs-on: [ ubuntu-latest ] | |
env: | |
DEFAULT_PG_VERSION: 14 | |
TEST_OUTPUT: /tmp/test_output | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: Cache poetry deps | |
id: cache_poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: v1-${{ runner.os }}-python-deps-${{ hashFiles('poetry.lock') }} | |
- name: Install Python deps | |
shell: bash -euxo pipefail {0} | |
run: ./scripts/pysync | |
- name: Create Neon Project | |
id: create-neon-project | |
uses: ./.github/actions/neon-project-create | |
with: | |
api_key: ${{ secrets.NEON_STAGING_API_KEY }} | |
postgres_version: ${{ env.DEFAULT_PG_VERSION }} | |
- name: Run pytest | |
env: | |
REMOTE_ENV: 1 | |
BENCHMARK_CONNSTR: ${{ steps.create-neon-project.outputs.dsn }} | |
POSTGRES_DISTRIB_DIR: /tmp/neon/pg_install | |
shell: bash -euxo pipefail {0} | |
run: | | |
# Test framework expects we have psql binary; | |
# but since we don't really need it in this test, let's mock it | |
mkdir -p "$POSTGRES_DISTRIB_DIR/v${DEFAULT_PG_VERSION}/bin" && touch "$POSTGRES_DISTRIB_DIR/v${DEFAULT_PG_VERSION}/bin/psql"; | |
./scripts/pytest \ | |
--junitxml=$TEST_OUTPUT/junit.xml \ | |
--tb=short \ | |
--verbose \ | |
-m "remote_cluster" \ | |
-rA "test_runner/pg_clients" | |
- name: Delete Neon Project | |
if: ${{ always() }} | |
uses: ./.github/actions/neon-project-delete | |
with: | |
project_id: ${{ steps.create-neon-project.outputs.project_id }} | |
api_key: ${{ secrets.NEON_STAGING_API_KEY }} | |
# We use GitHub's action upload-artifact because `ubuntu-latest` doesn't have configured AWS CLI. | |
# It will be fixed after switching to gen2 runner | |
- name: Upload python test logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
retention-days: 7 | |
name: python-test-pg_clients-${{ runner.os }}-stage-logs | |
path: ${{ env.TEST_OUTPUT }} | |
- name: Post to a Slack channel | |
if: ${{ github.event.schedule && failure() }} | |
uses: slackapi/slack-github-action@v1 | |
with: | |
channel-id: "C033QLM5P7D" # dev-staging-stream | |
slack-message: "Testing Postgres clients: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |