Ruby: add downgrade scripts to prepare-db-upgrade.sh

This commit is contained in:
Arthur Baars 2022-01-25 15:27:33 +01:00
Родитель 1e39259e26
Коммит cada7ef1a4
6 изменённых файлов: 1507 добавлений и 2 удалений

8
.github/workflows/ruby-qltest.yml поставляемый
Просмотреть файл

@ -48,3 +48,11 @@ jobs:
codeql dataset import -S ql/lib/upgrades/initial/ruby.dbscheme testdb empty.trap
codeql dataset upgrade testdb --additional-packs ql/lib
diff -q testdb/ruby.dbscheme ql/lib/ruby.dbscheme
- name: Check DB downgrade scripts
run: |
echo >empty.trap
rm -rf testdb; codeql dataset import -S ql/lib/ruby.dbscheme testdb empty.trap
codeql resolve upgrades --format=lines --allow-downgrades --additional-packs downgrades \
--dbscheme=ql/lib/ruby.dbscheme --target-dbscheme=downgrades/initial/ruby.dbscheme |
xargs codeql execute upgrades testdb
diff -q testdb/ruby.dbscheme downgrades/initial/ruby.dbscheme

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,4 @@
name: codeql/ruby-downgrades
groups: ruby
downgrades: .
library: true

Просмотреть файл

@ -7,6 +7,7 @@ rm -Recurse -Force extractor-pack
mkdir extractor-pack | Out-Null
cp codeql-extractor.yml, ql\lib\ruby.dbscheme, ql\lib\ruby.dbscheme.stats extractor-pack
cp -Recurse tools extractor-pack
cp -Recurse downgrades extractor-pack
mkdir extractor-pack\tools\win64 | Out-Null
cp target\release\ruby-extractor.exe extractor-pack\tools\win64\extractor.exe
cp target\release\ruby-autobuilder.exe extractor-pack\tools\win64\autobuilder.exe

Просмотреть файл

@ -17,7 +17,7 @@ codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
rm -rf extractor-pack
mkdir -p extractor-pack
cp -r codeql-extractor.yml tools ql/lib/ruby.dbscheme ql/lib/ruby.dbscheme.stats extractor-pack/
cp -r codeql-extractor.yml downgrades tools ql/lib/ruby.dbscheme ql/lib/ruby.dbscheme.stats extractor-pack/
mkdir -p extractor-pack/tools/${platform}
cp target/release/ruby-extractor extractor-pack/tools/${platform}/extractor
cp target/release/ruby-autobuilder extractor-pack/tools/${platform}/autobuilder

Просмотреть файл

@ -63,6 +63,7 @@ fi
scheme_file="ql/lib/ruby.dbscheme"
upgrade_root="ql/lib/upgrades"
downgrade_root="downgrades"
check_hash_valid()
{
@ -95,12 +96,28 @@ description: <INSERT DESCRIPTION HERE>
compatibility: full|backwards|partial|breaking
EOF
# Copy current and new dbscheme into the downgrade dir
downgradedir="${downgrade_root}/${current_hash}"
mkdir -p "${downgradedir}"
cp "${scheme_file}" "${downgradedir}/old.dbscheme"
git cat-file blob "${prev_hash}" > "${downgradedir}/$(basename "${scheme_file}")"
# Create the template upgrade.properties file.
cat <<EOF > "${downgradedir}/upgrade.properties"
description: <INSERT DESCRIPTION HERE>
compatibility: full|backwards|partial|breaking
EOF
# Tell user what we've done
cat <<EOF
Created upgrade directory here:
${upgradedir}
Created downgrade directory here:
${downgradedir}
Please update:
${upgradedir}/upgrade.properties
with appropriate upgrade instructions
${downgradedir}/upgrade.properties
with appropriate instructions
EOF