forked from babelfish-for-postgresql/babelfish_extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (122 loc) · 6.8 KB
/
upgrade-test.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
129
130
131
132
133
134
135
name: Version Upgrade Test Framework
on: [push, pull_request]
jobs:
generate-version-upgrade-tests:
name: Generate Version Upgrade Tests
runs-on: ubuntu-20.04
outputs:
upgrade-path-list: ${{ steps.generate-upgrade-path.outputs.upgrade-path-list }}
steps:
- uses: actions/checkout@v2
- name: "Read and setup upgrade path list from configuration"
id: generate-upgrade-path
run: |
config="'$(yq -o=json ${{ github.workspace }}/.github/configuration/upgrade-test-configuration.yml)'"
config=$(echo $config | sed "s/\"/\\\\\"/g")
UPGRADE_PATH_LIST=$(node -e "let k = JSON.parse($config); let p = k['upgrade-version'].map((itm, index) => ({ id: index, path: itm.map(i => i.version.toString().replace(/[.]/g, \"_\")), title: itm.map(i => i.version.toString().replace(/[.]/g, \"_\")).join(\"-\"), last_version: itm[itm.length - 1].version.toString().replace(/[.]/g, \"_\") })); console.log(JSON.stringify(p));")
echo "::set-output name=upgrade-path-list::$UPGRADE_PATH_LIST"
run-version-upgrade-test:
needs: generate-version-upgrade-tests
strategy:
fail-fast: false
matrix:
upgrade-path: ${{ fromJson(needs.generate-version-upgrade-tests.outputs.upgrade-path-list) }}
name: Run Version Upgrade Test for ${{ matrix.upgrade-path.title }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install yq - yaml parser
id: install-yq
if: always()
run: sudo snap install yq
- name: Read Base Version and Final Version
id: read-base-and-final-version
if: always() && steps.install-yq.outcome == 'success'
run: >
echo "::set-output name=base-version::$(
yq '."upgrade-version"[${{ matrix.upgrade-path.id }}][0].version' ${{ github.workspace }}/.github/configuration/upgrade-test-configuration.yml
)" &&
echo "::set-output name=final-version::$(
yq '."upgrade-version"[${{ matrix.upgrade-path.id }}][-1].version' ${{ github.workspace }}/.github/configuration/upgrade-test-configuration.yml
)"
- name: Find Engine and Extension Branches for Base Version ${{ steps.read-base-and-final-version.outputs.base-version }}
id: find-branch
if: always() && steps.read-base-and-final-version.outcome == 'success'
run: >
echo "::set-output name=base-engine-branch::$(
yq '."${{ steps.read-base-and-final-version.outputs.base-version }}".engine_branch' ${{ github.workspace }}/.github/template/version-branch-template.yml
)" &&
echo "::set-output name=base-extension-branch::$(
yq '."${{ steps.read-base-and-final-version.outputs.base-version }}".extension_branch' ${{ github.workspace }}/.github/template/version-branch-template.yml
)" &&
echo "::set-output name=base-dir::$(echo postgres$(awk -F. '{print $1}' <<< ${{ steps.read-base-and-final-version.outputs.base-version }}))"
- name: Setup Base Version ${{ steps.read-base-and-final-version.outputs.base-version }} and Run Preparation Tests
id: setup-base-version
if: always() && steps.find-branch.outcome == 'success'
uses: ./.github/composite-actions/setup-base-version
with:
engine_branch: ${{ steps.find-branch.outputs.base-engine-branch }}
extension_branch: ${{ steps.find-branch.outputs.base-extension-branch }}
install_dir: ${{ steps.find-branch.outputs.base-dir }}
migration_mode: 'multi-db'
- name: Setup Upgrade Version Composite Action
id: setup-upgrade-ver-ca
if: always() && steps.install-yq.outcome == 'success' && steps.setup-base-version.outcome == 'success'
uses: ./.github/composite-actions/setup-upgrade-version-ca
with:
base_version: ${{ steps.read-base-and-final-version.outputs.base-version }}
- name: Upgrade till final version ${{ steps.read-base-and-final-version.outputs.final-version }} and run verify scripts
id: upgrade-and-test
if: always() && steps.setup-upgrade-ver-ca.outcome == 'success'
uses: ./.github/composite-actions/upgrade-version
# Due to some action/checkout's in previous step the dynamically generated upgrade-version composite action isn't available,
# hence to avoid error in post action step recreated the upgrade-version composite action
- name: Recreate Upgrade Version Composite Action
if: always() && steps.install-yq.outcome == 'success' && steps.setup-base-version.outcome == 'success'
uses: ./.github/composite-actions/setup-upgrade-version-ca
with:
base_version: ${{ steps.read-base-and-final-version.outputs.base-version }}
- name: Rename Test Summary Files
id: test-file-rename
if: always() && (steps.setup-base-version.outcome == 'failure' || steps.upgrade-and-test.outcome == 'failure')
run: |
cd test/JDBC/Info
timestamp=`ls -Art | tail -n 1`
cd $timestamp
mkdir -p ~/upgrade
cp $timestamp.diff ~/upgrade/output-diff.diff
cp "$timestamp"_runSummary.log ~/upgrade/run-summary.log
mkdir -p ~/failed-testscript-outputs
# copy output files of failed test scripts
BASE_VERSION=${{ steps.read-base-and-final-version.outputs.base-version }}
BASE_VERSION=${BASE_VERSION/./_}
FINAL_VERSION=${{ steps.read-base-and-final-version.outputs.final-version }}
FINAL_VERSION=${FINAL_VERSION/./_}
if [[ "$BASE_VERSION" == *"latest"* ]]; then
BASE_VERSION="latest"
fi
if [[ "$FINAL_VERSION" == *"latest"* ]]; then
FINAL_VERSION="latest"
fi
for f in $(grep "[A-Za-z_\-]*:[ ]*Failed" $timestamp"_runSummary.log" | cut -d ":" -f 1);
do
if [[ -f ../../output/$f".out" ]]; then
cp ../../output/$f".out" ~/failed-testscript-outputs/$f".out"
elif [[ -f ../../output/$BASE_VERSION"__preparation__"$f".out" ]]; then
cp ../../output/$BASE_VERSION"__preparation__"$f".out" ~/failed-testscript-outputs/$BASE_VERSION"__preparation__"$f".out"
else
cp ../../output/$FINAL_VERSION"__verification_cleanup__"$BASE_VERSION"__"$f".out" ~/failed-testscript-outputs/$FINAL_VERSION"__verification_cleanup__"$BASE_VERSION"__"$f".out"
fi
done
- name: Upload Logs
if: always() && steps.test-file-rename.outcome == 'success'
uses: actions/upload-artifact@v2
with:
name: upgrade-logs-${{ matrix.upgrade-path.title }}
path: |
~/upgrade/*.log
~/upgrade/*.diff
~/upgrade/*.out
~/upgrade/*.csv
~/postgres*/data/logfile
~/failed-testscript-outputs