-
Notifications
You must be signed in to change notification settings - Fork 361
128 lines (125 loc) · 4.69 KB
/
unit_tests_backwards_compatibility.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Backwards Compatibility Unit Tests
concurrency:
group: '${{ github.workflow }}-${{ github.new_cc_ref || github.run_id }}'
cancel-in-progress: true
on:
workflow_dispatch:
description: "This action tests backwards compatibility when db migrations are introduced. It tests database schema at new code(old_cc_ref) with unittests running old code(new_cc_ref) "
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: 30
strategy:
fail-fast: false
max-parallel: 3
matrix:
image: ["postgres:10", "postgres:11", "postgres:16"]
services:
postgres:
image: ${{ matrix.image }}
env:
POSTGRES_PASSWORD: rootpassword
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
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: 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: 30
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
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: 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