From 1f59f95a90af2105a2281444be25311003e4cec7 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Sat, 5 Aug 2023 07:17:25 -0500 Subject: [PATCH 1/7] Upgrade CI --- .github/workflows/test.yml | 113 ++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24821c77..4b20db6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,49 +17,43 @@ jobs: strategy: fail-fast: false matrix: - container: + swift-image: - 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 }} + container: ${{ matrix.swift-image }} 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 + shell: bash run: | - printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version + [[ -z "${SWIFT_PLATFORM}" ]] && SWIFT_PLATFORM="$(. /etc/os-release && echo "${ID}${VERSION_ID}")" + [[ -z "${SWIFT_VERSION}" ]] && SWIFT_VERSION="$(cat /.swift_tag 2>/dev/null || true)" + 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 + - name: Run unit tests with Thread Sanitizer + run: swift test --filter=^PostgresNIOTests --sanitize=thread linux-integration-and-dependencies: if: github.event_name == 'pull_request' strategy: fail-fast: false matrix: - dbimage: + postgres-image: - postgres:15 - postgres:13 - postgres:11 include: - - dbimage: postgres:15 - dbauth: scram-sha-256 - - dbimage: postgres:13 - dbauth: md5 - - dbimage: postgres:11 - dbauth: trust + - postgres-image: postgres:15 + postgres-auth: scram-sha-256 + - postgres-image: postgres:13 + postgres-auth: md5 + - postgres-image: postgres:11 + postgres-auth: trust container: image: swift:5.8-jammy volumes: [ 'pgrunshare:/var/run/postgresql' ] @@ -79,29 +73,31 @@ jobs: POSTGRES_HOSTNAME_A: 'psql-a' POSTGRES_HOSTNAME_B: 'psql-b' POSTGRES_SOCKET: '/var/run/postgresql/.s.PGSQL.5432' - POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }} + POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }} services: psql-a: - image: ${{ matrix.dbimage }} + image: ${{ matrix.postgres-image }} 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 }} + POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }} + POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }} psql-b: - image: ${{ matrix.dbimage }} + image: ${{ matrix.postgres-image }} 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 }} + POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }} + POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }} steps: - name: Display OS and Swift versions run: | + [[ -z "${SWIFT_PLATFORM}" ]] && SWIFT_PLATFORM="$(. /etc/os-release && echo "${ID}${VERSION_ID}")" + [[ -z "${SWIFT_VERSION}" ]] && SWIFT_VERSION="$(cat /.swift_tag 2>/dev/null || true)" printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version - name: Check out package uses: actions/checkout@v3 @@ -128,33 +124,34 @@ jobs: strategy: fail-fast: false matrix: - dbimage: + postgres-formula: # Only test one version on macOS, let Linux do the rest - postgresql@14 - dbauth: + postgres-auth: # Only test one auth method on macOS, Linux tests will cover the others - scram-sha-256 - xcode: - - latest-stable + xcode-version: + - '~14.3' + - '15.0-beta' 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_AUTH_METHOD: ${{ matrix.postgres-auth }} POSTGRES_SOCKET: '/tmp/.s.PGSQL.5432' - POSTGRES_VERSION: ${{ matrix.dbimage }} + POSTGRES_FORMULA: ${{ matrix.postgres-formula }} steps: - name: Select latest available Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: ${{ matrix.xcode }} + xcode-version: ${{ matrix.xcode-version }} - 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}") + export PATH="$(brew --prefix)/opt/${POSTGRES_FORMULA}/bin:$PATH" PGDATA=/tmp/vapor-postgres-test + (brew unlink postgresql || true) && brew install "${POSTGRES_FORMULA}" && brew link --force "${POSTGRES_FORMULA}" + initdb --locale=C --auth-host "${POSTGRES_AUTH_METHOD}" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}") pg_ctl start --wait timeout-minutes: 2 - name: Checkout code @@ -162,10 +159,21 @@ jobs: - name: Run all tests run: swift test + code-coverage: + runs-on: ubuntu-latest + container: swift:jammy + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Run unit tests for coverage data + run: swift test --enable-code-coverage + - name: Upload coverage data + uses: vapor/swift-codecov-action@v0.2 + api-breakage: if: github.event_name == 'pull_request' runs-on: ubuntu-latest - container: swift:5.8-jammy + container: swift:jammy steps: - name: Checkout uses: actions/checkout@v3 @@ -177,3 +185,28 @@ jobs: - name: API breaking changes run: swift package diagnose-api-breaking-changes origin/main + gh-codeql: + strategy: + fail-fast: false + matrix: + runner-os: + - ubuntu-latest + - macos-13 + runs-on: ${{ matrix.runner-os }} + #permissions: { security-events: write } + steps: + - name: Select appropriate Xcode version + if: ${{ startsWith(matrix.runner-os, 'macos') }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '~14.3' + - name: Check out code + uses: actions/checkout@v3 + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: swift + - name: Perform build + run: swift build + - name: Run CodeQL analyze + uses: github/codeql-action/analyze@v2 From 70b5a9d34873c1ee22dff7b0e2b1d8abb10ddb34 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Sat, 5 Aug 2023 07:23:42 -0500 Subject: [PATCH 2/7] Only run unit tests when doing code coverage --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b20db6b..9ab0c96e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -166,7 +166,7 @@ jobs: - name: Check out code uses: actions/checkout@v3 - name: Run unit tests for coverage data - run: swift test --enable-code-coverage + run: swift test --filter=^PostgresNIOTests --enable-code-coverage - name: Upload coverage data uses: vapor/swift-codecov-action@v0.2 From d4acf048f9b4fb4eeded6198bf5d49888cf8822a Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Sat, 5 Aug 2023 07:40:18 -0500 Subject: [PATCH 3/7] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ab0c96e..b3295272 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -193,7 +193,7 @@ jobs: - ubuntu-latest - macos-13 runs-on: ${{ matrix.runner-os }} - #permissions: { security-events: write } + permissions: { security-events: write } steps: - name: Select appropriate Xcode version if: ${{ startsWith(matrix.runner-os, 'macos') }} From 0a2ef8d8bd585a926c4beca56bbc8e3654a3d2b4 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Sat, 5 Aug 2023 08:05:48 -0500 Subject: [PATCH 4/7] Add dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5ff65243 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +enable-beta-ecosystems: true +updates: + - package-ecosystem: "swift" + directory: "/" + schedule: + interval: "daily" + groups: + dependencies: + patterns: + - "*" From 5c1f05c936797b2625be9cfa05b4df2d62e3bfd0 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Sat, 5 Aug 2023 08:08:40 -0500 Subject: [PATCH 5/7] Delete dependabot.yml --- .github/dependabot.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 5ff65243..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 -enable-beta-ecosystems: true -updates: - - package-ecosystem: "swift" - directory: "/" - schedule: - interval: "daily" - groups: - dependencies: - patterns: - - "*" From a67bcef849c4501da756ad208a82a23394db9fb6 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 7 Aug 2023 03:57:56 -0500 Subject: [PATCH 6/7] Add general Vapor docs theme and Vapor+Postgres logo to API docs --- .../PostgresNIO/Docs.docc/images/article.svg | 1 + .../Docs.docc/images/vapor-postgres-logo.svg | 36 +++++++++++++++ .../PostgresNIO/Docs.docc/theme-settings.json | 46 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 Sources/PostgresNIO/Docs.docc/images/article.svg create mode 100644 Sources/PostgresNIO/Docs.docc/images/vapor-postgres-logo.svg create mode 100644 Sources/PostgresNIO/Docs.docc/theme-settings.json diff --git a/Sources/PostgresNIO/Docs.docc/images/article.svg b/Sources/PostgresNIO/Docs.docc/images/article.svg new file mode 100644 index 00000000..3dc6a66c --- /dev/null +++ b/Sources/PostgresNIO/Docs.docc/images/article.svg @@ -0,0 +1 @@ + diff --git a/Sources/PostgresNIO/Docs.docc/images/vapor-postgres-logo.svg b/Sources/PostgresNIO/Docs.docc/images/vapor-postgres-logo.svg new file mode 100644 index 00000000..e1c1223b --- /dev/null +++ b/Sources/PostgresNIO/Docs.docc/images/vapor-postgres-logo.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/Sources/PostgresNIO/Docs.docc/theme-settings.json b/Sources/PostgresNIO/Docs.docc/theme-settings.json new file mode 100644 index 00000000..9a734609 --- /dev/null +++ b/Sources/PostgresNIO/Docs.docc/theme-settings.json @@ -0,0 +1,46 @@ +{ + "theme": { + "aside": { + "border-radius": "6px", + "border-style": "double", + "border-width": "3px" + }, + "border-radius": "0", + "button": { + "border-radius": "16px", + "border-width": "1px", + "border-style": "solid" + }, + "code": { + "border-radius": "16px", + "border-width": "1px", + "border-style": "solid" + }, + "color": { + "fill": { + "dark": "rgb(20, 20, 22)", + "light": "rgb(255, 255, 255)" + }, + "psql-blue": "#336791", + "documentation-intro-fill": "radial-gradient(circle at top, var(--color-documentation-intro-accent) 30%, #1f1d1f 100%)", + "documentation-intro-accent": "var(--color-psql-blue)", + "documentation-intro-accent-outer": { + "dark": "rgb(255, 255, 255)", + "light": "rgb(51, 51, 51)" + }, + "documentation-intro-accent-inner": { + "dark": "rgb(51, 51, 51)", + "light": "rgb(255, 255, 255)" + } + }, + "icons": { + "technology": "/images/vapor-postgres-logo.svg", + "article": "/images/article.svg" + } + }, + "features": { + "quickNavigation": { + "enable": true + } + } +} From 5fca6730311e34cf536efb5e964c85a33609162c Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 7 Aug 2023 04:23:50 -0500 Subject: [PATCH 7/7] Cut two jobs out of the CI --- .github/workflows/test.yml | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3295272..2da05f81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,9 @@ jobs: - swift:5.8-jammy - swiftlang/swift:nightly-5.9-jammy - swiftlang/swift:nightly-main-jammy + include: + - swift-image: swift:5.8-jammy + code-coverage: true container: ${{ matrix.swift-image }} runs-on: ubuntu-latest steps: @@ -36,7 +39,13 @@ jobs: - name: Check out package uses: actions/checkout@v3 - name: Run unit tests with Thread Sanitizer - run: swift test --filter=^PostgresNIOTests --sanitize=thread + env: + CODE_COVERAGE: ${{ matrix.code-coverage && '--enable-code-coverage' || '' }} + run: | + swift test --filter=^PostgresNIOTests --sanitize=thread ${CODE_COVERAGE} + - name: Submit code coverage + if: ${{ matrix.code-coverage }} + uses: vapor/swift-codecov-action@v0.2 linux-integration-and-dependencies: if: github.event_name == 'pull_request' @@ -159,17 +168,6 @@ jobs: - name: Run all tests run: swift test - code-coverage: - runs-on: ubuntu-latest - container: swift:jammy - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: Run unit tests for coverage data - run: swift test --filter=^PostgresNIOTests --enable-code-coverage - - name: Upload coverage data - uses: vapor/swift-codecov-action@v0.2 - api-breakage: if: github.event_name == 'pull_request' runs-on: ubuntu-latest @@ -186,20 +184,9 @@ jobs: run: swift package diagnose-api-breaking-changes origin/main gh-codeql: - strategy: - fail-fast: false - matrix: - runner-os: - - ubuntu-latest - - macos-13 - runs-on: ${{ matrix.runner-os }} + runs-on: ubuntu-latest permissions: { security-events: write } steps: - - name: Select appropriate Xcode version - if: ${{ startsWith(matrix.runner-os, 'macos') }} - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '~14.3' - name: Check out code uses: actions/checkout@v3 - name: Initialize CodeQL