Skip to content

Improve Development Experience #451

Improve Development Experience

Improve Development Experience #451

name: Backwards Compatibility Unit Tests
concurrency:
group: '${{ github.workflow }}-${{ github.new_cc_ref || github.run_id }}'
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
old_cc_ref:
description: 'Old Version of CC_NG that the backwards compatibility should be checked against'
required: true
new_cc_ref:
description: 'New Version of CC_NG that needs testing for backwards incompatible changes'
required: true
new_cc_repo:
description: 'New REPO of CC_NG that needs testing for backwards incompatible changes'
required: false
default: 'cloudfoundry/cloud_controller_ng'
pull_request:
branches: [ main ]
paths:
- 'db/migrations/**'
- '.github/workflows/unit_tests_backwards_compatibility.yml'
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
Test-Postgres-Backwards-Compatibillity:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 3
matrix:
image: ["postgres:13", "postgres:15", "postgres:17"]
services:
postgres:
image: ${{ matrix.image }}
env:
POSTGRES_PASSWORD: rootpassword
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data
--shm-size=256m
ports:
- 5432:5432
steps:
- uses: hmarr/debug-action@v3
- name: Checkout code to run the db migration with
uses: actions/checkout@v4
with:
ref: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.new_cc_ref
|| github.event.pull_request.head.ref
)}}
repository: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.new_cc_repo
|| github.event.pull_request.head.repo.full_name
)}}
- name: Setup Environment
uses: ./.github/workflows/composite/setup
- name: Configure PostgreSQL for performance
run: |
sudo apt-get update && sudo apt-get install -y postgresql-client
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET fsync = off;"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET synchronous_commit = off;"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET full_page_writes = off;"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET checkpoint_completion_target = 0.9;"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET wal_buffers = '16MB';"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "ALTER SYSTEM SET shared_buffers = '256MB';"
PGPASSWORD=rootpassword psql -h localhost -U postgres -c "SELECT pg_reload_conf();"
- name: Migrate Database
run: DB=postgres POSTGRES_CONNECTION_PREFIX="postgres://postgres:rootpassword@localhost:5432" bundle exec rake db:parallel:recreate db:parallel:migrate
- name: Checkout code to run the unit tests with
uses: actions/checkout@v4
with:
ref: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.old_cc_ref
|| github.event.pull_request.base.sha
)}}
- name: Setup Environment
uses: ./.github/workflows/composite/setup
- name: Run Tests
run: DB=postgres POSTGRES_CONNECTION_PREFIX="postgres://postgres:rootpassword@localhost:5432" bundle exec rake spec:without_migrate
Test-Mysql-Backwards-Compatibillity:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 3
matrix:
image: ["mysql:5.7", "mysql:8.0", "mysql:8.2"]
services:
mysql:
image: ${{ matrix.image }}
env:
MYSQL_DATABASE: cc_test
MYSQL_ROOT_PASSWORD: password
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
--tmpfs /var/lib/mysql
--tmpfs /tmp
ports:
- 3306:3306
steps:
- uses: hmarr/debug-action@v3
- name: Checkout code to run the db migration with
uses: actions/checkout@v4
with:
ref: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.new_cc_ref
|| github.event.pull_request.head.ref
)}}
repository: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.new_cc_repo
|| github.event.pull_request.head.repo.full_name
)}}
- name: Setup Environment
uses: ./.github/workflows/composite/setup
- name: Configure MySQL for performance
run: |
sudo apt-get update && sudo apt-get install -y mysql-client
mysql -h 127.0.0.1 -u root -ppassword -e "SET GLOBAL innodb_flush_log_at_trx_commit = 0;"
mysql -h 127.0.0.1 -u root -ppassword -e "SET GLOBAL innodb_buffer_pool_size = 268435456;"
mysql -h 127.0.0.1 -u root -ppassword -e "SET GLOBAL innodb_log_buffer_size = 16777216;"
- name: Migrate Database
run: DB=mysql MYSQL_CONNECTION_PREFIX="mysql2://root:[email protected]:3306" bundle exec rake db:parallel:recreate db:parallel:migrate
- name: Checkout code to run the unit tests with
uses: actions/checkout@v4
with:
ref: ${{ (
github.event_name == 'workflow_dispatch'
&& github.event.inputs.old_cc_ref
|| github.event.pull_request.base.sha
)}}
- name: Setup Environment
uses: ./.github/workflows/composite/setup
- name: Run tests
run: DB=mysql MYSQL_CONNECTION_PREFIX="mysql2://root:[email protected]:3306" bundle exec rake spec:without_migrate