Tidy up package a bit (#103) #146
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 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request: { types: [opened, reopened, synchronize, ready_for_review] } | |
push: { branches: [ main ] } | |
env: | |
LOG_LEVEL: info | |
SWIFT_DETERMINISTIC_HASHING: 1 | |
MYSQL_DATABASE: 'test_database' | |
MYSQL_DATABASE_A: 'test_database' | |
MYSQL_DATABASE_B: 'test_database' | |
MYSQL_USERNAME: 'test_username' | |
MYSQL_USERNAME_A: 'test_username' | |
MYSQL_USERNAME_B: 'test_username' | |
MYSQL_PASSWORD: 'test_password' | |
MYSQL_PASSWORD_A: 'test_password' | |
MYSQL_PASSWORD_B: 'test_password' | |
MYSQL_HOSTNAME: 'mysql-a' | |
MYSQL_HOSTNAME_A: 'mysql-a' | |
MYSQL_HOSTNAME_B: 'mysql-b' | |
jobs: | |
dependency-graph: | |
if: ${{ github.event_name == 'push' }} | |
runs-on: ubuntu-latest | |
container: swift:jammy | |
permissions: | |
contents: write | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Fix Git configuration | |
run: | | |
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | |
apt-get update && apt-get install -y curl | |
- name: Submit dependency graph | |
uses: vapor-community/[email protected] | |
with: | |
path: ${{ github.workspace }} | |
api-breakage: | |
if: ${{ !(github.event.pull_request.draft || false) }} | |
runs-on: ubuntu-latest | |
container: swift:jammy | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: { 'fetch-depth': 0 } | |
- name: Run API breakage check | |
run: | | |
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | |
swift package diagnose-api-breaking-changes origin/main | |
gh-codeql: | |
if: ${{ !(github.event.pull_request.draft || false) }} | |
runs-on: ubuntu-latest | |
container: | |
image: swift:5.9-jammy | |
permissions: { actions: write, contents: read, security-events: write } | |
timeout-minutes: 60 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Mark repo safe in non-fake global config | |
run: | | |
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | |
- name: Check Swift compatibility | |
id: swift-check | |
uses: vapor/ci/.github/actions/check-compatible-swift@main | |
- name: Initialize CodeQL | |
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }} | |
uses: github/codeql-action/init@v3 | |
with: { languages: swift } | |
- name: Perform build | |
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }} | |
run: | | |
swift build | |
- name: Run CodeQL analyze | |
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }} | |
uses: github/codeql-action/analyze@v3 | |
linux-all: | |
if: ${{ !(github.event.pull_request.draft || false) }} | |
strategy: | |
fail-fast: false | |
matrix: | |
dbimage: | |
- mysql:5.7 | |
- mysql:8.2 | |
- mariadb:10.2 | |
- mariadb:11 | |
- percona:5.7 | |
- percona:8 | |
swiftver: | |
- swift:5.7-jammy | |
- swift:5.8-jammy | |
- swift:5.9-jammy | |
- swiftlang/swift:nightly-5.10-jammy | |
- swiftlang/swift:nightly-main-jammy | |
runs-on: ubuntu-latest | |
container: ${{ matrix.swiftver }} | |
services: | |
mysql-a: | |
image: ${{ matrix.dbimage }} | |
env: { MYSQL_ALLOW_EMPTY_PASSWORD: true, MYSQL_USER: test_username, MYSQL_PASSWORD: test_password, MYSQL_DATABASE: test_database } | |
mysql-b: | |
image: ${{ matrix.dbimage }} | |
env: { MYSQL_ALLOW_EMPTY_PASSWORD: true, MYSQL_USER: test_username, MYSQL_PASSWORD: test_password, MYSQL_DATABASE: test_database } | |
steps: | |
- name: Check out package | |
uses: actions/checkout@v4 | |
with: { path: 'mysql-nio' } | |
- name: Run unit tests | |
run: swift test --package-path mysql-nio --enable-code-coverage --sanitize=thread | |
- name: Upload code coverage | |
uses: vapor/[email protected] | |
with: | |
package_path: 'mysql-nio' | |
- name: Check out mysql-kit dependent | |
uses: actions/checkout@v4 | |
with: { repository: 'vapor/mysql-kit', path: 'mysql-kit' } | |
- name: Check out fluent-mysql-driver dependent | |
uses: actions/checkout@v4 | |
with: { repository: 'vapor/fluent-mysql-driver', path: 'fluent-mysql-driver' } | |
- name: Use local package in dependents | |
run: | | |
swift package --package-path mysql-kit edit mysql-nio --path mysql-nio | |
swift package --package-path fluent-mysql-driver edit mysql-nio --path mysql-nio | |
- name: Run mysql-kit tests | |
run: swift test --package-path mysql-kit | |
- name: Run fluent-mysql-driver tests | |
run: swift test --package-path fluent-mysql-driver | |
macos-all: | |
if: ${{ !(github.event.pull_request.draft || false) }} | |
strategy: | |
fail-fast: false | |
matrix: | |
dbimage: [mysql, mariadb, percona-server] | |
xcode: ['~14.3', 'latest'] | |
macos: ['macos-13'] | |
include: | |
- { username: root } | |
- { dbimage: mariadb, username: runner } | |
runs-on: ${{ matrix.macos }} | |
env: { MYSQL_HOSTNAME: '127.0.0.1' } | |
steps: | |
- name: Select latest available Xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: ${{ matrix.xcode }} | |
- name: Install MySQL, setup DB and auth, and wait for server start | |
env: | |
FORMULA: ${{ matrix.dbimage }} | |
RUNAS_USER: ${{ matrix.username }} | |
shell: bash | |
run: | | |
brew install "${FORMULA}" && brew link --force "${FORMULA}" | |
brew services start "${FORMULA}" | |
until echo | mysql -u"${RUNAS_USER}"; do sleep 1; done | |
mysql -u"${RUNAS_USER}" --batch <<-SQL | |
CREATE USER ${MYSQL_USERNAME}@localhost IDENTIFIED BY '${MYSQL_PASSWORD}'; | |
CREATE DATABASE ${MYSQL_DATABASE}; | |
GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO ${MYSQL_USERNAME}@localhost; | |
SQL | |
timeout-minutes: 5 | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Run all tests | |
run: swift test --sanitize=thread --enable-code-coverage | |
- name: Upload code coverage | |
uses: vapor/[email protected] |