Code Coverage #2
This file contains 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: Code Coverage | |
on: | |
schedule: | |
- cron: '0 0 * * *' # runs every midnight | |
jobs: | |
run-code-coverage-tests: | |
runs-on: ubuntu-20.04 | |
env: | |
INSTALL_DIR: psql | |
steps: | |
- uses: actions/checkout@v2 | |
id: checkout | |
- name: Install Dependencies | |
id: install-dependencies | |
if: always() | |
uses: ./.github/composite-actions/install-dependencies | |
- name: Build Modified Postgres | |
id: build-modified-postgres | |
if: always() && steps.install-dependencies.outcome == 'success' | |
uses: ./.github/composite-actions/build-modified-postgres | |
with: | |
install_dir: ${{env.INSTALL_DIR}} | |
code_coverage: 'yes' | |
- name: Compile ANTLR | |
id: compile-antlr | |
if: always() && steps.build-modified-postgres.outcome == 'success' | |
uses: ./.github/composite-actions/compile-antlr | |
with: | |
install_dir: ${{env.INSTALL_DIR}} | |
- name: Build Extensions | |
id: build-extensions | |
if: always() && steps.compile-antlr.outcome == 'success' | |
uses: ./.github/composite-actions/build-extensions | |
with: | |
install_dir: ${{env.INSTALL_DIR}} | |
- name: Build tds_fdw Extension | |
id: build-tds_fdw-extension | |
if: always() && steps.build-extensions.outcome == 'success' | |
uses: ./.github/composite-actions/build-tds_fdw-extension | |
- name: Build vector Extension | |
id: build-vector-extension | |
if: always() && steps.build-tds_fdw-extension.outcome == 'success' | |
uses: ./.github/composite-actions/build-vector-extension | |
- name: Build PostGIS Extension | |
id: build-postgis-extension | |
if: always() && steps.build-vector-extension.outcome == 'success' | |
uses: ./.github/composite-actions/build-postgis-extension | |
- name: Install Extensions | |
id: install-extensions | |
if: always() && steps.build-extensions.outcome == 'success' | |
uses: ./.github/composite-actions/install-extensions | |
with: | |
install_dir: ${{env.INSTALL_DIR}} | |
- name: Run JDBC Tests | |
id: run-jdbc-tests | |
if: always() && steps.install-extensions.outcome == 'success' | |
timeout-minutes: 60 | |
uses: ./.github/composite-actions/run-jdbc-tests | |
- name: Run Dotnet Tests | |
id: install-and-run-dotnet | |
if: always() && steps.install-extensions.outcome == 'success' | |
uses: ./.github/composite-actions/install-and-run-dotnet | |
- name: Run ODBC Tests | |
id: install-and-run-odbc-tests | |
if: always() && steps.install-extensions.outcome == 'success' | |
uses: ./.github/composite-actions/install-and-run-odbc | |
- name: Drop and re-create Babelfish database | |
id: re-install-extensions | |
if: always() && steps.install-extensions.outcome == 'success' | |
run: | | |
sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql | |
sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode="multi-db" -v tsql_port=1433 -v parallel_query_mode=false -f .github/scripts/create_extension.sql | |
sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" | |
- name: Run Python Tests | |
id: install-and-run-python | |
if: always() && steps.re-install-extensions.outcome == 'success' | |
uses: ./.github/composite-actions/install-and-run-python | |
- name: Generate code coverage HTML report | |
id: code-coverage | |
if: always() | |
run: | | |
export PG_CONFIG=~/psql/bin/pg_config | |
export PG_SRC=~/work/postgresql_modified_for_babelfish | |
export cmake=$(which cmake) | |
cd contrib | |
for ext in babelfishpg_common babelfishpg_money babelfishpg_tds babelfishpg_tsql | |
do | |
cd $ext | |
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -i -d . -d ./ -o lcov_base.info | |
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -d . -d ./ -o lcov_test.info | |
rm -rf coverage | |
/usr/bin/genhtml -q --legend -o coverage --title='$ext' --ignore-errors source --num-spaces=4 lcov_base.info lcov_test.info | |
touch coverage-html-stamp | |
cd .. | |
done | |
shell: bash | |
- name: Summarize code coverage | |
id: code-coverage-summary | |
if: always() | |
run: | | |
cd contrib/ | |
lcov -a babelfishpg_tsql/lcov_test.info -a babelfishpg_tds/lcov_test.info -a babelfishpg_common/lcov_test.info -a babelfishpg_money/lcov_test.info -o lcov.info | |
lcov --list lcov.info | |
- name: Upload Coverage Report for babelfishpg_tsql extension | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_tsql_${{github.ref_name}} | |
path: contrib/babelfishpg_tsql/coverage/ | |
- name: Upload Coverage Report for babelfishpg_tds extension | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_tds_${{github.ref_name}} | |
path: contrib/babelfishpg_tds/coverage/ | |
- name: Upload Coverage Report for babelfishpg_common extension | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_common_${{github.ref_name}} | |
path: contrib/babelfishpg_common/coverage/ | |
- name: Upload Coverage Report for babelfishpg_money extension | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_money_${{github.ref_name}} | |
path: contrib/babelfishpg_money/coverage/ | |
- name: Download CSV report from previous run | |
if: (github.event_name == 'schedule') | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
name: csv_${{github.ref_name}} | |
path: contrib/ | |
search_artifacts: true | |
if_no_artifact_found: warn | |
- name: Add latest coverage numbers to CSV file | |
if: (github.event_name == 'schedule') | |
run: | | |
cd contrib/ | |
paste -s -d, <(date +"%m/%d/%Y %H:%M:%S";lcov --summary lcov.info | grep -Po "[0-9]+\.[0-9]*") >> ${{github.ref_name}}.csv | |
shell: bash | |
- name: Upload CSV report with latest coverage numbers | |
if: (github.event_name == 'schedule') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: csv_${{github.ref_name}} | |
path: contrib/${{github.ref_name}}.csv |