Repository navigation
Keep DateTime instants in pg timestamp params and Timeout::Error on Ruby 3.1's bundled timeout #71
Workflow file for this run
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: Tests | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: tests-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| on: | |
| workflow_call: # the Release workflow runs the full gate on the exact commit it releases | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "*" ] | |
| paths: | |
| - "**" | |
| - "!**.md" | |
| env: | |
| DB_NAME: tests | |
| DB_USER: root | |
| DB_PASS: pass | |
| jobs: | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3' | |
| bundler-cache: true | |
| # protocol codec, generator, golden snapshots, formatting rules (incl. the protobuf codec cross-check) | |
| - name: Unit & golden tests | |
| run: bundle exec rake test | |
| compatibility: | |
| name: Plugin on Ruby ${{ matrix.ruby-version }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.4', '4.0'] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| # the process plugin runs on whatever Ruby the user has: no bundler, only the standard library + minitest | |
| - name: Unit tests | |
| run: ruby -Ilib -Itest -e 'Dir["test/*_test.rb"].sort.each { |file| require File.expand_path(file) }' | |
| end2end-pg: | |
| name: End-to-End (PostgreSQL, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0'] | |
| variant: ['default'] | |
| include: | |
| - ruby-version: '4.0' | |
| variant: 'module-no-prepared' | |
| - ruby-version: '3.1' | |
| variant: 'bundled-timeout' | |
| services: | |
| postgres: | |
| image: postgres:16.2 | |
| env: | |
| POSTGRES_DB: tests | |
| POSTGRES_USER: root | |
| POSTGRES_PASSWORD: pass | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U root -d tests" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| env: | |
| POSTGRES_HOST: 127.0.0.1 | |
| EXAMPLES_DRIVER: pg | |
| EXAMPLES_MODULE: ${{ matrix.variant == 'module-no-prepared' && 'MyApp::Db' || 'PgCodegen' }} | |
| PREPARED_STATEMENTS: ${{ matrix.variant == 'module-no-prepared' && 'false' || 'true' }} | |
| E2E_TIMEOUT_GEM: ${{ matrix.variant == 'bundled-timeout' && '0.2.0' || '' }} | |
| BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }} | |
| - name: Load tool versions | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" | |
| - uses: sqlc-dev/setup-sqlc@v5 | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| with: | |
| sqlc-version: '${{ env.SQLC_VERSION }}' | |
| - name: Generate version-specific examples | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV" | |
| - name: Generate option variant | |
| if: matrix.variant == 'module-no-prepared' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver pg --options '{"moduleName":"MyApp::Db","preparedStatements":false}' | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV" | |
| - name: Install E2E dependencies | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: bundle install | |
| - name: Create the schema | |
| run: psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql | |
| env: | |
| PGPASSWORD: ${{ env.DB_PASS }} | |
| - name: End-to-End tests | |
| run: bundle exec rake end2end_pg | |
| end2end-mysql: | |
| name: End-to-End (MySQL, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0'] | |
| variant: ['default'] | |
| include: | |
| - ruby-version: '4.0' | |
| variant: 'module-name' | |
| services: | |
| mysql: | |
| image: mysql:8.3.0 | |
| env: | |
| MYSQL_DATABASE: tests | |
| MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd "mysqladmin ping -h 127.0.0.1" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 20 | |
| env: | |
| MYSQL_HOST: 127.0.0.1 | |
| EXAMPLES_DRIVER: mysql2 | |
| EXAMPLES_MODULE: ${{ matrix.variant == 'module-name' && 'MyApp::Db' || 'Mysql2Codegen' }} | |
| BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }} | |
| - name: Load tool versions | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" | |
| - uses: sqlc-dev/setup-sqlc@v5 | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| with: | |
| sqlc-version: '${{ env.SQLC_VERSION }}' | |
| - name: Generate version-specific examples | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV" | |
| - name: Generate option variant | |
| if: matrix.variant == 'module-name' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver mysql2 --options '{"moduleName":"MyApp::Db"}' | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV" | |
| - name: Install E2E dependencies | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: bundle install | |
| - name: Create the schema (and allow LOAD DATA LOCAL INFILE for :copyfrom) | |
| run: | | |
| mysql -h 127.0.0.1 -u "${DB_USER}" -e 'SET GLOBAL local_infile = 1' | |
| mysql -h 127.0.0.1 -u "${DB_USER}" "${DB_NAME}" < examples/authors/mysql/schema.sql | |
| - name: End-to-End tests | |
| run: bundle exec rake end2end_mysql2 | |
| end2end-sqlite: | |
| name: End-to-End (SQLite, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0'] | |
| variant: ['default'] | |
| include: | |
| - ruby-version: '4.0' | |
| variant: 'module-name' | |
| env: | |
| EXAMPLES_DRIVER: sqlite3 | |
| EXAMPLES_MODULE: ${{ matrix.variant == 'module-name' && 'MyApp::Db' || 'Sqlite3Codegen' }} | |
| BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }} | |
| - name: Load tool versions | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" | |
| - uses: sqlc-dev/setup-sqlc@v5 | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default' | |
| with: | |
| sqlc-version: '${{ env.SQLC_VERSION }}' | |
| - name: Generate version-specific examples | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV" | |
| - name: Generate option variant | |
| if: matrix.variant == 'module-name' | |
| run: | | |
| ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver sqlite3 --options '{"moduleName":"MyApp::Db"}' | |
| echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV" | |
| - name: Install E2E dependencies | |
| if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' | |
| run: bundle install | |
| - name: End-to-End tests | |
| run: bundle exec rake end2end_sqlite3 | |
| end2end-options: | |
| name: Generator options E2E (Ruby ${{ matrix.ruby-version }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '4.0'] | |
| services: | |
| postgres: | |
| image: postgres:16.2 | |
| env: | |
| POSTGRES_DB: tests | |
| POSTGRES_USER: root | |
| POSTGRES_PASSWORD: pass | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U root -d tests" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| env: | |
| POSTGRES_HOST: 127.0.0.1 | |
| BUNDLE_GEMFILE: Gemfile.options.e2e | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: false | |
| - name: Install options test dependencies | |
| run: bundle install | |
| - name: Load tool versions | |
| run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV" | |
| - uses: sqlc-dev/setup-sqlc@v5 | |
| with: | |
| sqlc-version: '${{ env.SQLC_VERSION }}' | |
| - name: End-to-end option tests | |
| run: bundle exec ruby tests/end2end_options.rb |