Skip to content

Add async listen; Refactor all listen code (#264) #905

Add async listen; Refactor all listen code (#264)

Add async listen; Refactor all listen code (#264) #905

Workflow file for this run

name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- "main"
pull_request:
branches:
- "*"
env:
LOG_LEVEL: info
jobs:
linux-unit:
strategy:
fail-fast: false
matrix:
container:
- swift:5.6-focal
- swift:5.7-jammy
- swift:5.8-jammy
- swiftlang/swift:nightly-5.9-jammy
- swiftlang/swift:nightly-main-jammy
container: ${{ matrix.container }}
runs-on: ubuntu-latest
steps:
- name: Note Swift version
if: ${{ contains(matrix.swiftver, 'nightly') }}
run: |
echo "SWIFT_PLATFORM=$(. /etc/os-release && echo "${ID}${VERSION_ID}")" >>"${GITHUB_ENV}"
echo "SWIFT_VERSION=$(cat /.swift_tag)" >>"${GITHUB_ENV}"
- name: Display OS and Swift versions
run: |
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
- name: Check out package
uses: actions/checkout@v3
- name: Run unit tests with code coverage and Thread Sanitizer
run: swift test --filter=^PostgresNIOTests --sanitize=thread --enable-code-coverage
- name: Submit coverage report to Codecov.io
uses: vapor/swift-codecov-action@v0.2
with:
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH'
cc_fail_ci_if_error: false
linux-integration-and-dependencies:
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
dbimage:
- postgres:15
- postgres:13
- postgres:11
include:
- dbimage: postgres:15
dbauth: scram-sha-256
- dbimage: postgres:13
dbauth: md5
- dbimage: postgres:11
dbauth: trust
container:
image: swift:5.8-jammy
volumes: [ 'pgrunshare:/var/run/postgresql' ]
runs-on: ubuntu-latest
env:
# Unfortunately, fluent-postgres-driver details leak through here
POSTGRES_DB: 'test_database'
POSTGRES_DB_A: 'test_database'
POSTGRES_DB_B: 'test_database'
POSTGRES_USER: 'test_username'
POSTGRES_USER_A: 'test_username'
POSTGRES_USER_B: 'test_username'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_PASSWORD_A: 'test_password'
POSTGRES_PASSWORD_B: 'test_password'
POSTGRES_HOSTNAME: 'psql-a'
POSTGRES_HOSTNAME_A: 'psql-a'
POSTGRES_HOSTNAME_B: 'psql-b'
POSTGRES_SOCKET: '/var/run/postgresql/.s.PGSQL.5432'
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
services:
psql-a:
image: ${{ matrix.dbimage }}
volumes: [ 'pgrunshare:/var/run/postgresql' ]
env:
POSTGRES_USER: 'test_username'
POSTGRES_DB: 'test_database'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
psql-b:
image: ${{ matrix.dbimage }}
volumes: [ 'pgrunshare:/var/run/postgresql' ]
env:
POSTGRES_USER: 'test_username'
POSTGRES_DB: 'test_database'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
steps:
- name: Display OS and Swift versions
run: |
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
- name: Check out package
uses: actions/checkout@v3
with: { path: 'postgres-nio' }
- name: Run integration tests
run: swift test --package-path postgres-nio --filter=^IntegrationTests
- name: Check out postgres-kit dependent
uses: actions/checkout@v3
with: { repository: 'vapor/postgres-kit', path: 'postgres-kit' }
- name: Check out fluent-postgres-driver dependent
uses: actions/checkout@v3
with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' }
- name: Use local package in dependents
run: |
swift package --package-path postgres-kit edit postgres-nio --path postgres-nio
swift package --package-path fluent-postgres-driver edit postgres-nio --path postgres-nio
- name: Run postgres-kit tests
run: swift test --package-path postgres-kit
- name: Run fluent-postgres-driver tests
run: swift test --package-path fluent-postgres-driver
macos-all:
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
dbimage:
# Only test one version on macOS, let Linux do the rest
- postgresql@14
dbauth:
# Only test one auth method on macOS, Linux tests will cover the others
- scram-sha-256
xcode:
- latest-stable
runs-on: macos-13
env:
POSTGRES_HOSTNAME: 127.0.0.1
POSTGRES_USER: 'test_username'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_DB: 'postgres'
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
POSTGRES_SOCKET: '/tmp/.s.PGSQL.5432'
POSTGRES_VERSION: ${{ matrix.dbimage }}
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode }}
- name: Install Postgres, setup DB and auth, and wait for server start
run: |
export PATH="$(brew --prefix)/opt/${POSTGRES_VERSION}/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
(brew unlink postgresql || true) && brew install "${POSTGRES_VERSION}" && brew link --force "${POSTGRES_VERSION}"
initdb --locale=C --auth-host "${POSTGRES_HOST_AUTH_METHOD}" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
pg_ctl start --wait
timeout-minutes: 2
- name: Checkout code
uses: actions/checkout@v3
- name: Run all tests
run: swift test
api-breakage:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
container: swift:5.8-jammy
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
- name: Mark the workspace as safe
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: API breaking changes
run: swift package diagnose-api-breaking-changes origin/main